diff --git node/deps/v8/include/v8-initialization.h node/deps/v8/include/v8-initialization.h index 406f1d0ba5..fb8eea420d 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 9ef4e3b4a6..34cabe171c 100644 --- node/deps/v8/src/api/api.cc +++ node/deps/v8/src/api/api.cc @@ -469,6 +469,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 2dc782458e..0cddfbbbc4 100644 --- node/deps/v8/src/codegen/compiler.cc +++ node/deps/v8/src/codegen/compiler.cc @@ -3988,7 +3988,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/compiler/wasm-compiler.cc node/deps/v8/src/compiler/wasm-compiler.cc index 632d54de8c..cbf91f9d6c 100644 --- node/deps/v8/src/compiler/wasm-compiler.cc +++ node/deps/v8/src/compiler/wasm-compiler.cc @@ -1090,11 +1090,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()); 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 8ac9d6d49b..7a241f2de7 100644 --- node/deps/v8/src/heap/marking-visitor-inl.h +++ node/deps/v8/src/heap/marking-visitor-inl.h @@ -517,6 +517,13 @@ bool MarkingVisitorBase::HasBytecodeArrayForFlushing( template bool MarkingVisitorBase::ShouldFlushCode( Tagged sfi) const { + auto script_obj = sfi->script(); + if (!IsUndefined(script_obj)) { + auto script = Cast