Skip to content

Commit

Permalink
fix: upgrade deno_core (denoland#24128)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju committed Jun 7, 2024
1 parent 3735a1a commit 9dc0e33
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 72 deletions.
31 changes: 18 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
66 changes: 35 additions & 31 deletions ext/node/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand All @@ -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>(
Expand All @@ -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();
Expand All @@ -348,20 +349,21 @@ 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>(
scope: &mut v8::HandleScope<'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);

Expand All @@ -373,25 +375,26 @@ 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>(
scope: &mut v8::HandleScope<'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);
Expand All @@ -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>(
Expand Down Expand Up @@ -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);
Expand All @@ -466,27 +470,26 @@ 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>(
scope: &mut v8::HandleScope<'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);
Expand All @@ -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
}
Loading

0 comments on commit 9dc0e33

Please sign in to comment.