From be68b82eb43f8e6156bad562b292af11776d38b8 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Wed, 27 Oct 2021 23:26:15 +0200 Subject: [PATCH] chore: update to rusty_v8 0.33.0 (#12564) --- Cargo.lock | 30 +++++++++--------- Cargo.toml | 4 +-- cli/compat/mod.rs | 2 +- core/Cargo.toml | 2 +- core/bindings.rs | 3 +- core/error.rs | 1 - core/flags.rs | 1 - core/inspector.rs | 1 - core/lib.rs | 2 +- core/modules.rs | 2 -- core/ops.rs | 1 - core/ops_builtin.rs | 2 +- core/runtime.rs | 28 ++++++++--------- serde_v8/Cargo.toml | 2 +- serde_v8/benches/de.rs | 1 - serde_v8/benches/ser.rs | 2 -- serde_v8/examples/basic.rs | 2 -- serde_v8/src/de.rs | 1 - serde_v8/src/keys.rs | 2 -- serde_v8/src/magic/buffer.rs | 2 +- serde_v8/src/magic/value.rs | 1 - serde_v8/src/magic/zero_copy_buf.rs | 1 - serde_v8/src/payload.rs | 1 - serde_v8/src/ser.rs | 1 - serde_v8/src/serializable.rs | 1 - serde_v8/src/utils.rs | 1 - serde_v8/tests/de.rs | 2 -- serde_v8/tests/magic.rs | 2 -- serde_v8/tests/ser.rs | 2 -- tools/wpt/expectation.json | 48 ++++++----------------------- 30 files changed, 47 insertions(+), 104 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4d352431f7..8eaece96f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -747,12 +747,12 @@ dependencies = [ "log", "parking_lot", "pin-project", - "rusty_v8", "serde", "serde_json", "serde_v8", "tokio", "url", + "v8", ] [[package]] @@ -3114,19 +3114,6 @@ dependencies = [ "security-framework", ] -[[package]] -name = "rusty_v8" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b311db3661f6b7631f94ad431133ff0f299c423e6bcc35b748ad0d57d6e604" -dependencies = [ - "bitflags", - "fslock", - "lazy_static", - "libc", - "which", -] - [[package]] name = "rustyline" version = "9.0.0" @@ -3323,9 +3310,9 @@ name = "serde_v8" version = "0.16.0" dependencies = [ "bencher", - "rusty_v8", "serde", "serde_json", + "v8", ] [[package]] @@ -4537,6 +4524,19 @@ dependencies = [ "serde", ] +[[package]] +name = "v8" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b3adb16fd1af3e28d6fda8348a6d96b5363a128dc5a0216b137b64ecbae6641" +dependencies = [ + "bitflags", + "fslock", + "lazy_static", + "libc", + "which", +] + [[package]] name = "vcpkg" version = "0.2.15" diff --git a/Cargo.toml b/Cargo.toml index 83c25c9e59..0f8b7563c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,7 +70,7 @@ opt-level = 3 opt-level = 3 [profile.bench.package.num-bigint-dig] opt-level = 3 -[profile.bench.package.rusty_v8] +[profile.bench.package.v8] opt-level = 3 [profile.bench.package.serde_v8] opt-level = 3 @@ -104,7 +104,7 @@ opt-level = 3 opt-level = 3 [profile.release.package.num-bigint-dig] opt-level = 3 -[profile.release.package.rusty_v8] +[profile.release.package.v8] opt-level = 3 [profile.release.package.serde_v8] opt-level = 3 diff --git a/cli/compat/mod.rs b/cli/compat/mod.rs index ac0a34c5a4..bcc9473eb4 100644 --- a/cli/compat/mod.rs +++ b/cli/compat/mod.rs @@ -106,7 +106,7 @@ pub async fn check_if_should_use_esm_loader( let use_esm_loader_global = js_runtime.resolve_value(result).await?; let use_esm_loader = { let scope = &mut js_runtime.handle_scope(); - let use_esm_loader_local = use_esm_loader_global.get(scope); + let use_esm_loader_local = use_esm_loader_global.open(scope); use_esm_loader_local.boolean_value(scope) }; diff --git a/core/Cargo.toml b/core/Cargo.toml index 94da16776f..089826ec6d 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -21,11 +21,11 @@ lazy_static = "1.4.0" log = "0.4.14" parking_lot = "0.11.1" pin-project = "1.0.7" -rusty_v8 = "0.32.0" serde = { version = "1.0.129", features = ["derive"] } serde_json = { version = "1.0.66", features = ["preserve_order"] } serde_v8 = { version = "0.16.0", path = "../serde_v8" } url = { version = "2.2.2", features = ["serde"] } +v8 = "0.33.0" [[example]] name = "http_bench_json_ops" diff --git a/core/bindings.rs b/core/bindings.rs index fc86a1136a..2ba8059a0a 100644 --- a/core/bindings.rs +++ b/core/bindings.rs @@ -13,7 +13,6 @@ use crate::OpTable; use crate::PromiseId; use crate::ZeroCopyBuf; use log::debug; -use rusty_v8 as v8; use serde::Deserialize; use serde::Serialize; use serde_v8::to_v8; @@ -633,7 +632,7 @@ fn set_wasm_streaming_callback( let undefined = v8::undefined(scope); let rid = serde_v8::to_v8(scope, streaming_rid).unwrap(); cb_handle - .get(scope) + .open(scope) .call(scope, undefined.into(), &[arg, rid]); }); } diff --git a/core/error.rs b/core/error.rs index 88cb06887f..b94b7f192b 100644 --- a/core/error.rs +++ b/core/error.rs @@ -3,7 +3,6 @@ pub use anyhow::anyhow; pub use anyhow::bail; pub use anyhow::Context; -use rusty_v8 as v8; use std::borrow::Cow; use std::convert::TryFrom; use std::convert::TryInto; diff --git a/core/flags.rs b/core/flags.rs index af64df64e1..78ed081253 100644 --- a/core/flags.rs +++ b/core/flags.rs @@ -1,6 +1,5 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use rusty_v8 as v8; /// Pass the command line arguments to v8. /// Returns a vector of command line arguments that V8 did not understand. pub fn v8_set_flags(args: Vec) -> Vec { diff --git a/core/inspector.rs b/core/inspector.rs index c4dddc5d68..3e84bcd584 100644 --- a/core/inspector.rs +++ b/core/inspector.rs @@ -22,7 +22,6 @@ use crate::futures::task::Poll; use crate::serde_json; use crate::serde_json::json; use crate::serde_json::Value; -use crate::v8; use parking_lot::Mutex; use std::cell::BorrowMutError; use std::cell::RefCell; diff --git a/core/lib.rs b/core/lib.rs index 889f613dfa..eff1397cf4 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -20,7 +20,6 @@ mod runtime; // Re-exports pub use futures; pub use parking_lot; -pub use rusty_v8 as v8; pub use serde; pub use serde_json; pub use serde_v8; @@ -28,6 +27,7 @@ pub use serde_v8::Buffer as ZeroCopyBuf; pub use serde_v8::ByteString; pub use serde_v8::StringOrBuffer; pub use url; +pub use v8; pub use crate::async_cancel::CancelFuture; pub use crate::async_cancel::CancelHandle; diff --git a/core/modules.rs b/core/modules.rs index 31e03196a4..ba7db507e1 100644 --- a/core/modules.rs +++ b/core/modules.rs @@ -1,7 +1,5 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use rusty_v8 as v8; - use crate::bindings; use crate::error::generic_error; use crate::error::AnyError; diff --git a/core/ops.rs b/core/ops.rs index 20b14ec394..ab233ef296 100644 --- a/core/ops.rs +++ b/core/ops.rs @@ -13,7 +13,6 @@ use futures::ready; use futures::task::noop_waker; use futures::Future; use indexmap::IndexMap; -use rusty_v8 as v8; use serde::de::DeserializeOwned; use serde::Serialize; use std::cell::RefCell; diff --git a/core/ops_builtin.rs b/core/ops_builtin.rs index c830f8eff1..d33565caf6 100644 --- a/core/ops_builtin.rs +++ b/core/ops_builtin.rs @@ -98,7 +98,7 @@ pub fn op_print( Ok(()) } -pub struct WasmStreamingResource(pub(crate) RefCell); +pub struct WasmStreamingResource(pub(crate) RefCell); impl Resource for WasmStreamingResource { fn close(self: Rc) { diff --git a/core/runtime.rs b/core/runtime.rs index e453b453fe..327662e7c5 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -1,7 +1,5 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use rusty_v8 as v8; - use crate::bindings; use crate::error::attach_handle_to_error; use crate::error::generic_error; @@ -529,7 +527,7 @@ impl JsRuntime { let scope = &mut self.handle_scope(); let state_rc = JsRuntime::state(scope); let js_sync_cb_handle = state_rc.borrow().js_sync_cb.clone().unwrap(); - let js_sync_cb = js_sync_cb_handle.get(scope); + let js_sync_cb = js_sync_cb_handle.open(scope); let this = v8::undefined(scope).into(); js_sync_cb.call(scope, this, &[]); } @@ -995,7 +993,7 @@ impl JsRuntime { let status = { let scope = &mut self.handle_scope(); - let module = module_handle.get(scope); + let module = module_handle.open(scope); module.get_status() }; @@ -1142,7 +1140,7 @@ impl JsRuntime { .dynamic_import_map .remove(&id) .expect("Invalid dynamic import id"); - let resolver = resolver_handle.get(scope); + let resolver = resolver_handle.open(scope); let exception = err .downcast_ref::() @@ -1171,7 +1169,7 @@ impl JsRuntime { .dynamic_import_map .remove(&id) .expect("Invalid dynamic import id"); - let resolver = resolver_handle.get(scope); + let resolver = resolver_handle.open(scope); let module = { module_map_rc @@ -1328,7 +1326,7 @@ impl JsRuntime { let module_evaluation = maybe_module_evaluation.unwrap(); let scope = &mut self.handle_scope(); - let promise = module_evaluation.promise.get(scope); + let promise = module_evaluation.promise.open(scope); let promise_state = promise.state(); match promise_state { @@ -1364,8 +1362,8 @@ impl JsRuntime { let scope = &mut self.handle_scope(); let module_id = pending_dyn_evaluate.module_id; - let promise = pending_dyn_evaluate.promise.get(scope); - let _module = pending_dyn_evaluate.module.get(scope); + let promise = pending_dyn_evaluate.promise.open(scope); + let _module = pending_dyn_evaluate.module.open(scope); let promise_state = promise.state(); match promise_state { @@ -1545,7 +1543,7 @@ impl JsRuntime { } let tc_scope = &mut v8::TryCatch::new(scope); - let js_recv_cb = js_recv_cb_handle.get(tc_scope); + let js_recv_cb = js_recv_cb_handle.open(tc_scope); let this = v8::undefined(tc_scope).into(); js_recv_cb.call(tc_scope, this, args.as_slice()); @@ -1563,7 +1561,7 @@ impl JsRuntime { }; let scope = &mut self.handle_scope(); - let js_macrotask_cb = js_macrotask_cb_handle.get(scope); + let js_macrotask_cb = js_macrotask_cb_handle.open(scope); // Repeatedly invoke macrotask callback until it returns true (done), // such that ready microtasks would be automatically run before @@ -1729,13 +1727,13 @@ pub mod tests { let value_global = runtime.execute_script("a.js", "a = 1 + 2").unwrap(); { let scope = &mut runtime.handle_scope(); - let value = value_global.get(scope); + let value = value_global.open(scope); assert_eq!(value.integer_value(scope).unwrap(), 3); } let value_global = runtime.execute_script("b.js", "b = 'foobar'").unwrap(); { let scope = &mut runtime.handle_scope(); - let value = value_global.get(scope); + let value = value_global.open(scope); assert!(value.is_string()); assert_eq!( value.to_string(scope).unwrap().to_rust_string_lossy(scope), @@ -1753,7 +1751,7 @@ pub mod tests { let result_global = runtime.resolve_value(value_global).await.unwrap(); { let scope = &mut runtime.handle_scope(); - let value = result_global.get(scope); + let value = result_global.open(scope); assert_eq!(value.integer_value(scope).unwrap(), 3); } @@ -1766,7 +1764,7 @@ pub mod tests { let result_global = runtime.resolve_value(value_global).await.unwrap(); { let scope = &mut runtime.handle_scope(); - let value = result_global.get(scope); + let value = result_global.open(scope); assert_eq!(value.integer_value(scope).unwrap(), 4); } diff --git a/serde_v8/Cargo.toml b/serde_v8/Cargo.toml index 6fcf626765..ac5d26575e 100644 --- a/serde_v8/Cargo.toml +++ b/serde_v8/Cargo.toml @@ -10,8 +10,8 @@ repository = "https://github.com/denoland/deno" description = "Rust to V8 serialization and deserialization" [dependencies] -rusty_v8 = "0.32.0" serde = { version = "1.0.130", features = ["derive"] } +v8 = "0.33.0" [dev-dependencies] bencher = "0.1" diff --git a/serde_v8/benches/de.rs b/serde_v8/benches/de.rs index 6bd4f0f9b0..d800a39a56 100644 --- a/serde_v8/benches/de.rs +++ b/serde_v8/benches/de.rs @@ -1,7 +1,6 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. use bencher::{benchmark_group, benchmark_main, Bencher}; -use rusty_v8 as v8; use std::convert::TryFrom; use serde::Deserialize; diff --git a/serde_v8/benches/ser.rs b/serde_v8/benches/ser.rs index d62e264cd1..1318f9585e 100644 --- a/serde_v8/benches/ser.rs +++ b/serde_v8/benches/ser.rs @@ -1,8 +1,6 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. use bencher::{benchmark_group, benchmark_main, Bencher}; -use rusty_v8 as v8; - use serde::Serialize; use serde_v8::utils::v8_do; diff --git a/serde_v8/examples/basic.rs b/serde_v8/examples/basic.rs index 6c24220d46..8bea43bb50 100644 --- a/serde_v8/examples/basic.rs +++ b/serde_v8/examples/basic.rs @@ -1,6 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use rusty_v8 as v8; - use serde::Deserialize; #[derive(Debug, Deserialize)] diff --git a/serde_v8/src/de.rs b/serde_v8/src/de.rs index b865547ec7..14edfec03e 100644 --- a/serde_v8/src/de.rs +++ b/serde_v8/src/de.rs @@ -1,5 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use rusty_v8 as v8; use serde::de::{self, Visitor}; use serde::Deserialize; diff --git a/serde_v8/src/keys.rs b/serde_v8/src/keys.rs index ea989086c0..783b7aaeff 100644 --- a/serde_v8/src/keys.rs +++ b/serde_v8/src/keys.rs @@ -1,6 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use rusty_v8 as v8; - use std::collections::HashMap; // KeyCache stores a pool struct keys mapped to v8, diff --git a/serde_v8/src/magic/buffer.rs b/serde_v8/src/magic/buffer.rs index ef1f395fe7..7a3a3b8ee5 100644 --- a/serde_v8/src/magic/buffer.rs +++ b/serde_v8/src/magic/buffer.rs @@ -1,4 +1,4 @@ -use rusty_v8 as v8; +// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. use std::fmt; use std::ops::Deref; diff --git a/serde_v8/src/magic/value.rs b/serde_v8/src/magic/value.rs index 2cb6224668..0522300076 100644 --- a/serde_v8/src/magic/value.rs +++ b/serde_v8/src/magic/value.rs @@ -1,5 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use rusty_v8 as v8; use std::fmt; use std::marker::PhantomData; diff --git a/serde_v8/src/magic/zero_copy_buf.rs b/serde_v8/src/magic/zero_copy_buf.rs index 1e911c329d..5c200a8423 100644 --- a/serde_v8/src/magic/zero_copy_buf.rs +++ b/serde_v8/src/magic/zero_copy_buf.rs @@ -1,6 +1,5 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use rusty_v8 as v8; use std::cell::Cell; use std::ops::Deref; use std::ops::DerefMut; diff --git a/serde_v8/src/payload.rs b/serde_v8/src/payload.rs index a9fb045e37..cad9bc8686 100644 --- a/serde_v8/src/payload.rs +++ b/serde_v8/src/payload.rs @@ -1,5 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use rusty_v8 as v8; // TODO: maybe add a Payload type that holds scope & v8::Value // so it can implement Deserialize by itself diff --git a/serde_v8/src/ser.rs b/serde_v8/src/ser.rs index a2a57d62e9..386e46019f 100644 --- a/serde_v8/src/ser.rs +++ b/serde_v8/src/ser.rs @@ -1,5 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use rusty_v8 as v8; use serde::ser; use serde::ser::Serialize; diff --git a/serde_v8/src/serializable.rs b/serde_v8/src/serializable.rs index c9182b636f..6cb6384409 100644 --- a/serde_v8/src/serializable.rs +++ b/serde_v8/src/serializable.rs @@ -1,5 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use rusty_v8 as v8; use std::any::TypeId; use std::mem::transmute_copy; diff --git a/serde_v8/src/utils.rs b/serde_v8/src/utils.rs index 6f638f7b32..f18d2269cb 100644 --- a/serde_v8/src/utils.rs +++ b/serde_v8/src/utils.rs @@ -1,5 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use rusty_v8 as v8; use std::sync::Once; pub fn js_exec<'s>( diff --git a/serde_v8/tests/de.rs b/serde_v8/tests/de.rs index 888bff4f49..366d6d2b5d 100644 --- a/serde_v8/tests/de.rs +++ b/serde_v8/tests/de.rs @@ -1,6 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use rusty_v8 as v8; - use serde::Deserialize; use serde_v8::utils::{js_exec, v8_do}; diff --git a/serde_v8/tests/magic.rs b/serde_v8/tests/magic.rs index 95ad3eb555..15b318bafb 100644 --- a/serde_v8/tests/magic.rs +++ b/serde_v8/tests/magic.rs @@ -1,6 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use rusty_v8 as v8; - use serde::{Deserialize, Serialize}; use serde_v8::utils::{js_exec, v8_do}; diff --git a/serde_v8/tests/ser.rs b/serde_v8/tests/ser.rs index c3ada7a6e4..951c16d555 100644 --- a/serde_v8/tests/ser.rs +++ b/serde_v8/tests/ser.rs @@ -1,6 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use rusty_v8 as v8; - use serde::Serialize; use serde_json::json; use serde_v8::utils::{js_exec, v8_do}; diff --git a/tools/wpt/expectation.json b/tools/wpt/expectation.json index 6bcaf576ff..c80aeea255 100644 --- a/tools/wpt/expectation.json +++ b/tools/wpt/expectation.json @@ -6709,33 +6709,15 @@ "toString.any.html": true, "toString.any.worker.html": true }, - "prototypes.any.html": false, - "prototypes.any.worker.html": false, + "prototypes.any.html": true, + "prototypes.any.worker.html": true, "table": { - "constructor.any.html": [ - "initialize externref table with default value" - ], - "constructor.any.worker.html": [ - "initialize externref table with default value" - ], - "get-set.any.html": [ - "Arguments for anyfunc table set", - "Arguments for externref table set" - ], - "get-set.any.worker.html": [ - "Arguments for anyfunc table set", - "Arguments for externref table set" - ], - "grow.any.html": [ - "Grow with exported-function argument", - "Grow with non-function argument", - "Grow with JS-function argument" - ], - "grow.any.worker.html": [ - "Grow with exported-function argument", - "Grow with non-function argument", - "Grow with JS-function argument" - ], + "constructor.any.html": true, + "constructor.any.worker.html": true, + "get-set.any.html": true, + "get-set.any.worker.html": true, + "grow.any.html": true, + "grow.any.worker.html": true, "length.any.html": true, "length.any.worker.html": true, "toString.any.html": true, @@ -6746,18 +6728,8 @@ "type.tentative.any.worker.html": false }, "exception": { - "basic.tentative.any.html": [ - "Wasm function throws argument", - "Wasm function throws null", - "Imported JS function throws", - "Imported JS function throws, Wasm catches and rethrows" - ], - "basic.tentative.any.worker.html": [ - "Wasm function throws argument", - "Wasm function throws null", - "Imported JS function throws", - "Imported JS function throws, Wasm catches and rethrows" - ], + "basic.tentative.any.html": true, + "basic.tentative.any.worker.html": true, "constructor.tentative.any.html": true, "constructor.tentative.any.worker.html": true, "getArg.tentative.any.html": true,