From af97f8b9cc77c29010bb50ae72335757870cf53f Mon Sep 17 00:00:00 2001 From: Igor Sheludko Date: Thu, 26 Feb 2026 18:22:51 +0100 Subject: [PATCH 1/3] deps: V8: cherry-pick 95efbaf92a0d Original commit message: [api] Delete usages of v8::HeapProfile::ObjectNameResolver ... and start deprecation of the class definition. Bug: 333672197 Change-Id: I9517d09cd1e01b9893384cb9408d714affcefdee Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7614327 Commit-Queue: Igor Sheludko Reviewed-by: Michael Lippautz Cr-Commit-Position: refs/heads/main@{#105492} Refs: https://github.com/v8/v8/commit/95efbaf92a0db596df3d66b5e7087e8cf4b04a07 --- common.gypi | 2 +- deps/v8/include/v8-profiler.h | 26 +--- deps/v8/src/api/api.cc | 29 ----- deps/v8/src/profiler/heap-profiler.cc | 20 +-- .../src/profiler/heap-snapshot-generator.cc | 48 ++----- .../v8/src/profiler/heap-snapshot-generator.h | 12 +- deps/v8/test/cctest/test-heap-profiler.cc | 123 ------------------ 7 files changed, 25 insertions(+), 235 deletions(-) diff --git a/common.gypi b/common.gypi index e6a17d3505a5..563259e21ea7 100644 --- a/common.gypi +++ b/common.gypi @@ -43,7 +43,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.32', + 'v8_embedder_string': '-node.33', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/include/v8-profiler.h b/deps/v8/include/v8-profiler.h index 927fa12e3190..c8874db078ad 100644 --- a/deps/v8/include/v8-profiler.h +++ b/deps/v8/include/v8-profiler.h @@ -1069,7 +1069,8 @@ class V8_EXPORT HeapProfiler { * * This interface will soon be deprecated in favour of ContextNameResolver. */ - class ObjectNameResolver { + class V8_DEPRECATE_SOON("Use ContextNameResolver instead.") + ObjectNameResolver { public: /** * Returns name to be used in the heap snapshot for given node. Returned @@ -1127,24 +1128,13 @@ class V8_EXPORT HeapProfiler { // NOLINTNEXTLINE HeapSnapshotOptions() {} - // TODO(https://crbug.com/333672197): remove once ObjectNameResolver is - // removed. - ALLOW_COPY_AND_MOVE_WITH_DEPRECATED_FIELDS(HeapSnapshotOptions) - /** * The control used to report intermediate progress to. */ ActivityControl* control = nullptr; - /** - * The resolver used by the snapshot generator to get names for V8 objects. - */ - V8_DEPRECATED("Use context_name_resolver callback instead.") - ObjectNameResolver* global_object_name_resolver = nullptr; /** * The resolver used by the snapshot generator to get names for v8::Context * objects. - * In case both this and |global_object_name_resolver| callbacks are - * provided, this one will be used. */ ContextNameResolver* context_name_resolver = nullptr; /** @@ -1176,18 +1166,8 @@ class V8_EXPORT HeapProfiler { * * \returns the snapshot. */ - V8_DEPRECATED("Use overload with ContextNameResolver* resolver instead.") - const HeapSnapshot* TakeHeapSnapshot( - ActivityControl* control, ObjectNameResolver* global_object_name_resolver, - bool hide_internals = true, bool capture_numeric_value = false); - const HeapSnapshot* TakeHeapSnapshot(ActivityControl* control, - ContextNameResolver* resolver, - bool hide_internals = true, - bool capture_numeric_value = false); - // TODO(333672197): remove this version once ObjectNameResolver* overload - // is removed. const HeapSnapshot* TakeHeapSnapshot(ActivityControl* control, - std::nullptr_t resolver = nullptr, + ContextNameResolver* resolver = nullptr, bool hide_internals = true, bool capture_numeric_value = false); diff --git a/deps/v8/src/api/api.cc b/deps/v8/src/api/api.cc index 48da5b35b872..eb3cd7dee28f 100644 --- a/deps/v8/src/api/api.cc +++ b/deps/v8/src/api/api.cc @@ -11849,21 +11849,6 @@ const HeapSnapshot* HeapProfiler::TakeHeapSnapshot( reinterpret_cast(this)->TakeSnapshot(options)); } -const HeapSnapshot* HeapProfiler::TakeHeapSnapshot(ActivityControl* control, - ObjectNameResolver* resolver, - bool hide_internals, - bool capture_numeric_value) { - HeapSnapshotOptions options; - options.control = control; - options.global_object_name_resolver = resolver; - options.snapshot_mode = hide_internals ? HeapSnapshotMode::kRegular - : HeapSnapshotMode::kExposeInternals; - options.numerics_mode = capture_numeric_value - ? NumericsMode::kExposeNumericValues - : NumericsMode::kHideNumericValues; - return TakeHeapSnapshot(options); -} - const HeapSnapshot* HeapProfiler::TakeHeapSnapshot( ActivityControl* control, ContextNameResolver* resolver, bool hide_internals, bool capture_numeric_value) { @@ -11878,20 +11863,6 @@ const HeapSnapshot* HeapProfiler::TakeHeapSnapshot( return TakeHeapSnapshot(options); } -const HeapSnapshot* HeapProfiler::TakeHeapSnapshot(ActivityControl* control, - std::nullptr_t resolver, - bool hide_internals, - bool capture_numeric_value) { - HeapSnapshotOptions options; - options.control = control; - options.snapshot_mode = hide_internals ? HeapSnapshotMode::kRegular - : HeapSnapshotMode::kExposeInternals; - options.numerics_mode = capture_numeric_value - ? NumericsMode::kExposeNumericValues - : NumericsMode::kHideNumericValues; - return TakeHeapSnapshot(options); -} - std::vector> HeapProfiler::GetDetachedJSWrapperObjects() { return reinterpret_cast(this) ->GetDetachedJSWrapperObjects(); diff --git a/deps/v8/src/profiler/heap-profiler.cc b/deps/v8/src/profiler/heap-profiler.cc index c123645e8a4d..f7b3bc55c22d 100644 --- a/deps/v8/src/profiler/heap-profiler.cc +++ b/deps/v8/src/profiler/heap-profiler.cc @@ -146,13 +146,9 @@ HeapSnapshot* HeapProfiler::TakeSnapshot( use_cpp_class_name.emplace(heap()->cpp_heap()); } - // Allow usages of v8::HeapProfiler::ObjectNameResolver for now. - // TODO(https://crbug.com/333672197): remove. - START_ALLOW_USE_DEPRECATED() - HeapSnapshotGenerator generator( - result, options.control, options.global_object_name_resolver, - options.context_name_resolver, heap(), options.stack_state); - END_ALLOW_USE_DEPRECATED() + HeapSnapshotGenerator generator(result, options.control, + options.context_name_resolver, heap(), + options.stack_state); if (!generator.GenerateSnapshot()) { delete result; result = nullptr; @@ -186,13 +182,9 @@ void HeapProfiler::WriteSnapshotToDiskAfterGC(HeapSnapshotMode snapshot_mode) { v8::HeapProfiler::HeapSnapshotOptions options; std::unique_ptr result( new HeapSnapshot(this, snapshot_mode, options.numerics_mode)); - // Allow usages of v8::HeapProfiler::ObjectNameResolver for now. - // TODO(https://crbug.com/333672197): remove. - START_ALLOW_USE_DEPRECATED() - HeapSnapshotGenerator generator( - result.get(), options.control, options.global_object_name_resolver, - options.context_name_resolver, heap(), options.stack_state); - END_ALLOW_USE_DEPRECATED() + HeapSnapshotGenerator generator(result.get(), options.control, + options.context_name_resolver, heap(), + options.stack_state); if (!generator.GenerateSnapshotAfterGC()) return; i::FileOutputStream stream(filename.c_str()); if (stream.IsOpen()) { diff --git a/deps/v8/src/profiler/heap-snapshot-generator.cc b/deps/v8/src/profiler/heap-snapshot-generator.cc index 27e748f204ff..0e87a0d2b4e8 100644 --- a/deps/v8/src/profiler/heap-snapshot-generator.cc +++ b/deps/v8/src/profiler/heap-snapshot-generator.cc @@ -823,18 +823,16 @@ void HeapObjectsMap::RemoveDeadEntries() { entries_map_.occupancy()); } -V8HeapExplorer::V8HeapExplorer( - HeapSnapshot* snapshot, SnapshottingProgressReportingInterface* progress, - v8::HeapProfiler::ObjectNameResolver* resolver, - v8::HeapProfiler::ContextNameResolver* context_resolver) +V8HeapExplorer::V8HeapExplorer(HeapSnapshot* snapshot, + SnapshottingProgressReportingInterface* progress, + v8::HeapProfiler::ContextNameResolver* resolver) : heap_(snapshot->profiler()->heap_object_map()->heap()), snapshot_(snapshot), names_(snapshot_->profiler()->names()), heap_object_map_(snapshot_->profiler()->heap_object_map()), progress_(progress), generator_(nullptr), - global_object_name_resolver_(resolver), - native_context_name_resolver_(context_resolver) {} + native_context_name_resolver_(resolver) {} HeapEntry* V8HeapExplorer::AllocateEntry(HeapThing ptr) { return AddEntry( @@ -3020,9 +3018,7 @@ class NativeContextEnumerator : public RootVisitor { V8HeapExplorer::TemporaryNativeContextTags V8HeapExplorer::CollectTemporaryNativeContextTags() { - if (!global_object_name_resolver_ && !native_context_name_resolver_) { - return {}; - } + if (!native_context_name_resolver_) return {}; Isolate* isolate = heap_->isolate(); TemporaryNativeContextTags native_context_tags; @@ -3030,33 +3026,12 @@ V8HeapExplorer::CollectTemporaryNativeContextTags() { NativeContextEnumerator enumerator( isolate, [this, isolate, &native_context_tags]( DirectHandle native_context) { - if (native_context_name_resolver_) { - v8::Local context = Utils::ToLocal(native_context); - if (const char* tag = - native_context_name_resolver_->GetName(context)) { - native_context_tags.emplace_back( - Global(reinterpret_cast(isolate), - context), - tag); - native_context_tags.back().first.SetWeak(); - } - return; - } - - DirectHandle global(native_context->global_object(), isolate); - if (const char* tag = - global_object_name_resolver_->GetName(Utils::ToLocal(global))) { - native_context_tags.emplace_back( - Global(reinterpret_cast(isolate), - Utils::ToLocal(native_context)), - tag); - native_context_tags.back().first.SetWeak(); - return; - } + v8::Local context = Utils::ToLocal(native_context); + const char* tag = native_context_name_resolver_->GetName(context); native_context_tags.emplace_back( Global(reinterpret_cast(isolate), - Utils::ToLocal(native_context)), - nullptr); + context), + tag); native_context_tags.back().first.SetWeak(); }); isolate->global_handles()->IterateAllRoots(&enumerator); @@ -3364,12 +3339,11 @@ bool NativeObjectsExplorer::IterateAndExtractReferences( HeapSnapshotGenerator::HeapSnapshotGenerator( HeapSnapshot* snapshot, v8::ActivityControl* control, - v8::HeapProfiler::ObjectNameResolver* resolver, - v8::HeapProfiler::ContextNameResolver* context_resolver, Heap* heap, + v8::HeapProfiler::ContextNameResolver* resolver, Heap* heap, cppgc::EmbedderStackState stack_state) : snapshot_(snapshot), control_(control), - v8_heap_explorer_(snapshot_, this, resolver, context_resolver), + v8_heap_explorer_(snapshot_, this, resolver), dom_explorer_(snapshot_, this), heap_(heap), stack_state_(stack_state) {} diff --git a/deps/v8/src/profiler/heap-snapshot-generator.h b/deps/v8/src/profiler/heap-snapshot-generator.h index 8d826fbc3098..f78dabae27a2 100644 --- a/deps/v8/src/profiler/heap-snapshot-generator.h +++ b/deps/v8/src/profiler/heap-snapshot-generator.h @@ -413,8 +413,7 @@ class V8_EXPORT_PRIVATE V8HeapExplorer : public HeapEntriesAllocator { public: V8HeapExplorer(HeapSnapshot* snapshot, SnapshottingProgressReportingInterface* progress, - v8::HeapProfiler::ObjectNameResolver* resolver, - v8::HeapProfiler::ContextNameResolver* context_resolver); + v8::HeapProfiler::ContextNameResolver* resolver); ~V8HeapExplorer() override = default; V8HeapExplorer(const V8HeapExplorer&) = delete; V8HeapExplorer& operator=(const V8HeapExplorer&) = delete; @@ -610,7 +609,6 @@ class V8_EXPORT_PRIVATE V8HeapExplorer : public HeapEntriesAllocator { native_context_tag_map_; UnorderedHeapObjectMap strong_gc_subroot_names_; std::unordered_set, Object::Hasher> user_roots_; - v8::HeapProfiler::ObjectNameResolver* global_object_name_resolver_; v8::HeapProfiler::ContextNameResolver* native_context_name_resolver_; std::vector visited_fields_; @@ -660,11 +658,9 @@ class HeapSnapshotGenerator : public SnapshottingProgressReportingInterface { // their representations in heap snapshots. using SmiEntriesMap = std::unordered_map; - HeapSnapshotGenerator( - HeapSnapshot* snapshot, v8::ActivityControl* control, - v8::HeapProfiler::ObjectNameResolver* resolver, - v8::HeapProfiler::ContextNameResolver* context_name_resolver, Heap* heap, - cppgc::EmbedderStackState stack_state); + HeapSnapshotGenerator(HeapSnapshot* snapshot, v8::ActivityControl* control, + v8::HeapProfiler::ContextNameResolver* resolver, + Heap* heap, cppgc::EmbedderStackState stack_state); HeapSnapshotGenerator(const HeapSnapshotGenerator&) = delete; HeapSnapshotGenerator& operator=(const HeapSnapshotGenerator&) = delete; bool GenerateSnapshot(); diff --git a/deps/v8/test/cctest/test-heap-profiler.cc b/deps/v8/test/cctest/test-heap-profiler.cc index 427ad5ce91c0..2373fbfd0381 100644 --- a/deps/v8/test/cctest/test-heap-profiler.cc +++ b/deps/v8/test/cctest/test-heap-profiler.cc @@ -2176,129 +2176,6 @@ TEST(DeleteHeapSnapshot) { CHECK(!FindHeapSnapshot(heap_profiler, s3)); } -class NameResolver : public v8::HeapProfiler::ObjectNameResolver { - public: - const char* GetName(v8::Local object) override { - return "Global object name"; - } -}; - -TEST(GlobalObjectNameSimple) { - LocalContext env; - v8::HandleScope scope(env.isolate()); - v8::HeapProfiler* heap_profiler = env.isolate()->GetHeapProfiler(); - - CompileRun("document = { URL:\"abcdefgh\" };"); - - // Allow usages of v8::HeapProfiler::ObjectNameResolver for now. - // TODO(https://crbug.com/333672197): remove. - START_ALLOW_USE_DEPRECATED() - NameResolver name_resolver; - const v8::HeapSnapshot* snapshot = - heap_profiler->TakeHeapSnapshot(nullptr, &name_resolver); - END_ALLOW_USE_DEPRECATED() - CHECK(ValidateSnapshot(snapshot)); - const v8::HeapGraphNode* native_context = GetNativeContext(snapshot); - CHECK_NOT_NULL(native_context); - CHECK_EQ(std::string("system / NativeContext / Global object name"), - std::string(GetName(native_context))); - - const v8::HeapGraphNode* global = GetGlobalObject(snapshot); - CHECK_NOT_NULL(global); - CHECK_EQ(std::string("Object (global*) / Global object name"), - std::string(GetName(global))); - - const v8::HeapGraphNode* global_proxy = GetProperty( - env.isolate(), global, v8::HeapGraphEdge::kInternal, "global_proxy"); - CHECK_NOT_NULL(global_proxy); - CHECK_EQ(std::string("Object (global) / Global object name"), - std::string(GetName(global_proxy))); -} - -TEST(GlobalObjectName) { - v8::Isolate* isolate = CcTest::isolate(); - v8::HandleScope scope(isolate); - - v8::Local global_constructor = - v8::FunctionTemplate::New(isolate); - global_constructor->SetClassName(v8_str("MyGlobal")); - - v8::Local global_template = - v8::ObjectTemplate::New(isolate, global_constructor); - LocalContext env(isolate, nullptr, global_template); - - v8::HeapProfiler* heap_profiler = env.isolate()->GetHeapProfiler(); - - CompileRun("document = { URL:\"abcdefgh\" };"); - - // Allow usages of v8::HeapProfiler::ObjectNameResolver for now. - // TODO(https://crbug.com/333672197): remove. - START_ALLOW_USE_DEPRECATED() - NameResolver name_resolver; - const v8::HeapSnapshot* snapshot = - heap_profiler->TakeHeapSnapshot(nullptr, &name_resolver); - END_ALLOW_USE_DEPRECATED() - CHECK(ValidateSnapshot(snapshot)); - const v8::HeapGraphNode* native_context = GetNativeContext(snapshot); - CHECK_NOT_NULL(native_context); - CHECK_EQ(std::string("system / NativeContext / Global object name"), - std::string(GetName(native_context))); - - const v8::HeapGraphNode* global = GetGlobalObject(snapshot, false); - CHECK_NOT_NULL(global); - CHECK_EQ(std::string("MyGlobal (global*) / Global object name"), - std::string(GetName(global))); - - const v8::HeapGraphNode* global_proxy = GetProperty( - env.isolate(), global, v8::HeapGraphEdge::kInternal, "global_proxy"); - CHECK_NOT_NULL(global_proxy); - CHECK_EQ(std::string("MyGlobal (global) / Global object name"), - std::string(GetName(global_proxy))); -} - -TEST(GlobalObjectNameDetached) { - v8::Isolate* isolate = CcTest::isolate(); - v8::HandleScope scope(isolate); - - v8::Local global_constructor = - v8::FunctionTemplate::New(isolate); - global_constructor->SetClassName(v8_str("MyGlobal")); - - v8::Local global_template = - v8::ObjectTemplate::New(isolate, global_constructor); - LocalContext env(isolate, nullptr, global_template); - - v8::HeapProfiler* heap_profiler = env.isolate()->GetHeapProfiler(); - - CompileRun("document = { URL:\"abcdefgh\" };"); - - env->DetachGlobal(); - - // Allow usages of v8::HeapProfiler::ObjectNameResolver for now. - // TODO(https://crbug.com/333672197): remove. - START_ALLOW_USE_DEPRECATED() - NameResolver name_resolver; - const v8::HeapSnapshot* snapshot = - heap_profiler->TakeHeapSnapshot(nullptr, &name_resolver); - END_ALLOW_USE_DEPRECATED() - CHECK(ValidateSnapshot(snapshot)); - const v8::HeapGraphNode* native_context = GetNativeContext(snapshot); - CHECK_NOT_NULL(native_context); - CHECK_EQ(std::string("system / NativeContext / Global object name"), - std::string(GetName(native_context))); - - const v8::HeapGraphNode* global = GetGlobalObject(snapshot, false); - CHECK_NOT_NULL(global); - CHECK_EQ(std::string("MyGlobal (global*) / Global object name"), - std::string(GetName(global))); - - const v8::HeapGraphNode* global_proxy = GetProperty( - env.isolate(), global, v8::HeapGraphEdge::kInternal, "global_proxy"); - CHECK_NOT_NULL(global_proxy); - CHECK_EQ(std::string("Object (global) / "), - std::string(GetName(global_proxy))); -} - class ContextNameResolver : public v8::HeapProfiler::ContextNameResolver { public: const char* GetName(v8::Local context) override { From db31ecbafe6374da30d65a99d646662715db52aa Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 14 Sep 2026 11:51:34 +0200 Subject: [PATCH 2/3] tools: disable fortify warnings in `test-shared` --- shell.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shell.nix b/shell.nix index 6f50142046e9..39e3fa53b9d9 100644 --- a/shell.nix +++ b/shell.nix @@ -89,6 +89,9 @@ in pkgs.mkShell { inherit nativeBuildInputs; + # `_FORTIFY_SOURCE` requires optimization, which debug builds do not have. + hardeningDisable = [ "fortify" ]; + buildInputs = builtins.attrValues sharedLibDeps ++ buildInputs From 0470c7f424b79c09943ac187c6433d1e5e23ec3d Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 14 Sep 2026 12:41:55 +0000 Subject: [PATCH 3/3] src: fix `-Wextra` warning in `WriteFileSync` `req.result` is `ssize_t` while `UV_EIO` is an enumerator, which GCC flags as mixing enumerated and non-enumerated types in a conditional expression. Assisted-by: Devin Signed-off-by: Antoine du Hamel --- src/node_file_utils.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_file_utils.cc b/src/node_file_utils.cc index ced08b1d0ff2..6c62fcee55ac 100644 --- a/src/node_file_utils.cc +++ b/src/node_file_utils.cc @@ -59,7 +59,7 @@ int WriteFileSync(const char* path, uv_buf_t* bufs, size_t buf_count) { nullptr); if (req.result <= 0) { // Error during write. // UV_EIO should not happen unless the file system is full. - int err = req.result < 0 ? req.result : UV_EIO; + int err = req.result < 0 ? static_cast(req.result) : UV_EIO; uv_fs_req_cleanup(&req); uv_fs_close(nullptr, &req, fd, nullptr); uv_fs_req_cleanup(&req);