1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

feat: upgrade deno_core (#24364)

- Symbol.asyncDispose no longer needs to be polyfilled
- assorted updates for cppgc api changes
This commit is contained in:
snek 2024-07-01 15:48:52 -07:00 committed by GitHub
parent 740c6a0998
commit a555cb4d1d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 108 additions and 47 deletions

85
Cargo.lock generated
View file

@ -438,6 +438,29 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "bindgen"
version = "0.69.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0"
dependencies = [
"bitflags 2.5.0",
"cexpr",
"clang-sys",
"itertools",
"lazy_static",
"lazycell",
"log",
"prettyplease 0.2.17",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex",
"syn 2.0.58",
"which 4.4.2",
]
[[package]] [[package]]
name = "bit-set" name = "bit-set"
version = "0.5.3" version = "0.5.3"
@ -596,6 +619,15 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "cexpr"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
dependencies = [
"nom 7.1.3",
]
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "1.0.0" version = "1.0.0"
@ -628,6 +660,17 @@ dependencies = [
"inout", "inout",
] ]
[[package]]
name = "clang-sys"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
dependencies = [
"glob",
"libc",
"libloading 0.8.3",
]
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.4.17" version = "4.4.17"
@ -1292,9 +1335,9 @@ dependencies = [
[[package]] [[package]]
name = "deno_core" name = "deno_core"
version = "0.291.0" version = "0.292.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec3d6bd1d8fc2858208a55aa492d43d92de7d42b9f434f0a7ed251befaf27a3c" checksum = "248b86ab980532603f44c14e1c079881133fc54be4c5c716d5333c67952293d2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -1755,9 +1798,9 @@ dependencies = [
[[package]] [[package]]
name = "deno_ops" name = "deno_ops"
version = "0.167.0" version = "0.168.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b573e543149e9a37cdf9cf37b88d778215a8eff7da8211b94f84d3d155cfe3f5" checksum = "81638e46cda0051461c034e6aeef73d7184264fffface2372586a6ce410a0e89"
dependencies = [ dependencies = [
"proc-macro-rules", "proc-macro-rules",
"proc-macro2", "proc-macro2",
@ -3761,6 +3804,12 @@ dependencies = [
"spin 0.5.2", "spin 0.5.2",
] ]
[[package]]
name = "lazycell"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]] [[package]]
name = "lexical-core" name = "lexical-core"
version = "0.8.5" version = "0.8.5"
@ -4892,6 +4941,16 @@ dependencies = [
"syn 1.0.109", "syn 1.0.109",
] ]
[[package]]
name = "prettyplease"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7"
dependencies = [
"proc-macro2",
"syn 2.0.58",
]
[[package]] [[package]]
name = "primeorder" name = "primeorder"
version = "0.13.6" version = "0.13.6"
@ -4986,7 +5045,7 @@ dependencies = [
"log", "log",
"multimap", "multimap",
"petgraph", "petgraph",
"prettyplease", "prettyplease 0.1.25",
"prost", "prost",
"prost-types", "prost-types",
"regex", "regex",
@ -5771,9 +5830,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_v8" name = "serde_v8"
version = "0.200.0" version = "0.201.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "579057484ec81c031826ca53bc5b4ab5d1273fcd5cc4c8057c0f0cd1e57dfa65" checksum = "4f7436cf7c06303e6570fea42ec827e47111a77edbf6b40fcfc05424da4d01c0"
dependencies = [ dependencies = [
"num-bigint", "num-bigint",
"serde", "serde",
@ -5846,6 +5905,12 @@ dependencies = [
"dirs", "dirs",
] ]
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]] [[package]]
name = "signal-hook" name = "signal-hook"
version = "0.3.17" version = "0.3.17"
@ -7365,16 +7430,18 @@ dependencies = [
[[package]] [[package]]
name = "v8" name = "v8"
version = "0.93.1" version = "0.95.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82943fec029559cb43f9d7fc36e2bb85121534702d6f893554e737d1b147d140" checksum = "c4395d3c43b81368d91335ffc78d71cb6e3288d311ab6a55094634cb2afdc5c5"
dependencies = [ dependencies = [
"bindgen",
"bitflags 2.5.0", "bitflags 2.5.0",
"fslock", "fslock",
"gzip-header", "gzip-header",
"home", "home",
"miniz_oxide", "miniz_oxide",
"once_cell", "once_cell",
"paste",
"which 6.0.1", "which 6.0.1",
] ]

View file

@ -44,7 +44,7 @@ repository = "https://github.com/denoland/deno"
[workspace.dependencies] [workspace.dependencies]
deno_ast = { version = "=0.39.2", features = ["transpiling"] } 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_bench_util = { version = "0.152.0", path = "./bench_util" }
deno_lockfile = "0.20.0" deno_lockfile = "0.20.0"

View file

@ -22,7 +22,7 @@ pub struct BlockListResource {
blocklist: RefCell<BlockList>, blocklist: RefCell<BlockList>,
} }
impl deno_core::GcResource for BlockListResource {} impl deno_core::GarbageCollected for BlockListResource {}
#[derive(Serialize)] #[derive(Serialize)]
struct SocketAddressSerialization(String, String); struct SocketAddressSerialization(String, String);

View file

@ -1,7 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use deno_core::error::generic_error; use deno_core::error::generic_error;
use deno_core::error::AnyError; use deno_core::error::AnyError;
use deno_core::GcResource; use deno_core::GarbageCollected;
use digest::Digest; use digest::Digest;
use digest::DynDigest; use digest::DynDigest;
use digest::ExtendableOutput; use digest::ExtendableOutput;
@ -13,7 +13,7 @@ pub struct Hasher {
pub hash: Rc<RefCell<Option<Hash>>>, pub hash: Rc<RefCell<Option<Hash>>>,
} }
impl GcResource for Hasher {} impl GarbageCollected for Hasher {}
impl Hasher { impl Hasher {
pub fn new( pub fn new(

View file

@ -19,7 +19,7 @@ pub(crate) struct Certificate {
cert: X509Certificate<'static>, cert: X509Certificate<'static>,
} }
impl deno_core::GcResource for Certificate {} impl deno_core::GarbageCollected for Certificate {}
impl Certificate { impl Certificate {
fn fingerprint<D: Digest>(&self) -> Option<String> { fn fingerprint<D: Digest>(&self) -> Option<String> {

View file

@ -29,7 +29,7 @@ pub struct Script {
inner: i::ContextifyScript, inner: i::ContextifyScript,
} }
impl deno_core::GcResource for Script {} impl deno_core::GarbageCollected for Script {}
impl Script { impl Script {
fn new( fn new(

View file

@ -58,13 +58,17 @@ impl ContextifyScript {
} }
} }
#[derive(Debug, Clone)]
pub struct ContextifyContext { pub struct ContextifyContext {
context: v8::Global<v8::Context>, context: v8::TracedReference<v8::Context>,
sandbox: v8::Global<v8::Object>, 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 { impl ContextifyContext {
pub fn attach( pub fn attach(
@ -102,12 +106,12 @@ impl ContextifyContext {
); );
} }
let context = v8::Global::new(scope, v8_context); let context = v8::TracedReference::new(scope, v8_context);
let sandbox = v8::Global::new(scope, sandbox_obj); let sandbox = v8::TracedReference::new(scope, sandbox_obj);
let wrapper = let wrapper =
deno_core::cppgc::make_cppgc_object(scope, Self { context, sandbox }); deno_core::cppgc::make_cppgc_object(scope, Self { context, sandbox });
let ptr = deno_core::cppgc::try_unwrap_cppgc_object::<Self>(wrapper.into()) let ptr =
.unwrap(); deno_core::cppgc::try_unwrap_cppgc_object::<Self>(scope, wrapper.into());
// SAFETY: We are storing a pointer to the ContextifyContext // SAFETY: We are storing a pointer to the ContextifyContext
// in the embedder data of the v8::Context. The contextified wrapper // in the embedder data of the v8::Context. The contextified wrapper
@ -115,7 +119,7 @@ impl ContextifyContext {
unsafe { unsafe {
v8_context.set_aligned_pointer_in_embedder_data( v8_context.set_aligned_pointer_in_embedder_data(
3, 3,
ptr as *const ContextifyContext as _, ptr.borrow().unwrap() as *const ContextifyContext as _,
); );
} }
@ -137,8 +141,12 @@ impl ContextifyContext {
sandbox_obj sandbox_obj
.get_private(scope, private_symbol) .get_private(scope, private_symbol)
.and_then(|wrapper| { .and_then(|wrapper| {
deno_core::cppgc::try_unwrap_cppgc_object::<Self>(wrapper) deno_core::cppgc::try_unwrap_cppgc_object::<Self>(scope, wrapper)
.map(|s| s as _) .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, &self,
scope: &mut v8::HandleScope<'a>, scope: &mut v8::HandleScope<'a>,
) -> v8::Local<'a, v8::Context> { ) -> v8::Local<'a, v8::Context> {
v8::Local::new(scope, &self.context) self.context.get(scope).unwrap()
} }
fn global_proxy<'s>( fn global_proxy<'s>(
@ -168,7 +176,7 @@ impl ContextifyContext {
&self, &self,
scope: &mut v8::HandleScope<'a>, scope: &mut v8::HandleScope<'a>,
) -> v8::Local<'a, v8::Object> { ) -> v8::Local<'a, v8::Object> {
v8::Local::new(scope, &self.sandbox) self.sandbox.get(scope).unwrap()
} }
fn get<'a, 'c>( fn get<'a, 'c>(

View file

@ -144,7 +144,7 @@ impl ZlibInner {
self.err = self.strm.inflate(self.flush); self.err = self.strm.inflate(self.flush);
// TODO(@littledivy): Use if let chain when it is stable. // TODO(@littledivy): Use if let chain when it is stable.
// https://github.com/rust-lang/rust/issues/53667 // https://github.com/rust-lang/rust/issues/53667
// //
// Data was encoded with dictionary // Data was encoded with dictionary
if let (Z_NEED_DICT, Some(dictionary)) = (self.err, &self.dictionary) { if let (Z_NEED_DICT, Some(dictionary)) = (self.err, &self.dictionary) {
self.err = self.strm.inflate_set_dictionary(dictionary); self.err = self.strm.inflate_set_dictionary(dictionary);
@ -233,7 +233,7 @@ struct Zlib {
inner: RefCell<Option<ZlibInner>>, inner: RefCell<Option<ZlibInner>>,
} }
impl deno_core::GcResource for Zlib {} impl deno_core::GarbageCollected for Zlib {}
impl deno_core::Resource for Zlib { impl deno_core::Resource for Zlib {
fn name(&self) -> Cow<str> { fn name(&self) -> Cow<str> {

View file

@ -50,7 +50,7 @@ pub enum TlsKeys {
pub struct TlsKeysHolder(RefCell<TlsKeys>); pub struct TlsKeysHolder(RefCell<TlsKeys>);
impl deno_core::GcResource for TlsKeysHolder {} impl deno_core::GarbageCollected for TlsKeysHolder {}
impl TlsKeysHolder { impl TlsKeysHolder {
pub fn take(&self) -> TlsKeys { pub fn take(&self) -> TlsKeys {
@ -224,7 +224,7 @@ pub struct TlsKeyLookup {
RefCell<HashMap<String, broadcast::Sender<Result<TlsKey, ErrorType>>>>, RefCell<HashMap<String, broadcast::Sender<Result<TlsKey, ErrorType>>>>,
} }
impl deno_core::GcResource for TlsKeyLookup {} impl deno_core::GarbageCollected for TlsKeyLookup {}
impl TlsKeyLookup { impl TlsKeyLookup {
/// Multiple `poll` calls are safe, but this method is not starvation-safe. Generally /// Multiple `poll` calls are safe, but this method is not starvation-safe. Generally

View file

@ -92,15 +92,7 @@ import {
import { import {
workerRuntimeGlobalProperties, workerRuntimeGlobalProperties,
} from "ext:runtime/98_global_scope_worker.js"; } from "ext:runtime/98_global_scope_worker.js";
import { import { SymbolDispose, SymbolMetadata } from "ext:deno_web/00_infra.js";
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!";
}
// deno-lint-ignore prefer-primordials // deno-lint-ignore prefer-primordials
if (Symbol.metadata) { if (Symbol.metadata) {
throw "V8 supports Symbol.metadata now, no need to shim it!"; throw "V8 supports Symbol.metadata now, no need to shim it!";
@ -112,12 +104,6 @@ ObjectDefineProperties(Symbol, {
writable: false, writable: false,
configurable: false, configurable: false,
}, },
asyncDispose: {
value: SymbolAsyncDispose,
enumerable: false,
writable: false,
configurable: false,
},
metadata: { metadata: {
value: SymbolMetadata, value: SymbolMetadata,
enumerable: false, enumerable: false,