diff --git node/common.gypi node/common.gypi index 0ffa5b1371..6f04eb354f 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 d3e35d6ec5..6e9bbe3849 100644 --- node/deps/v8/include/v8-initialization.h +++ node/deps/v8/include/v8-initialization.h @@ -89,6 +89,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 f9ce798dc2..68af88ab13 100644 --- node/deps/v8/src/api/api.cc +++ node/deps/v8/src/api/api.cc @@ -624,6 +624,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::Handle::cast(Utils::OpenHandle(*unbound_script)); + i::Handle script(i::Script::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/code-stub-assembler.h node/deps/v8/src/codegen/code-stub-assembler.h index c7c92eed93..9eaea3aaa8 100644 --- node/deps/v8/src/codegen/code-stub-assembler.h +++ node/deps/v8/src/codegen/code-stub-assembler.h @@ -286,7 +286,8 @@ enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol }; // 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_WITH_ABORT(csa, x) +#define CSA_HOLE_SECURITY_CHECK(csa, x) \ + (csa)->Check([&]() -> TNode { return x; }, #x, "placeholder", 1) #ifdef DEBUG // CSA_DCHECK_ARGS generates an diff --git node/deps/v8/src/codegen/compiler.cc node/deps/v8/src/codegen/compiler.cc index 9048655363..ab81c326fc 100644 --- node/deps/v8/src/codegen/compiler.cc +++ node/deps/v8/src/codegen/compiler.cc @@ -3634,7 +3634,7 @@ MaybeHandle 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/compiler/wasm-compiler.cc node/deps/v8/src/compiler/wasm-compiler.cc index bd3dd3b27b..dab870e776 100644 --- node/deps/v8/src/compiler/wasm-compiler.cc +++ node/deps/v8/src/compiler/wasm-compiler.cc @@ -8618,12 +8618,13 @@ wasm::WasmCompilationResult CompileWasmImportCallWrapper( '-'); auto compile_with_turboshaft = [&]() { + wasm::WrapperCompilationInfo info; + info.code_kind = CodeKind::WASM_TO_JS_FUNCTION; + info.import_info.import_kind = kind; + info.import_info.expected_arity = expected_arity; + info.import_info.suspend = suspend; return Pipeline::GenerateCodeForWasmNativeStubFromTurboshaft( - env->module, sig, - wasm::WrapperCompilationInfo{ - .code_kind = CodeKind::WASM_TO_JS_FUNCTION, - .import_info = {kind, expected_arity, suspend}}, - func_name, WasmStubAssemblerOptions(), nullptr); + env->module, sig, info, func_name, WasmStubAssemblerOptions(), nullptr); }; auto compile_with_turbofan = [&]() { //-------------------------------------------------------------------------- @@ -8779,13 +8780,15 @@ MaybeHandle CompileWasmToJSWrapper(Isolate* isolate, base::VectorOf(name_buffer.get(), kMaxNameLen) + kNamePrefixLen, sig); auto compile_with_turboshaft = [&]() { + wasm::WrapperCompilationInfo info; + info.code_kind = CodeKind::WASM_TO_JS_FUNCTION; + info.import_info.import_kind = kind; + info.import_info.expected_arity = expected_arity; + info.import_info.suspend = suspend; std::unique_ptr job = Pipeline::NewWasmTurboshaftWrapperCompilationJob( - isolate, sig, - wasm::WrapperCompilationInfo{ - .code_kind = CodeKind::WASM_TO_JS_FUNCTION, - .import_info = {kind, expected_arity, suspend}}, - nullptr, std::move(name_buffer), WasmAssemblerOptions()); + isolate, sig, info, nullptr, std::move(name_buffer), + WasmAssemblerOptions()); // Compile the wrapper if (job->ExecuteJob(isolate->counters()->runtime_call_stats()) == diff --git node/deps/v8/src/heap/marking-visitor-inl.h node/deps/v8/src/heap/marking-visitor-inl.h index 39a5bbd22c..4b860f55d5 100644 --- node/deps/v8/src/heap/marking-visitor-inl.h +++ node/deps/v8/src/heap/marking-visitor-inl.h @@ -329,6 +329,13 @@ bool MarkingVisitorBase::HasBytecodeArrayForFlushing( template bool MarkingVisitorBase::ShouldFlushCode( Tagged sfi) const { + auto script_obj = sfi->script(); + if (!IsUndefined(script_obj)) { + auto script = i::Script::cast(script_obj); + if (IsUndefined(script->source())) { + return false; + } + } return IsStressFlushingEnabled(code_flush_mode_) || IsOld(sfi); } diff --git node/deps/v8/src/objects/js-function.cc node/deps/v8/src/objects/js-function.cc index 529e283bbf..c997c53a18 100644 --- node/deps/v8/src/objects/js-function.cc +++ node/deps/v8/src/objects/js-function.cc @@ -1308,6 +1308,10 @@ Handle JSFunction::ToString(Handle function) { Handle maybe_class_positions = JSReceiver::GetDataProperty( isolate, function, isolate->factory()->class_positions_symbol()); if (IsClassPositions(*maybe_class_positions)) { + if (IsUndefined( + String::cast(Script::cast(shared_info->script())->source()))) { + return isolate->factory()->NewStringFromAsciiChecked("class {}"); + } Tagged class_positions = ClassPositions::cast(*maybe_class_positions); int start_position = class_positions->start(); diff --git node/deps/v8/src/objects/objects.cc node/deps/v8/src/objects/objects.cc index 535ee9ed70..cf1e06d4fc 100644 --- node/deps/v8/src/objects/objects.cc +++ node/deps/v8/src/objects/objects.cc @@ -4246,7 +4246,12 @@ void Script::InitLineEndsInternal(IsolateT* isolate, Handle