1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

chore(core): remove argc field from OpDecl (#18024)

https://github.com/denoland/deno/pull/18023#discussion_r1125611859
This commit is contained in:
Divy Srivastava 2023-03-05 16:46:43 +05:30 committed by GitHub
parent da201d9ea5
commit d4807f458e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 54 additions and 96 deletions

View file

@ -51,9 +51,6 @@ pub struct OpDecl {
pub enabled: bool, pub enabled: bool,
pub is_async: bool, pub is_async: bool,
pub is_unstable: bool, pub is_unstable: bool,
/// V8 argument count. Used as an optimization
/// hint by `core.initalizeAsyncOps`.
pub argc: usize,
pub is_v8: bool, pub is_v8: bool,
pub fast_fn: Option<Box<dyn FastFunction>>, pub fast_fn: Option<Box<dyn FastFunction>>,
} }

View file

@ -145,7 +145,6 @@ impl Op {
is_async: #is_async, is_async: #is_async,
is_unstable: #is_unstable, is_unstable: #is_unstable,
is_v8: #is_v8, is_v8: #is_v8,
argc: 0,
} }
} }
@ -160,7 +159,7 @@ impl Op {
let has_fallible_fast_call = active && optimizer.returns_result; let has_fallible_fast_call = active && optimizer.returns_result;
let (v8_body, argc) = if is_async { let v8_body = if is_async {
let deferred = attrs.deferred; let deferred = attrs.deferred;
codegen_v8_async( codegen_v8_async(
&core, &core,
@ -202,7 +201,6 @@ impl Op {
is_async: #is_async, is_async: #is_async,
is_unstable: #is_unstable, is_unstable: #is_unstable,
is_v8: #is_v8, is_v8: #is_v8,
argc: #argc,
} }
} }
@ -239,7 +237,7 @@ fn codegen_v8_async(
margs: Attributes, margs: Attributes,
asyncness: bool, asyncness: bool,
deferred: bool, deferred: bool,
) -> (TokenStream2, usize) { ) -> TokenStream2 {
let Attributes { is_v8, .. } = margs; let Attributes { is_v8, .. } = margs;
let special_args = f let special_args = f
.sig .sig
@ -253,7 +251,7 @@ fn codegen_v8_async(
let rust_i0 = special_args.len(); let rust_i0 = special_args.len();
let args_head = special_args.into_iter().collect::<TokenStream2>(); let args_head = special_args.into_iter().collect::<TokenStream2>();
let (arg_decls, args_tail, argc) = codegen_args(core, f, rust_i0, 1, true); let (arg_decls, args_tail, _) = codegen_args(core, f, rust_i0, 1, true);
let type_params = exclude_lifetime_params(&f.sig.generics.params); let type_params = exclude_lifetime_params(&f.sig.generics.params);
let (pre_result, mut result_fut) = match asyncness { let (pre_result, mut result_fut) = match asyncness {
@ -284,7 +282,6 @@ fn codegen_v8_async(
false => quote! { let result = Ok(result); }, false => quote! { let result = Ok(result); },
}; };
(
quote! { quote! {
use #core::futures::FutureExt; use #core::futures::FutureExt;
// SAFETY: #core guarantees args.data() is a v8 External pointing to an OpCtx for the isolates lifetime // SAFETY: #core guarantees args.data() is a v8 External pointing to an OpCtx for the isolates lifetime
@ -323,9 +320,7 @@ fn codegen_v8_async(
#result_wrapper #result_wrapper
(realm_idx, promise_id, op_id, #core::_ops::to_op_result(get_class, result)) (realm_idx, promise_id, op_id, #core::_ops::to_op_result(get_class, result))
}); });
}, }
argc,
)
} }
fn scope_arg(arg: &FnArg) -> Option<TokenStream2> { fn scope_arg(arg: &FnArg) -> Option<TokenStream2> {
@ -362,7 +357,7 @@ fn codegen_v8_sync(
f: &syn::ItemFn, f: &syn::ItemFn,
margs: Attributes, margs: Attributes,
has_fallible_fast_call: bool, has_fallible_fast_call: bool,
) -> (TokenStream2, usize) { ) -> TokenStream2 {
let Attributes { is_v8, .. } = margs; let Attributes { is_v8, .. } = margs;
let special_args = f let special_args = f
.sig .sig
@ -374,7 +369,7 @@ fn codegen_v8_sync(
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let rust_i0 = special_args.len(); let rust_i0 = special_args.len();
let args_head = special_args.into_iter().collect::<TokenStream2>(); let args_head = special_args.into_iter().collect::<TokenStream2>();
let (arg_decls, args_tail, argc) = codegen_args(core, f, rust_i0, 0, false); let (arg_decls, args_tail, _) = codegen_args(core, f, rust_i0, 0, false);
let ret = codegen_sync_ret(core, &f.sig.output); let ret = codegen_sync_ret(core, &f.sig.output);
let type_params = exclude_lifetime_params(&f.sig.generics.params); let type_params = exclude_lifetime_params(&f.sig.generics.params);
@ -393,7 +388,6 @@ fn codegen_v8_sync(
quote! {} quote! {}
}; };
(
quote! { quote! {
// SAFETY: #core guarantees args.data() is a v8 External pointing to an OpCtx for the isolates lifetime // SAFETY: #core guarantees args.data() is a v8 External pointing to an OpCtx for the isolates lifetime
let ctx = unsafe { let ctx = unsafe {
@ -411,9 +405,7 @@ fn codegen_v8_sync(
op_state.tracker.track_sync(ctx.id); op_state.tracker.track_sync(ctx.id);
#ret #ret
}, }
argc,
)
} }
/// (full declarations, idents, v8 argument count) /// (full declarations, idents, v8 argument count)

View file

@ -26,7 +26,6 @@ impl op_void_async {
is_async: true, is_async: true,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 0usize,
} }
} }
#[inline] #[inline]

View file

@ -26,7 +26,6 @@ impl op_async_result {
is_async: true, is_async: true,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 1usize,
} }
} }
#[inline] #[inline]

