-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ops): V8 Fast Calls #15291
feat(ops): V8 Fast Calls #15291
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
I finally managed to understand that the fast bindings are generated to an extra function bound into the original function but... Why? Does the references snapshotting somehow not work with direct binding to the normal op call function? |
for ctx in ops { | ||
let ctx_ptr = ctx as *const OpCtx as _; | ||
references.push(v8::ExternalReference { pointer: ctx_ptr }); | ||
references.push(v8::ExternalReference { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are all this external refs now suddenly needed when previously they were not?
) { | ||
for ctx in op_ctxs { | ||
let ctx_ptr = ctx as *const OpCtx as *const c_void; | ||
set_func_raw(scope, ops_obj, ctx.decl.name, ctx.decl.v8_fn_ptr, ctx_ptr); | ||
|
||
// If this is a fast op, we don't want it to be in the snapshot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this explains why the boolean is used here, it does not actually explain why the fast op is not wanted in the snapshot. At least I would like to understand why the fast op is left out: Is it because of the doubling of the OpCtx
and slow call function pointer referencing?
@@ -1344,17 +1344,17 @@ async fn op_flash_next_async( | |||
// the ContextScope creation is optimized away and the op is as simple as: | |||
// f(info: *const v8::FunctionCallbackInfo) { let rv = ...; rv.set_uint32(op_flash_next()); } | |||
#[op] | |||
fn op_flash_next(op_state: &mut OpState) -> u32 { | |||
let flash_ctx = op_state.borrow_mut::<FlashContext>(); | |||
fn op_flash_next(state: &mut OpState) -> u32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This is awesome - great work @littledivy |
Relands auto fast api template generation for ops. This optimization is opt in: