Skip to content

Commit

Permalink
perf: externalize op name strings (#1049)
Browse files Browse the repository at this point in the history
  • Loading branch information
littledivy authored Jan 19, 2025
1 parent 12a3c63 commit 3949be9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions core/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,12 @@ impl OpCtx {

/// Generates four external references for each op. If an op does not have a fastcall, it generates
/// "null" slots to avoid changing the size of the external references array.
pub const fn external_references(&self) -> [v8::ExternalReference; 4] {
pub const fn external_references(&self) -> [v8::ExternalReference; 5] {
extern "C" fn placeholder() {}

let name_ptr = v8::ExternalReference {
pointer: self.decl.name_fast.into_v8_const_ptr() as _,
};
let ctx_ptr = v8::ExternalReference {
pointer: self as *const OpCtx as _,
};
Expand All @@ -165,9 +168,9 @@ impl OpCtx {
let fast_info = v8::ExternalReference {
type_info: fast_fn_info.type_info(),
};
[ctx_ptr, slow_fn, fast_fn, fast_info]
[name_ptr, ctx_ptr, slow_fn, fast_fn, fast_info]
} else {
[ctx_ptr, slow_fn, null, null]
[name_ptr, ctx_ptr, slow_fn, null, null]
}
} else {
let slow_fn = v8::ExternalReference {
Expand All @@ -182,9 +185,9 @@ impl OpCtx {
let fast_info = v8::ExternalReference {
type_info: fast_fn_info.type_info(),
};
[ctx_ptr, slow_fn, fast_fn, fast_info]
[name_ptr, ctx_ptr, slow_fn, fast_fn, fast_info]
} else {
[ctx_ptr, slow_fn, null, null]
[name_ptr, ctx_ptr, slow_fn, null, null]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/runtime/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub(crate) fn create_external_references(
let mut references = Vec::with_capacity(
6 + CONTEXT_SETUP_SOURCES.len()
+ BUILTIN_SOURCES.len()
+ (ops.len() * 4)
+ (ops.len() * 5)
+ additional_references.len()
+ sources.len()
+ 18, // for callsite_fns
Expand Down

0 comments on commit 3949be9

Please sign in to comment.