diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25d186b6a9..91ec047955 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,6 +97,9 @@ jobs: - name: Install rust uses: dsherret/rust-toolchain-file@v1 + - name: Install binstall + uses: cargo-bins/cargo-binstall@main + - name: Install python uses: actions/setup-python@v5 with: @@ -125,6 +128,9 @@ jobs: echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc-10" >> ${GITHUB_ENV} echo "QEMU_LD_PREFIX=/usr/aarch64-linux-gnu" >> ${GITHUB_ENV} + - name: Install nextest + run: cargo binstall cargo-nextest --secure --no-confirm + - name: Write git_submodule_status.txt run: git submodule status --recursive > git_submodule_status.txt @@ -199,8 +205,7 @@ jobs: SCCACHE_IDLE_TIMEOUT: 0 if: matrix.config.variant == 'debug' || matrix.config.variant == 'release' run: - ${{ matrix.config.cargo }} test -vv --all-targets --locked ${{ env.CARGO_VARIANT_FLAG }} - --target ${{ matrix.config.target }} + ${{ matrix.config.cargo }} nextest run -v --cargo-verbose --cargo-verbose --all-targets --locked ${{ env.CARGO_VARIANT_FLAG }} --target ${{ matrix.config.target }} - name: Clippy run: diff --git a/build.rs b/build.rs index 4aead47749..510fff010a 100644 --- a/build.rs +++ b/build.rs @@ -16,7 +16,6 @@ use std::io::Write; use std::path::Path; use std::path::PathBuf; use std::process::Command; -use std::process::Stdio; use which::which; fn main() { @@ -888,6 +887,7 @@ fn ninja(gn_out_dir: &Path, maybe_env: Option) -> Command { let mut cmd = Command::new(&cmd_string); cmd.arg("-C"); cmd.arg(gn_out_dir); + cmd.stdout(io::stderr()); if !cmd_string.ends_with("autoninja") { if let Ok(jobs) = env::var("NUM_JOBS") { cmd.arg("-j"); @@ -929,8 +929,8 @@ pub fn maybe_gen(gn_args: GnArgs) -> PathBuf { .arg(&gn_out_dir) .arg("--ide=json") .arg("--args=".to_owned() + &args) - .stdout(Stdio::inherit()) - .stderr(Stdio::inherit()) + .stdout(io::stderr()) + .stderr(io::stderr()) .envs(env::vars()) .status() .expect("Could not run `gn`") diff --git a/buildtools b/buildtools index a7a84ac61e..5c57673513 160000 --- a/buildtools +++ b/buildtools @@ -1 +1 @@ -Subproject commit a7a84ac61eae5a8946807265a2fd8bd812daf384 +Subproject commit 5c576735131cd501c8e45073a3e1aee068eedbae diff --git a/src/isolate.rs b/src/isolate.rs index a2de0ba959..8f29578cd9 100644 --- a/src/isolate.rs +++ b/src/isolate.rs @@ -193,7 +193,7 @@ pub type HostInitializeImportMetaObjectCallback = /// /// The specifier is the name of the module that should be imported. /// -/// The import_assertions are import assertions for this request in the form: +/// The import_attributes are import assertions for this request in the form: /// [key1, value1, key2, value2, ...] where the keys and values are of type /// v8::String. Note, unlike the FixedArray passed to ResolveModuleCallback and /// returned from ModuleRequest::GetImportAssertions(), this array does not @@ -217,7 +217,7 @@ pub type HostInitializeImportMetaObjectCallback = /// host_defined_options: v8::Local<'s, v8::Data>, /// resource_name: v8::Local<'s, v8::Value>, /// specifier: v8::Local<'s, v8::String>, -/// import_assertions: v8::Local<'s, v8::FixedArray>, +/// import_attributes: v8::Local<'s, v8::FixedArray>, /// ) -> Option> { /// todo!() /// } @@ -275,7 +275,7 @@ where host_defined_options: Local<'s, Data>, resource_name: Local<'s, Value>, specifier: Local<'s, String>, - import_assertions: Local<'s, FixedArray>, + import_attributes: Local<'s, FixedArray>, ) -> Option> { let scope = &mut unsafe { CallbackScope::new(context) }; (F::get())( @@ -283,7 +283,7 @@ where host_defined_options, resource_name, specifier, - import_assertions, + import_attributes, ) } @@ -294,14 +294,14 @@ where host_defined_options: Local<'s, Data>, resource_name: Local<'s, Value>, specifier: Local<'s, String>, - import_assertions: Local<'s, FixedArray>, + import_attributes: Local<'s, FixedArray>, ) -> *mut Promise { scope_adapter::( context, host_defined_options, resource_name, specifier, - import_assertions, + import_attributes, ) .map(|return_value| return_value.as_non_null().as_ptr()) .unwrap_or_else(null_mut) @@ -315,7 +315,7 @@ where host_defined_options: Local<'s, Data>, resource_name: Local<'s, Value>, specifier: Local<'s, String>, - import_assertions: Local<'s, FixedArray>, + import_attributes: Local<'s, FixedArray>, ) -> *mut *mut Promise { unsafe { std::ptr::write( @@ -325,7 +325,7 @@ where host_defined_options, resource_name, specifier, - import_assertions, + import_attributes, ) .map(|return_value| return_value.as_non_null().as_ptr()) .unwrap_or_else(null_mut), diff --git a/src/lib.rs b/src/lib.rs index c4f1ccb23d..e0a3df4bb9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -187,3 +187,14 @@ pub const VERSION_STRING: &str = // TODO(piscisaureus): Ideally this trait would not be exported. pub use support::MapFnTo; + +#[cfg(test)] +pub(crate) fn initialize_v8() { + use std::sync::Once; + + static INIT: Once = Once::new(); + INIT.call_once(|| { + V8::initialize_platform(new_default_platform(0, false).make_shared()); + V8::initialize(); + }); +} diff --git a/src/module.rs b/src/module.rs index f9424d588a..354d0ab291 100644 --- a/src/module.rs +++ b/src/module.rs @@ -21,7 +21,7 @@ use crate::UnboundModuleScript; use crate::Value; /// Called during Module::instantiate_module. Provided with arguments: -/// (context, specifier, import_assertions, referrer). Return None on error. +/// (context, specifier, import_attributes, referrer). Return None on error. /// /// Note: this callback has an unusual signature due to ABI incompatibilities /// between Rust and C++. However end users can implement the callback as @@ -31,7 +31,7 @@ use crate::Value; /// fn my_resolve_callback<'a>( /// context: v8::Local<'a, v8::Context>, /// specifier: v8::Local<'a, v8::String>, -/// import_assertions: v8::Local<'a, v8::FixedArray>, +/// import_attributes: v8::Local<'a, v8::FixedArray>, /// referrer: v8::Local<'a, v8::Module>, /// ) -> Option> { /// // ... @@ -74,9 +74,9 @@ where { #[cfg(not(target_os = "windows"))] fn mapping() -> Self { - let f = |context, specifier, import_assertions, referrer| { + let f = |context, specifier, import_attributes, referrer| { ResolveModuleCallbackRet( - (F::get())(context, specifier, import_assertions, referrer) + (F::get())(context, specifier, import_attributes, referrer) .map(|r| -> *const Module { &*r }) .unwrap_or(null()), ) @@ -86,8 +86,8 @@ where #[cfg(target_os = "windows")] fn mapping() -> Self { - let f = |ret_ptr, context, specifier, import_assertions, referrer| { - let r = (F::get())(context, specifier, import_assertions, referrer) + let f = |ret_ptr, context, specifier, import_attributes, referrer| { + let r = (F::get())(context, specifier, import_attributes, referrer) .map(|r| -> *const Module { &*r }) .unwrap_or(null()); unsafe { std::ptr::write(ret_ptr, r) }; // Write result to stack. @@ -313,8 +313,6 @@ impl Module { /// Returns an empty Maybe if an exception occurred during /// instantiation. (In the case where the callback throws an exception, that /// exception is propagated.) - /// - /// NOTE: requires to set `--harmony-import-assertions` V8 flag. #[must_use] #[inline(always)] pub fn instantiate_module<'a>( @@ -507,10 +505,4 @@ impl ModuleRequest { unsafe { Local::from_raw(v8__ModuleRequest__GetImportAttributes(self)) } .unwrap() } - - #[inline(always)] - #[deprecated(note = "Use get_import_attributes instead")] - pub fn get_import_assertions(&self) -> Local { - self.get_import_attributes() - } } diff --git a/src/scope.rs b/src/scope.rs index 9561336f31..899e19fbe9 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -2260,12 +2260,9 @@ mod raw { #[cfg(test)] mod tests { use super::*; - use crate::new_default_platform; use crate::ContextOptions; use crate::Global; - use crate::V8; use std::any::type_name; - use std::sync::Once; trait SameType {} impl SameType for (A, A) {} @@ -2284,17 +2281,9 @@ mod tests { } } - fn initialize_v8() { - static INIT: Once = Once::new(); - INIT.call_once(|| { - V8::initialize_platform(new_default_platform(0, false).make_shared()); - V8::initialize(); - }); - } - #[test] fn deref_types() { - initialize_v8(); + crate::initialize_v8(); let isolate = &mut Isolate::new(Default::default()); AssertTypeOf(isolate).is::(); let l1_hs = &mut HandleScope::new(isolate); @@ -2468,7 +2457,7 @@ mod tests { #[test] fn new_scope_types() { - initialize_v8(); + crate::initialize_v8(); let isolate = &mut Isolate::new(Default::default()); AssertTypeOf(isolate).is::(); let global_context: Global; diff --git a/tests/test_api.rs b/tests/test_api.rs index a50c3c3a86..b3a5b81107 100644 --- a/tests/test_api.rs +++ b/tests/test_api.rs @@ -51,7 +51,7 @@ mod setup { )) .is_ok()); v8::V8::set_flags_from_string( - "--no_freeze_flags_after_init --expose_gc --harmony-import-assertions --harmony-shadow-realm --allow_natives_syntax --turbo_fast_api_calls", + "--no_freeze_flags_after_init --expose_gc --harmony-shadow-realm --allow_natives_syntax --turbo_fast_api_calls", ); v8::V8::initialize_platform( v8::new_unprotected_default_platform(0, false).make_shared(), @@ -639,6 +639,8 @@ fn microtasks() { expected = "v8::OwnedIsolate instances must be dropped in the reverse order of creation. They are entered upon creation and exited upon being dropped." )] fn isolate_drop_order() { + let _setup_guard = setup::parallel_test(); + let isolate1 = v8::Isolate::new(Default::default()); let isolate2 = v8::Isolate::new(Default::default()); drop(isolate1); @@ -1361,7 +1363,7 @@ fn add_message_listener() { fn unexpected_module_resolve_callback<'a>( _context: v8::Local<'a, v8::Context>, _specifier: v8::Local<'a, v8::String>, - _import_assertions: v8::Local<'a, v8::FixedArray>, + _import_attributes: v8::Local<'a, v8::FixedArray>, _referrer: v8::Local<'a, v8::Module>, ) -> Option> { unreachable!() @@ -4881,7 +4883,7 @@ fn module_instantiation_failures1() { fn resolve_callback<'a>( context: v8::Local<'a, v8::Context>, _specifier: v8::Local<'a, v8::String>, - _import_assertions: v8::Local<'a, v8::FixedArray>, + _import_attributes: v8::Local<'a, v8::FixedArray>, _referrer: v8::Local<'a, v8::Module>, ) -> Option> { let scope = &mut unsafe { v8::CallbackScope::new(context) }; @@ -4908,7 +4910,7 @@ fn module_instantiation_failures1() { fn compile_specifier_as_module_resolve_callback<'a>( context: v8::Local<'a, v8::Context>, specifier: v8::Local<'a, v8::String>, - _import_assertions: v8::Local<'a, v8::FixedArray>, + _import_attributes: v8::Local<'a, v8::FixedArray>, _referrer: v8::Local<'a, v8::Module>, ) -> Option> { let scope = &mut unsafe { v8::CallbackScope::new(context) }; @@ -5025,10 +5027,7 @@ fn module_stalled_top_level_await() { } #[test] -fn import_assertions() { - use std::sync::atomic::AtomicUsize; - use std::sync::atomic::Ordering; - +fn import_attributes() { let _setup_guard = setup::parallel_test(); let isolate = &mut v8::Isolate::new(Default::default()); @@ -5038,22 +5037,22 @@ fn import_assertions() { fn module_resolve_callback<'a>( context: v8::Local<'a, v8::Context>, _specifier: v8::Local<'a, v8::String>, - import_assertions: v8::Local<'a, v8::FixedArray>, + import_attributes: v8::Local<'a, v8::FixedArray>, _referrer: v8::Local<'a, v8::Module>, ) -> Option> { let scope = &mut unsafe { v8::CallbackScope::new(context) }; // "type" keyword, value and source offset of assertion - assert_eq!(import_assertions.length(), 3); - let assert1 = import_assertions.get(scope, 0).unwrap(); + assert_eq!(import_attributes.length(), 3); + let assert1 = import_attributes.get(scope, 0).unwrap(); let assert1_val = v8::Local::::try_from(assert1).unwrap(); assert_eq!(assert1_val.to_rust_string_lossy(scope), "type"); - let assert2 = import_assertions.get(scope, 1).unwrap(); + let assert2 = import_attributes.get(scope, 1).unwrap(); let assert2_val = v8::Local::::try_from(assert2).unwrap(); assert_eq!(assert2_val.to_rust_string_lossy(scope), "json"); - let assert3 = import_assertions.get(scope, 2).unwrap(); + let assert3 = import_attributes.get(scope, 2).unwrap(); let assert3_val = v8::Local::::try_from(assert3).unwrap(); - assert_eq!(assert3_val.to_rust_string_lossy(scope), "27"); + assert_eq!(assert3_val.to_rust_string_lossy(scope), "25"); let origin = mock_script_origin(scope, "module.js"); let src = v8::String::new(scope, "export const a = 'a';").unwrap(); @@ -5068,34 +5067,20 @@ fn import_assertions() { _host_defined_options: v8::Local<'s, v8::Data>, _resource_name: v8::Local<'s, v8::Value>, _specifier: v8::Local<'s, v8::String>, - import_assertions: v8::Local<'s, v8::FixedArray>, + import_attributes: v8::Local<'s, v8::FixedArray>, ) -> Option> { // "type" keyword, value - assert_eq!(import_assertions.length(), 2); - let assert1 = import_assertions.get(scope, 0).unwrap(); + assert_eq!(import_attributes.length(), 2); + let assert1 = import_attributes.get(scope, 0).unwrap(); let assert1_val = v8::Local::::try_from(assert1).unwrap(); assert_eq!(assert1_val.to_rust_string_lossy(scope), "type"); - let assert2 = import_assertions.get(scope, 1).unwrap(); + let assert2 = import_attributes.get(scope, 1).unwrap(); let assert2_val = v8::Local::::try_from(assert2).unwrap(); assert_eq!(assert2_val.to_rust_string_lossy(scope), "json"); None } isolate.set_host_import_module_dynamically_callback(dynamic_import_cb); - // TODO(@littledivy): this won't work when V8 removes `assert`. - static COUNTER: AtomicUsize = AtomicUsize::new(0); - extern "C" fn callback( - _msg: v8::Local, - _: v8::Local, - ) { - COUNTER.fetch_add(1, Ordering::SeqCst); - } - - isolate.add_message_listener_with_error_level( - callback, - v8::MessageErrorLevel::ALL, - ); - { let scope = &mut v8::HandleScope::new(isolate); let context = v8::Context::new(scope, Default::default()); @@ -5103,8 +5088,8 @@ fn import_assertions() { let source_text = v8::String::new( scope, - "import 'foo.json' assert { type: \"json\" };\n\ - import('foo.json', { assert: { type: 'json' } });", + "import 'foo.json' with { type: \"json\" };\n\ + import('foo.json', { with: { type: 'json' } });", ) .unwrap(); let origin = mock_script_origin(scope, "foo.js"); @@ -5123,8 +5108,6 @@ fn import_assertions() { assert!(result.unwrap()); assert_eq!(v8::ModuleStatus::Instantiated, module.get_status()); } - - assert_eq!(COUNTER.load(Ordering::SeqCst), 1); } #[test] @@ -5935,7 +5918,7 @@ fn dynamic_import() { _host_defined_options: v8::Local<'s, v8::Data>, _resource_name: v8::Local<'s, v8::Value>, specifier: v8::Local<'s, v8::String>, - _import_assertions: v8::Local<'s, v8::FixedArray>, + _import_attributes: v8::Local<'s, v8::FixedArray>, ) -> Option> { assert!( specifier.strict_equals(v8::String::new(scope, "bar.js").unwrap().into()) @@ -7691,6 +7674,8 @@ fn heap_statistics() { #[test] fn low_memory_notification() { + let _setup_guard = setup::parallel_test(); + let mut isolate = v8::Isolate::new(Default::default()); isolate.low_memory_notification(); } @@ -9248,7 +9233,7 @@ fn code_cache() { fn resolve_callback<'a>( _context: v8::Local<'a, v8::Context>, _specifier: v8::Local<'a, v8::String>, - _import_assertions: v8::Local<'a, v8::FixedArray>, + _import_attributes: v8::Local<'a, v8::FixedArray>, _referrer: v8::Local<'a, v8::Module>, ) -> Option> { None @@ -9642,6 +9627,8 @@ fn compiled_wasm_module() { #[test] fn function_names() { + let _setup_guard = setup::parallel_test(); + // Setup isolate let isolate = &mut v8::Isolate::new(Default::default()); let scope = &mut v8::HandleScope::new(isolate); @@ -9785,6 +9772,8 @@ fn backing_store_resizable() { #[test] fn current_stack_trace() { + let _setup_guard = setup::parallel_test(); + // Setup isolate let isolate = &mut v8::Isolate::new(Default::default()); let scope = &mut v8::HandleScope::new(isolate); diff --git a/tests/test_platform_atomics_pump_message_loop.rs b/tests/test_platform_atomics_pump_message_loop.rs index 4f3307b9e3..190791acd3 100644 --- a/tests/test_platform_atomics_pump_message_loop.rs +++ b/tests/test_platform_atomics_pump_message_loop.rs @@ -1,8 +1,6 @@ #[test] fn atomics_pump_message_loop() { - v8::V8::set_flags_from_string( - "--allow-natives-syntax --harmony-sharedarraybuffer", - ); + v8::V8::set_flags_from_string("--allow-natives-syntax"); v8::V8::initialize_platform( v8::new_unprotected_default_platform(0, false).make_shared(), ); diff --git a/tests/test_ui.rs b/tests/test_ui.rs index 86f1bcf73b..b2a25f64f8 100644 --- a/tests/test_ui.rs +++ b/tests/test_ui.rs @@ -5,6 +5,10 @@ fn ui() { // This environment variable tells build.rs that we're running trybuild tests, // so it won't rebuild V8. std::env::set_var("DENO_TRYBUILD", "1"); + std::env::set_var( + "RUSTY_V8_SRC_BINDING_PATH", + env!("RUSTY_V8_SRC_BINDING_PATH"), + ); let t = trybuild::TestCases::new(); t.compile_fail("tests/compile_fail/*.rs"); diff --git a/third_party/abseil-cpp b/third_party/abseil-cpp index 1f7e21e34c..dc257ad54f 160000 --- a/third_party/abseil-cpp +++ b/third_party/abseil-cpp @@ -1 +1 @@ -Subproject commit 1f7e21e34c3807a8841c9562cfc8b3213eb50bfc +Subproject commit dc257ad54f38739767a6cb26eb57fd51c37bfe3c diff --git a/third_party/libc++/src b/third_party/libc++/src index 50ab693ecb..6a68fd412b 160000 --- a/third_party/libc++/src +++ b/third_party/libc++/src @@ -1 +1 @@ -Subproject commit 50ab693ecb611942ce4440d8c9ed707ee65ed5e8 +Subproject commit 6a68fd412b9aecd515a20a7cf84d11b598bfaf96 diff --git a/third_party/libc++abi/src b/third_party/libc++abi/src index 29b2e9a0f4..9a1d90c3b4 160000 --- a/third_party/libc++abi/src +++ b/third_party/libc++abi/src @@ -1 +1 @@ -Subproject commit 29b2e9a0f48688da116692cb04758393053d269c +Subproject commit 9a1d90c3b412d5ebeb97a6e33d98e1d0dd923221 diff --git a/third_party/libunwind/src b/third_party/libunwind/src index dc70138c3e..efc3baa2d1 160000 --- a/third_party/libunwind/src +++ b/third_party/libunwind/src @@ -1 +1 @@ -Subproject commit dc70138c3e68e2f946585f134e20815851e26263 +Subproject commit efc3baa2d1ece3630fcfa72bef93ed831bcaec4c diff --git a/tools/auto_update_v8.ts b/tools/auto_update_v8.ts index 23904bfaa3..f050317e3b 100644 --- a/tools/auto_update_v8.ts +++ b/tools/auto_update_v8.ts @@ -41,6 +41,9 @@ async function run(cmd: string, args: string[], cwd?: string) { await run("git", ["fetch", `origin`, V8_TRACKING_BRANCH], "./v8"); await run("git", ["checkout", `origin/${V8_TRACKING_BRANCH}`], "./v8"); +// Update v8 dependencies +await run("python", ["tools/update_deps.py"]); + const newVersion = extractVersion(); if (currentVersion == newVersion) { console.log(`No new version available. Staying on ${newVersion}`); diff --git a/tools/clang b/tools/clang index e47c184ec5..c8b0e5b333 160000 --- a/tools/clang +++ b/tools/clang @@ -1 +1 @@ -Subproject commit e47c184ec52d50c7aa2a99cd3bd26ebcafaa94b9 +Subproject commit c8b0e5b3332ed68fee3ddb20d7e717424a2a4753