View file

@ -26,7 +26,6 @@ impl op_fallback {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 1usize,
} }
} }
#[inline] #[inline]

View file

@ -26,7 +26,6 @@ impl op_cow_str {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 1usize,
} }
} }
#[inline] #[inline]

View file

@ -26,7 +26,6 @@ impl op_f64_buf {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 1usize,
} }
} }
#[inline] #[inline]

View file

@ -22,7 +22,6 @@ impl op_sync_serialize_object_with_numbers_as_keys {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 1usize,
} }
} }
#[inline] #[inline]

View file

@ -22,7 +22,6 @@ impl send_stdin {
is_async: true, is_async: true,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 1usize,
} }
} }
#[inline] #[inline]

View file

@ -22,7 +22,6 @@ impl send_stdin {
is_async: true, is_async: true,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 1usize,
} }
} }
#[inline] #[inline]

View file

@ -22,7 +22,6 @@ impl op_blob_revoke_object_url {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 1usize,
} }
} }
#[inline] #[inline]

View file

@ -26,7 +26,6 @@ impl op_ffi_ptr_value {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 2usize,
} }
} }
#[inline] #[inline]

View file

@ -22,7 +22,6 @@ impl op_print {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 2usize,
} }
} }
#[inline] #[inline]

View file

@ -26,7 +26,6 @@ impl op_set_exit_code {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 1usize,
} }
} }
#[inline] #[inline]

View file

@ -26,7 +26,6 @@ impl foo {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 2usize,
} }
} }
#[inline] #[inline]

View file

@ -32,7 +32,6 @@ impl op_foo {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 0usize,
} }
} }
#[inline] #[inline]

View file

@ -26,7 +26,6 @@ impl foo {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 2usize,
} }
} }
#[inline] #[inline]

View file

@ -26,7 +26,6 @@ impl op_listen {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 0usize,
} }
} }
#[inline] #[inline]

View file

@ -32,7 +32,6 @@ impl op_now {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 1usize,
} }
} }
#[inline] #[inline]

View file

@ -26,7 +26,6 @@ impl op_add_4 {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 4usize,
} }
} }
#[inline] #[inline]

View file

@ -22,7 +22,6 @@ impl op_try_close {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 1usize,
} }
} }
#[inline] #[inline]

View file

@ -26,7 +26,6 @@ impl op_string_length {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 1usize,
} }
} }
#[inline] #[inline]

View file

@ -22,7 +22,6 @@ impl op_read_sync {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 2usize,
} }
} }
#[inline] #[inline]

View file

@ -32,7 +32,6 @@ impl op_ffi_ptr_of {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 2usize,
} }
} }
#[inline] #[inline]

View file

@ -26,7 +26,6 @@ impl op_is_proxy {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 1usize,
} }
} }
#[inline] #[inline]

View file

@ -26,7 +26,6 @@ impl op_string_length {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 1usize,
} }
} }
#[inline] #[inline]

View file

@ -22,7 +22,6 @@ impl op_string_length {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 1usize,
} }
} }
#[inline] #[inline]

View file

@ -22,7 +22,6 @@ impl op_bench_now {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 0usize,
} }
} }
#[inline] #[inline]

View file

@ -26,7 +26,6 @@ impl op_import_spki_x25519 {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 2usize,
} }
} }
#[inline] #[inline]

View file

@ -26,7 +26,6 @@ impl op_unit_result {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 0usize,
} }
} }
#[inline] #[inline]

View file

@ -26,7 +26,6 @@ impl op_set_nodelay {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 2usize,
} }
} }
#[inline] #[inline]

View file

@ -26,7 +26,6 @@ impl op_unit {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 0usize,
} }
} }
#[inline] #[inline]

View file

@ -26,7 +26,6 @@ impl op_wasm {
is_async: false, is_async: false,
is_unstable: false, is_unstable: false,
is_v8: false, is_v8: false,
argc: 1usize,
} }
} }
#[inline] #[inline]