diff options
-rw-r--r-- | Cargo.lock | 31 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | ext/node/global.rs | 66 | ||||
-rw-r--r-- | ext/node/ops/vm_internal.rs | 67 |
4 files changed, 94 insertions, 72 deletions
diff --git a/Cargo.lock b/Cargo.lock index 0f29b9995..fa928f07c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1303,9 +1303,9 @@ dependencies = [ [[package]] name = "deno_core" -version = "0.284.0" +version = "0.285.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4a5c809e81be26fcfbbce4275573251f6a156137b67059889e9e38f73e75b63" +checksum = "1b2df681c5746ff035671d98a3aa906f818024bb1bb9b8f9122a38cdc6a1b6e4" dependencies = [ "anyhow", "bincode", @@ -1759,9 +1759,9 @@ dependencies = [ [[package]] name = "deno_ops" -version = "0.160.0" +version = "0.161.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "517e54d41a2da6a69b8f534294334d79d9115ddd43aea88a5ceefdb717e6d85e" +checksum = "504faf12efd80bdef6dc4d693072479dd916f397a151893963db66fb061f0c9d" dependencies = [ "proc-macro-rules", "proc-macro2", @@ -5763,9 +5763,9 @@ dependencies = [ [[package]] name = "serde_v8" -version = "0.193.0" +version = "0.194.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21ec612dfc7ab70330b5405e8015b25e637bbfe1d79c4bd173557933aea66e76" +checksum = "c56fad5568bad7902594c0b2fd33f7b97c1eb539837cc9a7f9d7742ca1c77883" dependencies = [ "num-bigint", "serde", @@ -7337,9 +7337,9 @@ dependencies = [ [[package]] name = "v8" -version = "0.92.0" +version = "0.93.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "234589219e37a7496cbce73d971586db8369871be2420372c45a579b6a919b15" +checksum = "abc3ff12243d345cc697c151b29fbb8ad1f898e3f8b7aa1386701ff9f2c7cbbf" dependencies = [ "bitflags 2.5.0", "fslock", @@ -7347,7 +7347,7 @@ dependencies = [ "home", "miniz_oxide", "once_cell", - "which 5.0.0", + "which 6.0.1", ] [[package]] @@ -7640,15 +7640,14 @@ dependencies = [ [[package]] name = "which" -version = "5.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bf3ea8596f3a0dd5980b46430f2058dfe2c36a27ccfbb1845d6fbfcd9ba6e14" +checksum = "8211e4f58a2b2805adfbefbc07bab82958fc91e3836339b1ab7ae32465dce0d7" dependencies = [ "either", "home", - "once_cell", "rustix", - "windows-sys 0.48.0", + "winsafe", ] [[package]] @@ -7889,6 +7888,12 @@ dependencies = [ ] [[package]] +name = "winsafe" +version = "0.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" + +[[package]] name = "wtf8" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/Cargo.toml b/Cargo.toml index 26f242036..d3bdf17f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,7 +44,7 @@ repository = "https://github.com/denoland/deno" [workspace.dependencies] deno_ast = { version = "=0.39.1", features = ["transpiling"] } -deno_core = { version = "0.284.0" } +deno_core = { version = "0.285.0" } deno_bench_util = { version = "0.149.0", path = "./bench_util" } deno_lockfile = "0.20.0" diff --git a/ext/node/global.rs b/ext/node/global.rs index d2fe7a1e5..5c95b2f8f 100644 --- a/ext/node/global.rs +++ b/ext/node/global.rs @@ -15,13 +15,13 @@ use crate::resolution::NodeResolverRc; // these mapped functions per-thread. We should revisit it in the future and // ideally remove altogether. thread_local! { - pub static GETTER_MAP_FN: v8::GenericNamedPropertyGetterCallback<'static> = getter.map_fn_to(); - pub static SETTER_MAP_FN: v8::GenericNamedPropertySetterCallback<'static> = setter.map_fn_to(); - pub static QUERY_MAP_FN: v8::GenericNamedPropertyGetterCallback<'static> = query.map_fn_to(); - pub static DELETER_MAP_FN: v8::GenericNamedPropertyGetterCallback<'static> = deleter.map_fn_to(); - pub static ENUMERATOR_MAP_FN: v8::GenericNamedPropertyEnumeratorCallback<'static> = enumerator.map_fn_to(); - pub static DEFINER_MAP_FN: v8::GenericNamedPropertyDefinerCallback<'static> = definer.map_fn_to(); - pub static DESCRIPTOR_MAP_FN: v8::GenericNamedPropertyGetterCallback<'static> = descriptor.map_fn_to(); + pub static GETTER_MAP_FN: v8::NamedPropertyGetterCallback<'static> = getter.map_fn_to(); + pub static SETTER_MAP_FN: v8::NamedPropertySetterCallback<'static> = setter.map_fn_to(); + pub static QUERY_MAP_FN: v8::NamedPropertyGetterCallback<'static> = query.map_fn_to(); + pub static DELETER_MAP_FN: v8::NamedPropertyGetterCallback<'static> = deleter.map_fn_to(); + pub static ENUMERATOR_MAP_FN: v8::NamedPropertyEnumeratorCallback<'static> = enumerator.map_fn_to(); + pub static DEFINER_MAP_FN: v8::NamedPropertyDefinerCallback<'static> = definer.map_fn_to(); + pub static DESCRIPTOR_MAP_FN: v8::NamedPropertyGetterCallback<'static> = descriptor.map_fn_to(); } /// Convert an ASCII string to a UTF-16 byte encoding of the string. @@ -287,9 +287,9 @@ pub fn getter<'s>( key: v8::Local<'s, v8::Name>, args: v8::PropertyCallbackArguments<'s>, mut rv: v8::ReturnValue, -) { +) -> v8::Intercepted { if !is_managed_key(scope, key) { - return; + return v8::Intercepted::No; }; let this = args.this(); @@ -311,10 +311,11 @@ pub fn getter<'s>( undefined.into(), &[inner.into(), key.into(), this.into()], ) else { - return; + return v8::Intercepted::No; }; rv.set(value); + v8::Intercepted::Yes } pub fn setter<'s>( @@ -323,9 +324,9 @@ pub fn setter<'s>( value: v8::Local<'s, v8::Value>, args: v8::PropertyCallbackArguments<'s>, mut rv: v8::ReturnValue, -) { +) -> v8::Intercepted { if !is_managed_key(scope, key) { - return; + return v8::Intercepted::No; }; let this = args.this(); @@ -348,10 +349,11 @@ pub fn setter<'s>( undefined.into(), &[inner.into(), key.into(), value, this.into()], ) else { - return; + return v8::Intercepted::No; }; rv.set(success); + v8::Intercepted::Yes } pub fn query<'s>( @@ -359,9 +361,9 @@ pub fn query<'s>( key: v8::Local<'s, v8::Name>, _args: v8::PropertyCallbackArguments<'s>, mut rv: v8::ReturnValue, -) { +) -> v8::Intercepted { if !is_managed_key(scope, key) { - return; + return v8::Intercepted::No; }; let mode = current_mode(scope); @@ -373,15 +375,16 @@ pub fn query<'s>( let inner = v8::Local::new(scope, inner); let Some(true) = inner.has_own_property(scope, key) else { - return; + return v8::Intercepted::No; }; let Some(attributes) = inner.get_property_attributes(scope, key.into()) else { - return; + return v8::Intercepted::No; }; rv.set_uint32(attributes.as_u32()); + v8::Intercepted::Yes } pub fn deleter<'s>( @@ -389,9 +392,9 @@ pub fn deleter<'s>( key: v8::Local<'s, v8::Name>, args: v8::PropertyCallbackArguments<'s>, mut rv: v8::ReturnValue, -) { +) -> v8::Intercepted { if !is_managed_key(scope, key) { - return; + return v8::Intercepted::No; }; let mode = current_mode(scope); @@ -404,17 +407,18 @@ pub fn deleter<'s>( let inner = v8::Local::new(scope, inner); let Some(success) = inner.delete(scope, key.into()) else { - return; + return v8::Intercepted::No; }; if args.should_throw_on_error() && !success { let message = v8::String::new(scope, "Cannot delete property").unwrap(); let exception = v8::Exception::type_error(scope, message); scope.throw_exception(exception); - return; + return v8::Intercepted::Yes; } rv.set_bool(success); + v8::Intercepted::Yes } pub fn enumerator<'s>( @@ -450,10 +454,10 @@ pub fn definer<'s>( key: v8::Local<'s, v8::Name>, descriptor: &v8::PropertyDescriptor, args: v8::PropertyCallbackArguments<'s>, - mut rv: v8::ReturnValue, -) { + _rv: v8::ReturnValue, +) -> v8::Intercepted { if !is_managed_key(scope, key) { - return; + return v8::Intercepted::No; }; let mode = current_mode(scope); @@ -466,17 +470,16 @@ pub fn definer<'s>( let inner = v8::Local::new(scope, inner); let Some(success) = inner.define_property(scope, key, descriptor) else { - return; + return v8::Intercepted::No; }; if args.should_throw_on_error() && !success { let message = v8::String::new(scope, "Cannot define property").unwrap(); let exception = v8::Exception::type_error(scope, message); scope.throw_exception(exception); - return; } - rv.set_bool(success); + v8::Intercepted::Yes } pub fn descriptor<'s>( @@ -484,9 +487,9 @@ pub fn descriptor<'s>( key: v8::Local<'s, v8::Name>, _args: v8::PropertyCallbackArguments<'s>, mut rv: v8::ReturnValue, -) { +) -> v8::Intercepted { if !is_managed_key(scope, key) { - return; + return v8::Intercepted::No; }; let mode = current_mode(scope); @@ -502,12 +505,13 @@ pub fn descriptor<'s>( let Some(descriptor) = inner.get_own_property_descriptor(scope, key) else { scope.rethrow().expect("to have caught an exception"); - return; + return v8::Intercepted::Yes; }; if descriptor.is_undefined() { - return; + return v8::Intercepted::No; } rv.set(descriptor); + v8::Intercepted::Yes } diff --git a/ext/node/ops/vm_internal.rs b/ext/node/ops/vm_internal.rs index 9c641954e..bbdcba632 100644 --- a/ext/node/ops/vm_internal.rs +++ b/ext/node/ops/vm_internal.rs @@ -215,12 +215,12 @@ extern "C" fn c_noop(_: *const v8::FunctionCallbackInfo) {} // // See NOTE in ext/node/global.rs#L12 thread_local! { - pub static GETTER_MAP_FN: v8::GenericNamedPropertyGetterCallback<'static> = property_getter.map_fn_to(); - pub static SETTER_MAP_FN: v8::GenericNamedPropertySetterCallback<'static> = property_setter.map_fn_to(); - pub static DELETER_MAP_FN: v8::GenericNamedPropertyGetterCallback<'static> = property_deleter.map_fn_to(); - pub static ENUMERATOR_MAP_FN: v8::GenericNamedPropertyEnumeratorCallback<'static> = property_enumerator.map_fn_to(); - pub static DEFINER_MAP_FN: v8::GenericNamedPropertyDefinerCallback<'static> = property_definer.map_fn_to(); - pub static DESCRIPTOR_MAP_FN: v8::GenericNamedPropertyGetterCallback<'static> = property_descriptor.map_fn_to(); + pub static GETTER_MAP_FN: v8::NamedPropertyGetterCallback<'static> = property_getter.map_fn_to(); + pub static SETTER_MAP_FN: v8::NamedPropertySetterCallback<'static> = property_setter.map_fn_to(); + pub static DELETER_MAP_FN: v8::NamedPropertyGetterCallback<'static> = property_deleter.map_fn_to(); + pub static ENUMERATOR_MAP_FN: v8::NamedPropertyEnumeratorCallback<'static> = property_enumerator.map_fn_to(); + pub static DEFINER_MAP_FN: v8::NamedPropertyDefinerCallback<'static> = property_definer.map_fn_to(); + pub static DESCRIPTOR_MAP_FN: v8::NamedPropertyGetterCallback<'static> = property_descriptor.map_fn_to(); } thread_local! { @@ -286,7 +286,7 @@ fn property_getter<'s>( key: v8::Local<'s, v8::Name>, args: v8::PropertyCallbackArguments<'s>, mut ret: v8::ReturnValue, -) { +) -> v8::Intercepted { let ctx = ContextifyContext::get(scope, args.this()).unwrap(); let sandbox = ctx.sandbox(scope); @@ -308,7 +308,10 @@ fn property_getter<'s>( } ret.set(rv); + return v8::Intercepted::Yes; } + + v8::Intercepted::No } fn property_setter<'s>( @@ -317,7 +320,7 @@ fn property_setter<'s>( value: v8::Local<'s, v8::Value>, args: v8::PropertyCallbackArguments<'s>, mut rv: v8::ReturnValue, -) { +) -> v8::Intercepted { let ctx = ContextifyContext::get(scope, args.this()).unwrap(); let (attributes, is_declared_on_global_proxy) = match ctx @@ -339,7 +342,7 @@ fn property_setter<'s>( read_only |= attributes.is_read_only(); if read_only { - return; + return v8::Intercepted::No; } // true for x = 5 @@ -363,15 +366,15 @@ fn property_setter<'s>( && is_contextual_store && !is_function { - return; + return v8::Intercepted::No; } if !is_declared && key.is_symbol() { - return; + return v8::Intercepted::No; }; if ctx.sandbox(scope).set(scope, key.into(), value).is_none() { - return; + return v8::Intercepted::No; } if is_declared_on_sandbox { @@ -394,10 +397,13 @@ fn property_setter<'s>( .unwrap_or(false) { rv.set(value); + return v8::Intercepted::Yes; } } } } + + v8::Intercepted::No } fn property_deleter<'s>( @@ -405,17 +411,18 @@ fn property_deleter<'s>( key: v8::Local<'s, v8::Name>, args: v8::PropertyCallbackArguments<'s>, mut rv: v8::ReturnValue, -) { +) -> v8::Intercepted { let ctx = ContextifyContext::get(scope, args.this()).unwrap(); let context = ctx.context(scope); let sandbox = ctx.sandbox(scope); let context_scope = &mut v8::ContextScope::new(scope, context); if !sandbox.delete(context_scope, key.into()).unwrap_or(false) { - return; + return v8::Intercepted::No; } rv.set_bool(false); + v8::Intercepted::Yes } fn property_enumerator<'s>( @@ -443,7 +450,7 @@ fn property_definer<'s>( desc: &v8::PropertyDescriptor, args: v8::PropertyCallbackArguments<'s>, _: v8::ReturnValue, -) { +) -> v8::Intercepted { let ctx = ContextifyContext::get(scope, args.this()).unwrap(); let context = ctx.context(scope); @@ -461,7 +468,7 @@ fn property_definer<'s>( // If the property is set on the global as read_only, don't change it on // the global or sandbox. if is_declared && read_only && dont_delete { - return; + return v8::Intercepted::No; } let sandbox = ctx.sandbox(scope); @@ -512,6 +519,8 @@ fn property_definer<'s>( define_prop_on_sandbox(scope, &mut desc_for_sandbox); } } + + v8::Intercepted::Yes } fn property_descriptor<'s>( @@ -519,7 +528,7 @@ fn property_descriptor<'s>( key: v8::Local<'s, v8::Name>, args: v8::PropertyCallbackArguments<'s>, mut rv: v8::ReturnValue, -) { +) -> v8::Intercepted { let ctx = ContextifyContext::get(scope, args.this()).unwrap(); let context = ctx.context(scope); @@ -529,8 +538,11 @@ fn property_descriptor<'s>( if sandbox.has_own_property(scope, key).unwrap_or(false) { if let Some(desc) = sandbox.get_own_property_descriptor(scope, key) { rv.set(desc); + return v8::Intercepted::Yes; } } + + v8::Intercepted::No } fn uint32_to_name<'s>( @@ -547,9 +559,9 @@ fn indexed_property_getter<'s>( index: u32, args: v8::PropertyCallbackArguments<'s>, rv: v8::ReturnValue, -) { +) -> v8::Intercepted { let key = uint32_to_name(scope, index); - property_getter(scope, key, args, rv); + property_getter(scope, key, args, rv) } fn indexed_property_setter<'s>( @@ -558,9 +570,9 @@ fn indexed_property_setter<'s>( value: v8::Local<'s, v8::Value>, args: v8::PropertyCallbackArguments<'s>, rv: v8::ReturnValue, -) { +) -> v8::Intercepted { let key = uint32_to_name(scope, index); - property_setter(scope, key, value, args, rv); + property_setter(scope, key, value, args, rv) } fn indexed_property_deleter<'s>( @@ -568,19 +580,20 @@ fn indexed_property_deleter<'s>( index: u32, args: v8::PropertyCallbackArguments<'s>, mut rv: v8::ReturnValue, -) { +) -> v8::Intercepted { let ctx = ContextifyContext::get(scope, args.this()).unwrap(); let context = ctx.context(scope); let sandbox = ctx.sandbox(scope); let context_scope = &mut v8::ContextScope::new(scope, context); if !sandbox.delete_index(context_scope, index).unwrap_or(false) { - return; + return v8::Intercepted::No; } // Delete failed on the sandbox, intercept and do not delete on // the global object. rv.set_bool(false); + v8::Intercepted::No } fn indexed_property_definer<'s>( @@ -589,9 +602,9 @@ fn indexed_property_definer<'s>( descriptor: &v8::PropertyDescriptor, args: v8::PropertyCallbackArguments<'s>, rv: v8::ReturnValue, -) { +) -> v8::Intercepted { let key = uint32_to_name(scope, index); - property_definer(scope, key, descriptor, args, rv); + property_definer(scope, key, descriptor, args, rv) } fn indexed_property_descriptor<'s>( @@ -599,7 +612,7 @@ fn indexed_property_descriptor<'s>( index: u32, args: v8::PropertyCallbackArguments<'s>, rv: v8::ReturnValue, -) { +) -> v8::Intercepted { let key = uint32_to_name(scope, index); - property_descriptor(scope, key, args, rv); + property_descriptor(scope, key, args, rv) } |