diff --git node/common.gypi node/common.gypi index f75cdf47b8..0030fe2ad4 100644 --- node/common.gypi +++ node/common.gypi @@ -187,7 +187,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 5e7775f1a5..eeebf67796 100644 --- node/deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.c +++ node/deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.c @@ -33,16 +33,6 @@ #include "nghttp3_macro.h" -#if defined(_MSC_VER) && !defined(__clang__) && (defined(_M_ARM) || defined(_M_ARM64)) -unsigned int __popcnt(unsigned int x) { - unsigned int c = 0; - for (; x; ++c) { - x &= x - 1; - } - return c; -} -#endif - int nghttp3_ringbuf_init(nghttp3_ringbuf *rb, size_t nmemb, size_t size, const nghttp3_mem *mem) { if (nmemb) { diff --git node/deps/ngtcp2/ngtcp2/lib/ngtcp2_ringbuf.c node/deps/ngtcp2/ngtcp2/lib/ngtcp2_ringbuf.c index 74e488bce7..36ca05e80e 100644 --- node/deps/ngtcp2/ngtcp2/lib/ngtcp2_ringbuf.c +++ node/deps/ngtcp2/ngtcp2/lib/ngtcp2_ringbuf.c @@ -31,16 +31,6 @@ #include "ngtcp2_macro.h" -#if defined(_MSC_VER) && !defined(__clang__) && (defined(_M_ARM) || defined(_M_ARM64)) -unsigned int __popcnt(unsigned int x) { - unsigned int c = 0; - for (; x; ++c) { - x &= x - 1; - } - return c; -} -#endif - int ngtcp2_ringbuf_init(ngtcp2_ringbuf *rb, size_t nmemb, size_t size, const ngtcp2_mem *mem) { uint8_t *buf = ngtcp2_mem_malloc(mem, nmemb * size); 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 da0c960f99..08af13d77a 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