diff --git node/common.gypi node/common.gypi index 576d5057d9..34e85ee423 100644 --- node/common.gypi +++ node/common.gypi @@ -192,7 +192,7 @@ ['clang==1', { 'lto': ' -flto ', # Clang }, { - 'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ', # GCC + 'lto': ' -flto=4 -ffat-lto-objects ', # GCC }], ], }, diff --git node/deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.c node/deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.c index 7d3ab39bf8..67a48dee53 100644 --- node/deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.c +++ node/deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.c @@ -34,10 +34,7 @@ #include "nghttp3_macro.h" static int ispow2(size_t n) { -#if defined(_MSC_VER) && !defined(__clang__) && \ - (defined(_M_ARM) || (defined(_M_ARM64) && _MSC_VER < 1941)) - return n && !(n & (n - 1)); -#elif defined(WIN32) +#if defined(WIN32) return 1 == __popcnt((unsigned int)n); #else /* !((defined(_MSC_VER) && !defined(__clang__) && (defined(_M_ARM) || \ (defined(_M_ARM64) && _MSC_VER < 1941))) || defined(WIN32)) */ diff --git node/deps/ngtcp2/ngtcp2/lib/ngtcp2_ringbuf.c node/deps/ngtcp2/ngtcp2/lib/ngtcp2_ringbuf.c index 353afca4d4..dea944aed5 100644 --- node/deps/ngtcp2/ngtcp2/lib/ngtcp2_ringbuf.c +++ node/deps/ngtcp2/ngtcp2/lib/ngtcp2_ringbuf.c @@ -33,10 +33,7 @@ #ifndef NDEBUG static int ispow2(size_t n) { -# if defined(_MSC_VER) && !defined(__clang__) && \ - (defined(_M_ARM) || (defined(_M_ARM64) && _MSC_VER < 1941)) - return n && !(n & (n - 1)); -# elif defined(WIN32) +#if defined(WIN32) return 1 == __popcnt((unsigned int)n); # else /* !((defined(_MSC_VER) && !defined(__clang__) && (defined(_M_ARM) || \ (defined(_M_ARM64) && _MSC_VER < 1941))) || defined(WIN32)) */ diff --git node/deps/v8/include/v8-initialization.h node/deps/v8/include/v8-initialization.h index 46a21a02cb..fdb0edf42a 100644 --- node/deps/v8/include/v8-initialization.h +++ node/deps/v8/include/v8-initialization.h @@ -98,6 +98,10 @@ class V8_EXPORT V8 { static void SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags); + static void EnableCompilationForSourcelessUse(); + static void DisableCompilationForSourcelessUse(); + static void FixSourcelessScript(Isolate* v8_isolate, Local script); + /** Get the version string. */ static const char* GetVersion(); diff --git node/deps/v8/src/api/api.cc node/deps/v8/src/api/api.cc index ef4546de27..60bb6a4edc 100644 --- node/deps/v8/src/api/api.cc +++ node/deps/v8/src/api/api.cc @@ -443,6 +443,28 @@ void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { HelpOptions(HelpOptions::kDontExit)); } +bool save_lazy; +bool save_predictable; + +void V8::EnableCompilationForSourcelessUse() { + save_lazy = i::v8_flags.lazy; + i::v8_flags.lazy = false; + save_predictable = i::v8_flags.predictable; + i::v8_flags.predictable = true; +} + +void V8::DisableCompilationForSourcelessUse() { + i::v8_flags.lazy = save_lazy; + i::v8_flags.predictable = save_predictable; +} + +void V8::FixSourcelessScript(Isolate* v8_isolate, Local unbound_script) { + auto isolate = reinterpret_cast(v8_isolate); + auto function_info = i::Cast(Utils::OpenHandle(*unbound_script)); + i::Handle script(i::Cast(function_info->script()), isolate); + script->SetSource(isolate, script, isolate->factory()->empty_string()); +} + RegisteredExtension* RegisteredExtension::first_extension_ = nullptr; RegisteredExtension::RegisteredExtension(std::unique_ptr extension) diff --git node/deps/v8/src/codegen/compiler.cc node/deps/v8/src/codegen/compiler.cc index e31937f042..fa8c37072f 100644 --- node/deps/v8/src/codegen/compiler.cc +++ node/deps/v8/src/codegen/compiler.cc @@ -3945,7 +3945,7 @@ MaybeDirectHandle GetSharedFunctionInfoForScriptImpl( maybe_script = lookup_result.script(); maybe_result = lookup_result.toplevel_sfi(); is_compiled_scope = lookup_result.is_compiled_scope(); - if (!maybe_result.is_null()) { + if (!maybe_result.is_null() && source->length()) { compile_timer.set_hit_isolate_cache(); } else if (can_consume_code_cache) { compile_timer.set_consuming_code_cache(); diff --git node/deps/v8/src/codegen/define-code-stub-assembler-macros.inc node/deps/v8/src/codegen/define-code-stub-assembler-macros.inc index fb272f6afd..eb7c237530 100644 --- node/deps/v8/src/codegen/define-code-stub-assembler-macros.inc +++ node/deps/v8/src/codegen/define-code-stub-assembler-macros.inc @@ -21,7 +21,7 @@ // This is a check that always calls into the runtime if it aborts. // This also exits silently when --hole-fuzzing is enabled. #define CSA_HOLE_SECURITY_CHECK(csa, x) \ - (csa)->Check([&]() -> TNode { return x; }, #x, __FILE__, __LINE__) + (csa)->Check([&]() -> TNode { return x; }, #x, "placeholder", 1) #ifdef DEBUG // CSA_DCHECK_ARGS generates an diff --git node/deps/v8/src/compiler/wasm-compiler.cc node/deps/v8/src/compiler/wasm-compiler.cc index 87a194b5c2..06270d0c6e 100644 --- node/deps/v8/src/compiler/wasm-compiler.cc +++ node/deps/v8/src/compiler/wasm-compiler.cc @@ -1096,11 +1096,15 @@ wasm::WasmCompilationResult CompileWasmImportCallWrapper( "wasm-to-js-%d-", static_cast(kind)); PrintSignature(base::VectorOf(func_name, kMaxNameLen) + name_prefix_len, sig, '-'); + wasm::WrapperCompilationInfo info; + info.code_kind = CodeKind::WASM_TO_JS_FUNCTION; + info.import_kind = kind; + info.expected_arity = expected_arity; + info.suspend = suspend; auto result = Pipeline::GenerateCodeForWasmNativeStubFromTurboshaft( sig, - wasm::WrapperCompilationInfo{CodeKind::WASM_TO_JS_FUNCTION, kind, - expected_arity, suspend}, + info, func_name, WasmStubAssemblerOptions(), nullptr); if (V8_UNLIKELY(v8_flags.trace_wasm_compilation_times)) { diff --git node/deps/v8/src/heap/marking-visitor-inl.h node/deps/v8/src/heap/marking-visitor-inl.h index c38e02da07..6d6d7b33ed 100644 --- node/deps/v8/src/heap/marking-visitor-inl.h +++ node/deps/v8/src/heap/marking-visitor-inl.h @@ -464,6 +464,13 @@ bool MarkingVisitorBase::HasBytecodeArrayForFlushing( template bool MarkingVisitorBase::ShouldFlushCode( Tagged sfi) const { + auto script_obj = sfi->script(); + if (!IsUndefined(script_obj)) { + auto script = Cast