diff --git a/patches/node.v20.14.0.cpp.patch b/patches/node.v20.14.0.cpp.patch index e69de29b..1a953a95 100644 --- a/patches/node.v20.14.0.cpp.patch +++ b/patches/node.v20.14.0.cpp.patch @@ -0,0 +1,553 @@ +diff --git node/common.gypi node/common.gypi +index 0af8af37c6..604a28c3cf 100644 +--- node/common.gypi ++++ node/common.gypi +@@ -183,7 +183,7 @@ + 'MSVC_runtimeType': 2 # MultiThreadedDLL (/MD) + }], + ['llvm_version=="0.0"', { +- 'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ', # GCC ++ 'lto': ' -flto=4 -ffat-lto-objects ', # GCC + }, { + 'lto': ' -flto ', # Clang + }], +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 a06394e6c1..154b7a82a8 100644 +--- node/deps/v8/src/api/api.cc ++++ node/deps/v8/src/api/api.cc +@@ -806,6 +806,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->set_source(i::ReadOnlyRoots(isolate).undefined_value()); ++} ++ + 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 31c5acceeb..56cad8671f 100644 +--- node/deps/v8/src/codegen/compiler.cc ++++ node/deps/v8/src/codegen/compiler.cc +@@ -3475,7 +3475,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/objects/js-function.cc node/deps/v8/src/objects/js-function.cc +index 94f7a672a7..57bb3fc7f1 100644 +--- node/deps/v8/src/objects/js-function.cc ++++ node/deps/v8/src/objects/js-function.cc +@@ -1280,6 +1280,9 @@ Handle JSFunction::ToString(Handle function) { + Handle maybe_class_positions = JSReceiver::GetDataProperty( + isolate, function, isolate->factory()->class_positions_symbol()); + if (maybe_class_positions->IsClassPositions()) { ++ if (String::cast(Script::cast(shared_info->script()).source()).IsUndefined(isolate)) { ++ return isolate->factory()->NewStringFromAsciiChecked("class {}"); ++ } + ClassPositions class_positions = + ClassPositions::cast(*maybe_class_positions); + int start_position = class_positions.start(); +diff --git node/deps/v8/src/objects/shared-function-info-inl.h node/deps/v8/src/objects/shared-function-info-inl.h +index 5621b15d98..722e1d18cb 100644 +--- node/deps/v8/src/objects/shared-function-info-inl.h ++++ node/deps/v8/src/objects/shared-function-info-inl.h +@@ -635,6 +635,14 @@ bool SharedFunctionInfo::ShouldFlushCode( + } + if (!data.IsBytecodeArray()) return false; + ++ Object script_obj = script(); ++ if (!script_obj.IsUndefined()) { ++ Script script = Script::cast(script_obj); ++ if (script.source().IsUndefined()) { ++ return false; ++ } ++ } ++ + if (IsStressFlushingEnabled(code_flush_mode)) return true; + + BytecodeArray bytecode = BytecodeArray::cast(data); +diff --git node/deps/v8/src/parsing/parsing.cc node/deps/v8/src/parsing/parsing.cc +index 8c55a6fb6e..70bf82a57d 100644 +--- node/deps/v8/src/parsing/parsing.cc ++++ node/deps/v8/src/parsing/parsing.cc +@@ -42,6 +42,7 @@ bool ParseProgram(ParseInfo* info, Handle