summaryrefslogtreecommitdiff
path: root/ext/node/ops
diff options
context:
space:
mode:
authorsnek <snek@deno.com>2024-07-01 15:48:52 -0700
committerGitHub <noreply@github.com>2024-07-01 15:48:52 -0700
commita555cb4d1d3c04a4bdc0e04d20d23b157cef3b92 (patch)
tree9ebedb3c3cc499026f84053e6774a10ae19b2f75 /ext/node/ops
parent740c6a0998fb5873d0b9bf804b2f9c9730743e90 (diff)
feat: upgrade deno_core (#24364)
- Symbol.asyncDispose no longer needs to be polyfilled - assorted updates for cppgc api changes
Diffstat (limited to 'ext/node/ops')
-rw-r--r--ext/node/ops/blocklist.rs2
-rw-r--r--ext/node/ops/crypto/digest.rs4
-rw-r--r--ext/node/ops/crypto/x509.rs2
-rw-r--r--ext/node/ops/vm.rs2
-rw-r--r--ext/node/ops/vm_internal.rs34
-rw-r--r--ext/node/ops/zlib/mod.rs4
6 files changed, 28 insertions, 20 deletions
diff --git a/ext/node/ops/blocklist.rs b/ext/node/ops/blocklist.rs
index b853a5723..182f15df3 100644
--- a/ext/node/ops/blocklist.rs
+++ b/ext/node/ops/blocklist.rs
@@ -22,7 +22,7 @@ pub struct BlockListResource {
blocklist: RefCell<BlockList>,
}
-impl deno_core::GcResource for BlockListResource {}
+impl deno_core::GarbageCollected for BlockListResource {}
#[derive(Serialize)]
struct SocketAddressSerialization(String, String);
diff --git a/ext/node/ops/crypto/digest.rs b/ext/node/ops/crypto/digest.rs
index 588ea7425..e3a91e338 100644
--- a/ext/node/ops/crypto/digest.rs
+++ b/ext/node/ops/crypto/digest.rs
@@ -1,7 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use deno_core::error::generic_error;
use deno_core::error::AnyError;
-use deno_core::GcResource;
+use deno_core::GarbageCollected;
use digest::Digest;
use digest::DynDigest;
use digest::ExtendableOutput;
@@ -13,7 +13,7 @@ pub struct Hasher {
pub hash: Rc<RefCell<Option<Hash>>>,
}
-impl GcResource for Hasher {}
+impl GarbageCollected for Hasher {}
impl Hasher {
pub fn new(
diff --git a/ext/node/ops/crypto/x509.rs b/ext/node/ops/crypto/x509.rs
index 517a3a943..c9a23aca0 100644
--- a/ext/node/ops/crypto/x509.rs
+++ b/ext/node/ops/crypto/x509.rs
@@ -19,7 +19,7 @@ pub(crate) struct Certificate {
cert: X509Certificate<'static>,
}
-impl deno_core::GcResource for Certificate {}
+impl deno_core::GarbageCollected for Certificate {}
impl Certificate {
fn fingerprint<D: Digest>(&self) -> Option<String> {
diff --git a/ext/node/ops/vm.rs b/ext/node/ops/vm.rs
index 2614c4f73..df631a51f 100644
--- a/ext/node/ops/vm.rs
+++ b/ext/node/ops/vm.rs
@@ -29,7 +29,7 @@ pub struct Script {
inner: i::ContextifyScript,
}
-impl deno_core::GcResource for Script {}
+impl deno_core::GarbageCollected for Script {}
impl Script {
fn new(
diff --git a/ext/node/ops/vm_internal.rs b/ext/node/ops/vm_internal.rs
index 0ac714c9f..afcdc1b9c 100644
--- a/ext/node/ops/vm_internal.rs
+++ b/ext/node/ops/vm_internal.rs
@@ -58,13 +58,17 @@ impl ContextifyScript {
}
}
-#[derive(Debug, Clone)]
pub struct ContextifyContext {
- context: v8::Global<v8::Context>,
- sandbox: v8::Global<v8::Object>,
+ context: v8::TracedReference<v8::Context>,
+ sandbox: v8::TracedReference<v8::Object>,
}
-impl deno_core::GcResource for ContextifyContext {}
+impl deno_core::GarbageCollected for ContextifyContext {
+ fn trace(&self, visitor: &v8::cppgc::Visitor) {
+ visitor.trace(&self.context);
+ visitor.trace(&self.sandbox);
+ }
+}
impl ContextifyContext {
pub fn attach(
@@ -102,12 +106,12 @@ impl ContextifyContext {
);
}
- let context = v8::Global::new(scope, v8_context);
- let sandbox = v8::Global::new(scope, sandbox_obj);
+ let context = v8::TracedReference::new(scope, v8_context);
+ let sandbox = v8::TracedReference::new(scope, sandbox_obj);
let wrapper =
deno_core::cppgc::make_cppgc_object(scope, Self { context, sandbox });
- let ptr = deno_core::cppgc::try_unwrap_cppgc_object::<Self>(wrapper.into())
- .unwrap();
+ let ptr =
+ deno_core::cppgc::try_unwrap_cppgc_object::<Self>(scope, wrapper.into());
// SAFETY: We are storing a pointer to the ContextifyContext
// in the embedder data of the v8::Context. The contextified wrapper
@@ -115,7 +119,7 @@ impl ContextifyContext {
unsafe {
v8_context.set_aligned_pointer_in_embedder_data(
3,
- ptr as *const ContextifyContext as _,
+ ptr.borrow().unwrap() as *const ContextifyContext as _,
);
}
@@ -137,8 +141,12 @@ impl ContextifyContext {
sandbox_obj
.get_private(scope, private_symbol)
.and_then(|wrapper| {
- deno_core::cppgc::try_unwrap_cppgc_object::<Self>(wrapper)
- .map(|s| s as _)
+ deno_core::cppgc::try_unwrap_cppgc_object::<Self>(scope, wrapper)
+ .borrow()
+ // SAFETY: the lifetime of the scope does not actually bind to
+ // the lifetime of this reference at all, but the object we read
+ // it from does, so it will be alive at least that long.
+ .map(|r| unsafe { &*(r as *const _) })
})
}
@@ -153,7 +161,7 @@ impl ContextifyContext {
&self,
scope: &mut v8::HandleScope<'a>,
) -> v8::Local<'a, v8::Context> {
- v8::Local::new(scope, &self.context)
+ self.context.get(scope).unwrap()
}
fn global_proxy<'s>(
@@ -168,7 +176,7 @@ impl ContextifyContext {
&self,
scope: &mut v8::HandleScope<'a>,
) -> v8::Local<'a, v8::Object> {
- v8::Local::new(scope, &self.sandbox)
+ self.sandbox.get(scope).unwrap()
}
fn get<'a, 'c>(
diff --git a/ext/node/ops/zlib/mod.rs b/ext/node/ops/zlib/mod.rs
index 9e030176a..b1d6d21d2 100644
--- a/ext/node/ops/zlib/mod.rs
+++ b/ext/node/ops/zlib/mod.rs
@@ -144,7 +144,7 @@ impl ZlibInner {
self.err = self.strm.inflate(self.flush);
// TODO(@littledivy): Use if let chain when it is stable.
// https://github.com/rust-lang/rust/issues/53667
- //
+ //
// Data was encoded with dictionary
if let (Z_NEED_DICT, Some(dictionary)) = (self.err, &self.dictionary) {
self.err = self.strm.inflate_set_dictionary(dictionary);
@@ -233,7 +233,7 @@ struct Zlib {
inner: RefCell<Option<ZlibInner>>,
}
-impl deno_core::GcResource for Zlib {}
+impl deno_core::GarbageCollected for Zlib {}
impl deno_core::Resource for Zlib {
fn name(&self) -> Cow<str> {