Skip to content
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: upgrade deno_core #24364

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 76 additions & 9 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.2", features = ["transpiling"] }
deno_core = { version = "0.291.0" }
deno_core = { version = "0.292.0" }

deno_bench_util = { version = "0.152.0", path = "./bench_util" }
deno_lockfile = "0.20.0"
Expand Down
2 changes: 1 addition & 1 deletion ext/node/ops/blocklist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions ext/node/ops/crypto/digest.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion ext/node/ops/crypto/x509.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
2 changes: 1 addition & 1 deletion ext/node/ops/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
34 changes: 21 additions & 13 deletions ext/node/ops/vm_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Comment on lines 66 to 70
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

impl ContextifyContext {
pub fn attach(
Expand Down Expand Up @@ -102,20 106,20 @@ 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
// lives longer than the execution context, so this should be safe.
unsafe {
v8_context.set_aligned_pointer_in_embedder_data(
3,
ptr as *const ContextifyContext as _,
ptr.borrow().unwrap() as *const ContextifyContext as _,
);
}

Expand All @@ -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 _) })
})
}

Expand All @@ -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>(
Expand All @@ -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>(
Expand Down
4 changes: 2 additions & 2 deletions ext/node/ops/zlib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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> {
Expand Down
4 changes: 2 additions & 2 deletions ext/tls/tls_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 50,7 @@ pub enum TlsKeys {

pub struct TlsKeysHolder(RefCell<TlsKeys>);

impl deno_core::GcResource for TlsKeysHolder {}
impl deno_core::GarbageCollected for TlsKeysHolder {}

impl TlsKeysHolder {
pub fn take(&self) -> TlsKeys {
Expand Down Expand Up @@ -224,7 224,7 @@ pub struct TlsKeyLookup {
RefCell<HashMap<String, broadcast::Sender<Result<TlsKey, ErrorType>>>>,
}

impl deno_core::GcResource for TlsKeyLookup {}
impl deno_core::GarbageCollected for TlsKeyLookup {}

impl TlsKeyLookup {
/// Multiple `poll` calls are safe, but this method is not starvation-safe. Generally
Expand Down
16 changes: 1 addition & 15 deletions runtime/js/99_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 92,7 @@ import {
import {
workerRuntimeGlobalProperties,
} from "ext:runtime/98_global_scope_worker.js";
import {
SymbolAsyncDispose,
SymbolDispose,
SymbolMetadata,
} from "ext:deno_web/00_infra.js";
// deno-lint-ignore prefer-primordials
if (Symbol.asyncDispose) {
throw "V8 supports Symbol.asyncDispose now, no need to shim it!";
}
import { SymbolDispose, SymbolMetadata } from "ext:deno_web/00_infra.js";
// deno-lint-ignore prefer-primordials
if (Symbol.metadata) {
throw "V8 supports Symbol.metadata now, no need to shim it!";
Expand All @@ -112,12 104,6 @@ ObjectDefineProperties(Symbol, {
writable: false,
configurable: false,
},
asyncDispose: {
value: SymbolAsyncDispose,
enumerable: false,
writable: false,
configurable: false,
},
metadata: {
value: SymbolMetadata,
enumerable: false,
Expand Down