From cff3fa5f03c9a8e1398db7e7946f08a80dda3086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Thu, 19 Dec 2024 08:22:32 +0100 Subject: [PATCH] build,src,tools: adapt build config for V8 13.3 Refs: https://github.com/v8/v8/commit/1c9f59c80f37124f0b967c9f62e93ff35380a692 Refs: https://github.com/v8/v8/commit/b1c5eba50ac61e405a4e02bd3682c915a948c8ea Refs: https://github.com/v8/v8/commit/b3054f77d65ea96ddf6e0a526abadebd91d7114e Refs: https://github.com/v8/v8/commit/f81e87ee5c6815db81c6ca84ae932c944b1d6191 Refs: https://github.com/v8/v8/commit/dc0e30522358f421585aa9bb8e5e52cd11a7e09f Refs: https://github.com/v8/v8/commit/41d42cec13ea567f461d98dfb04d641e30d6bb5b PR-URL: https://github.com/nodejs/node/pull/58070 Reviewed-By: Antoine du Hamel Reviewed-By: Darshan Sen Reviewed-By: Joyee Cheung Reviewed-By: Rafael Gonzaga --- configure.py | 7 ------- node.gypi | 3 --- src/api/embed_helpers.cc | 4 ---- src/api/environment.cc | 6 ++---- src/env.cc | 12 +++--------- src/node.h | 4 ++-- tools/v8_gypfiles/abseil.gyp | 3 +++ tools/v8_gypfiles/features.gypi | 10 +++------- tools/v8_gypfiles/inspector.gypi | 1 - tools/v8_gypfiles/v8.gyp | 21 ++++++++++++++++++++- 10 files changed, 33 insertions(+), 38 deletions(-) diff --git a/configure.py b/configure.py index 65d39ba03b1..64ab723d006 100755 --- a/configure.py +++ b/configure.py @@ -640,12 +640,6 @@ parser.add_argument('--experimental-enable-pointer-compression', default=None, help='[Experimental] Enable V8 pointer compression (limits max heap to 4GB and breaks ABI compatibility)') -parser.add_argument('--disable-shared-readonly-heap', - action='store_true', - dest='disable_shared_ro_heap', - default=None, - help='Disable the shared read-only heap feature in V8') - parser.add_argument('--v8-options', action='store', dest='v8_options', @@ -1720,7 +1714,6 @@ def configure_v8(o, configs): o['variables']['v8_enable_pointer_compression'] = 1 if options.enable_pointer_compression else 0 o['variables']['v8_enable_sandbox'] = 1 if options.enable_pointer_compression else 0 o['variables']['v8_enable_31bit_smis_on_64bit_arch'] = 1 if options.enable_pointer_compression else 0 - o['variables']['v8_enable_shared_ro_heap'] = 0 if options.disable_shared_ro_heap else 1 o['variables']['v8_enable_extensible_ro_snapshot'] = 0 o['variables']['v8_trace_maps'] = 1 if options.trace_maps else 0 o['variables']['node_use_v8_platform'] = b(not options.without_v8_platform) diff --git a/node.gypi b/node.gypi index 17d09d0feb3..308d614ab02 100644 --- a/node.gypi +++ b/node.gypi @@ -100,9 +100,6 @@ 'NODE_USE_V8_PLATFORM=0', ], }], - [ 'v8_enable_shared_ro_heap==1', { - 'defines': ['NODE_V8_SHARED_RO_HEAP',], - }], [ 'node_tag!=""', { 'defines': [ 'NODE_TAG="<(node_tag)"' ], }], diff --git a/src/api/embed_helpers.cc b/src/api/embed_helpers.cc index ff9ae20d7b8..6498c09ee97 100644 --- a/src/api/embed_helpers.cc +++ b/src/api/embed_helpers.cc @@ -352,11 +352,7 @@ EmbedderSnapshotData::EmbedderSnapshotData(const SnapshotData* impl, : impl_(impl), owns_impl_(owns_impl) {} bool EmbedderSnapshotData::CanUseCustomSnapshotPerIsolate() { -#ifdef NODE_V8_SHARED_RO_HEAP return false; -#else - return true; -#endif } } // namespace node diff --git a/src/api/environment.cc b/src/api/environment.cc index 52322e73166..21cbfbfdf12 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -312,17 +312,15 @@ Isolate* NewIsolate(Isolate::CreateParams* params, SnapshotBuilder::InitializeIsolateParams(snapshot_data, params); } -#ifdef NODE_V8_SHARED_RO_HEAP { - // In shared-readonly-heap mode, V8 requires all snapshots used for - // creating Isolates to be identical. This isn't really memory-safe + // Because it uses a shared readonly-heap, V8 requires all snapshots used + // for creating Isolates to be identical. This isn't really memory-safe // but also otherwise just doesn't work, and the only real alternative // is disabling shared-readonly-heap mode altogether. static Isolate::CreateParams first_params = *params; params->snapshot_blob = first_params.snapshot_blob; params->external_references = first_params.external_references; } -#endif // Register the isolate on the platform before the isolate gets initialized, // so that the isolate can access the platform during initialization. diff --git a/src/env.cc b/src/env.cc index 5d6102dbdb1..3f393adbce9 100644 --- a/src/env.cc +++ b/src/env.cc @@ -828,15 +828,9 @@ Environment::Environment(IsolateData* isolate_data, thread_id_(thread_id.id == static_cast(-1) ? AllocateEnvironmentThreadId().id : thread_id.id) { - constexpr bool is_shared_ro_heap = -#ifdef NODE_V8_SHARED_RO_HEAP - true; -#else - false; -#endif - if (is_shared_ro_heap && !is_main_thread()) { - // If this is a Worker thread and we are in shared-readonly-heap mode, - // we can always safely use the parent's Isolate's code cache. + if (!is_main_thread()) { + // If this is a Worker thread, we can always safely use the parent's + // Isolate's code cache because of the shared read-only heap. CHECK_NOT_NULL(isolate_data->worker_context()); builtin_loader()->CopySourceAndCodeCacheReferenceFrom( isolate_data->worker_context()->env()->builtin_loader()); diff --git a/src/node.h b/src/node.h index c492185c56d..8c72fecaa04 100644 --- a/src/node.h +++ b/src/node.h @@ -543,8 +543,8 @@ class EmbedderSnapshotData { void ToFile(FILE* out) const; std::vector ToBlob() const; - // Returns whether custom snapshots can be used. Currently, this means - // that V8 was configured without the shared-readonly-heap feature. + // Returns whether custom snapshots can be used. Currently, this always + // returns false since V8 enforces shared readonly-heap. static bool CanUseCustomSnapshotPerIsolate(); EmbedderSnapshotData(const EmbedderSnapshotData&) = delete; diff --git a/tools/v8_gypfiles/abseil.gyp b/tools/v8_gypfiles/abseil.gyp index bac98d781fb..322ff2e12f7 100644 --- a/tools/v8_gypfiles/abseil.gyp +++ b/tools/v8_gypfiles/abseil.gyp @@ -11,6 +11,9 @@ 'include_dirs': [ '<(ABSEIL_ROOT)', ], + 'xcode_settings': { + 'OTHER_LDFLAGS': ['-framework CoreFoundation'], + }, }, 'include_dirs': [ '<(ABSEIL_ROOT)', diff --git a/tools/v8_gypfiles/features.gypi b/tools/v8_gypfiles/features.gypi index dc31a3a8fa6..582fcee3901 100644 --- a/tools/v8_gypfiles/features.gypi +++ b/tools/v8_gypfiles/features.gypi @@ -134,6 +134,9 @@ # Enable fast mksnapshot runs. 'v8_enable_fast_mksnapshot%': 0, + # Enable using multiple threads to build builtins in mksnapshot. + 'v8_enable_concurrent_mksnapshot%': 1, + # Enable the registration of unwinding info for Windows/x64 and ARM64. 'v8_win64_unwinding_info%': 1, @@ -209,10 +212,6 @@ # Controls the threshold for on-heap/off-heap Typed Arrays. 'v8_typed_array_max_size_in_heap%': 64, - # Enable sharing read-only space across isolates. - # Sets -DV8_SHARED_RO_HEAP. - 'v8_enable_shared_ro_heap%': 0, - # Enable lazy source positions by default. 'v8_enable_lazy_source_positions%': 1, @@ -437,9 +436,6 @@ ['v8_use_siphash==1', { 'defines': ['V8_USE_SIPHASH',], }], - ['v8_enable_shared_ro_heap==1', { - 'defines': ['V8_SHARED_RO_HEAP',], - }], ['dcheck_always_on!=0', { 'defines': ['DEBUG',], }, { diff --git a/tools/v8_gypfiles/inspector.gypi b/tools/v8_gypfiles/inspector.gypi index 517823767d8..4b6c3d72f73 100644 --- a/tools/v8_gypfiles/inspector.gypi +++ b/tools/v8_gypfiles/inspector.gypi @@ -119,7 +119,6 @@ '<(inspector_protocol_path)/crdtp/find_by_first.h', '<(inspector_protocol_path)/crdtp/json.cc', '<(inspector_protocol_path)/crdtp/json.h', - '<(inspector_protocol_path)/crdtp/maybe.h', '<(inspector_protocol_path)/crdtp/parser_handler.h', '<(inspector_protocol_path)/crdtp/protocol_core.cc', '<(inspector_protocol_path)/crdtp/protocol_core.h', diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp index eee8fd96796..c3724fe7a5b 100644 --- a/tools/v8_gypfiles/v8.gyp +++ b/tools/v8_gypfiles/v8.gyp @@ -451,6 +451,15 @@ 'mksnapshot_flags': ['--code-comments'], }, }], + ['v8_enable_concurrent_mksnapshot == 1', { + 'variables': { + 'mksnapshot_flags': [ + '--concurrent-builtin-generation', + # Use all the cores for concurrent builtin generation. + '--concurrent-turbofan-max-threads=0', + ], + }, + }], ['v8_enable_snapshot_native_code_counters', { 'variables': { 'mksnapshot_flags': ['--native-code-counters'], @@ -481,6 +490,7 @@ 'v8_compiler_for_mksnapshot', 'v8_initializers', 'v8_libplatform', + 'abseil.gyp:abseil', ] }, { 'dependencies': [ @@ -493,6 +503,7 @@ 'v8_compiler_for_mksnapshot', 'v8_initializers', 'v8_libplatform', + 'abseil.gyp:abseil', ] }], ['OS=="win" and clang==1', { @@ -1317,6 +1328,7 @@ 'dependencies': [ 'v8_shared_internal_headers', 'v8_libbase', + 'abseil.gyp:abseil', ], 'defines!': [ '_HAS_EXCEPTIONS=0', @@ -1370,6 +1382,7 @@ 'dependencies': [ 'v8_headers', + 'abseil.gyp:abseil', ], 'conditions': [ @@ -1618,6 +1631,7 @@ 'toolsets': ['host', 'target'], 'dependencies': [ 'v8_libbase', + 'abseil.gyp:abseil', ], 'sources': [ '