diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-05-21 22:23:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-21 20:23:28 +0000 |
commit | 9ec49897766d9c22f6c7bafabdd3e3f3a4b68ab1 (patch) | |
tree | e618fc4b47a720ce2392794a73735c7e28c3ca4c /core/bindings.rs | |
parent | addfb0c546f3cd911514591a91a9eef2ce5e3cec (diff) |
refactor(core): set function names for ops in JavaScript (#19208)
This commit ensures that JavaScript functions generated for registered
ops have proper names set up - the function name matches the name
of the op.
A test was added in `core/runtime.rs` that verifies this.
Closes https://github.com/denoland/deno/issues/19206
Diffstat (limited to 'core/bindings.rs')
-rw-r--r-- | core/bindings.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/bindings.rs b/core/bindings.rs index 8ad3948a5..46b6c622c 100644 --- a/core/bindings.rs +++ b/core/bindings.rs @@ -206,12 +206,15 @@ fn op_ctx_function<'s>( ) -> v8::Local<'s, v8::Function> { let op_ctx_ptr = op_ctx as *const OpCtx as *const c_void; let external = v8::External::new(scope, op_ctx_ptr as *mut c_void); + let v8name = + v8::String::new_external_onebyte_static(scope, op_ctx.decl.name.as_bytes()) + .unwrap(); let builder: v8::FunctionBuilder<v8::FunctionTemplate> = v8::FunctionTemplate::builder_raw(op_ctx.decl.v8_fn_ptr) .data(external.into()) .length(op_ctx.decl.arg_count as i32); - let templ = if let Some(fast_function) = &op_ctx.decl.fast_fn { + let template = if let Some(fast_function) = &op_ctx.decl.fast_fn { builder.build_fast( scope, fast_function, @@ -222,7 +225,10 @@ fn op_ctx_function<'s>( } else { builder.build(scope) }; - templ.get_function(scope).unwrap() + + let v8fn = template.get_function(scope).unwrap(); + v8fn.set_name(v8name); + v8fn } pub extern "C" fn wasm_async_resolve_promise_callback( |