-
Notifications
You must be signed in to change notification settings - Fork 94
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: op2 codegen for object methods #682
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,8 +183,6 @@ impl InnerIsolateState { | |
unsafe { | ||
ManuallyDrop::take(&mut self.main_realm).0.destroy(); | ||
} | ||
|
||
debug_assert_eq!(Rc::strong_count(&self.state), 1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is definitely a smell here -- we're leaking OpCtxs. |
||
} | ||
|
||
pub fn prepare_for_snapshot(mut self) -> v8::OwnedIsolate { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -439,6 +439,21 @@ pub(crate) fn generate_dispatch_fast( | |
quote!() | ||
}; | ||
|
||
let with_self = if generator_state.needs_self { | ||
gs_quote!(generator_state(self_ty) => { | ||
let self_: &#self_ty = deno_core::cppgc::try_unwrap_cppgc_object(this.into()).unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 awesome |
||
}) | ||
} else { | ||
quote!() | ||
}; | ||
|
||
let name = &generator_state.name; | ||
let call = if generator_state.needs_self { | ||
quote!(self_. #name) | ||
} else { | ||
quote!(Self:: #name) | ||
}; | ||
|
||
let with_opctx = if generator_state.needs_fast_opctx { | ||
generator_state.needs_fast_api_callback_options = true; | ||
gs_quote!(generator_state(opctx, fast_api_callback_options) => { | ||
|
@@ -503,7 +518,7 @@ pub(crate) fn generate_dispatch_fast( | |
|
||
#[allow(clippy::too_many_arguments)] | ||
extern "C" fn #fast_function( | ||
_: deno_core::v8::Local<deno_core::v8::Object>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's split this one line change into its own PR + the test changes to reduce the PR size. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it will be a warning (unused argument) if landed seperately There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No worries -- just add |
||
this: deno_core::v8::Local<deno_core::v8::Object>, | ||
#( #fastcall_names: #fastcall_types, )* | ||
) -> #output_type { | ||
#[cfg(debug_assertions)] | ||
|
@@ -512,9 +527,11 @@ pub(crate) fn generate_dispatch_fast( | |
#with_fast_api_callback_options | ||
#with_opctx | ||
#with_js_runtime_state | ||
#with_self | ||
|
||
let #result = { | ||
#(#call_args)* | ||
Self::call(#(#call_names),*) | ||
#call (#(#call_names),*) | ||
}; | ||
#handle_error | ||
#handle_result | ||
|
@@ -624,6 +641,10 @@ fn map_v8_fastcall_arg_to_arg( | |
*needs_js_runtime_state = true; | ||
quote!(let #arg_ident = &#js_runtime_state;) | ||
} | ||
Arg::Ref(RefType::Ref, Special::OpCtx) => { | ||
*needs_opctx = true; | ||
quote!(let #arg_ident = #opctx;) | ||
} | ||
Arg::State(RefType::Ref, state) => { | ||
*needs_opctx = true; | ||
let state = | ||
|
@@ -783,6 +804,7 @@ fn map_arg_to_v8_fastcall_type( | |
| Arg::Ref(_, Special::OpState) | ||
| Arg::Rc(Special::JsRuntimeState) | ||
| Arg::Ref(RefType::Ref, Special::JsRuntimeState) | ||
| Arg::Ref(RefType::Ref, Special::OpCtx) | ||
| Arg::State(..) | ||
| Arg::Special(Special::Isolate) | ||
| Arg::OptionState(..) | ||
|
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.
We should try to create these once when the JsRuntime is created and then look them up.