Skip to content

Commit 870a366

Browse files
isheludkoaduh95
authored andcommitted
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 <ishell@chromium.org> Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/main@{#105492} Refs: v8/v8@95efbaf PR-URL: #66020 Reviewed-By: Xuguang Mei <meixuguang@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent f8b7a2f commit 870a366

7 files changed

Lines changed: 25 additions & 235 deletions

File tree

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
# Reset this number to 0 on major V8 upgrades.
4545
# Increment by one for each non-official patch applied to deps/v8.
46-
'v8_embedder_string': '-node.33',
46+
'v8_embedder_string': '-node.34',
4747

4848
##### V8 defaults for Node.js #####
4949

deps/v8/include/v8-profiler.h

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,8 @@ class V8_EXPORT HeapProfiler {
10691069
*
10701070
* This interface will soon be deprecated in favour of ContextNameResolver.
10711071
*/
1072-
class ObjectNameResolver {
1072+
class V8_DEPRECATE_SOON("Use ContextNameResolver instead.")
1073+
ObjectNameResolver {
10731074
public:
10741075
/**
10751076
* Returns name to be used in the heap snapshot for given node. Returned
@@ -1127,24 +1128,13 @@ class V8_EXPORT HeapProfiler {
11271128
// NOLINTNEXTLINE
11281129
HeapSnapshotOptions() {}
11291130

1130-
// TODO(https://crbug.com/333672197): remove once ObjectNameResolver is
1131-
// removed.
1132-
ALLOW_COPY_AND_MOVE_WITH_DEPRECATED_FIELDS(HeapSnapshotOptions)
1133-
11341131
/**
11351132
* The control used to report intermediate progress to.
11361133
*/
11371134
ActivityControl* control = nullptr;
1138-
/**
1139-
* The resolver used by the snapshot generator to get names for V8 objects.
1140-
*/
1141-
V8_DEPRECATED("Use context_name_resolver callback instead.")
1142-
ObjectNameResolver* global_object_name_resolver = nullptr;
11431135
/**
11441136
* The resolver used by the snapshot generator to get names for v8::Context
11451137
* objects.
1146-
* In case both this and |global_object_name_resolver| callbacks are
1147-
* provided, this one will be used.
11481138
*/
11491139
ContextNameResolver* context_name_resolver = nullptr;
11501140
/**
@@ -1176,18 +1166,8 @@ class V8_EXPORT HeapProfiler {
11761166
*
11771167
* \returns the snapshot.
11781168
*/
1179-
V8_DEPRECATED("Use overload with ContextNameResolver* resolver instead.")
1180-
const HeapSnapshot* TakeHeapSnapshot(
1181-
ActivityControl* control, ObjectNameResolver* global_object_name_resolver,
1182-
bool hide_internals = true, bool capture_numeric_value = false);
1183-
const HeapSnapshot* TakeHeapSnapshot(ActivityControl* control,
1184-
ContextNameResolver* resolver,
1185-
bool hide_internals = true,
1186-
bool capture_numeric_value = false);
1187-
// TODO(333672197): remove this version once ObjectNameResolver* overload
1188-
// is removed.
11891169
const HeapSnapshot* TakeHeapSnapshot(ActivityControl* control,
1190-
std::nullptr_t resolver = nullptr,
1170+
ContextNameResolver* resolver = nullptr,
11911171
bool hide_internals = true,
11921172
bool capture_numeric_value = false);
11931173

deps/v8/src/api/api.cc

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11849,21 +11849,6 @@ const HeapSnapshot* HeapProfiler::TakeHeapSnapshot(
1184911849
reinterpret_cast<i::HeapProfiler*>(this)->TakeSnapshot(options));
1185011850
}
1185111851

11852-
const HeapSnapshot* HeapProfiler::TakeHeapSnapshot(ActivityControl* control,
11853-
ObjectNameResolver* resolver,
11854-
bool hide_internals,
11855-
bool capture_numeric_value) {
11856-
HeapSnapshotOptions options;
11857-
options.control = control;
11858-
options.global_object_name_resolver = resolver;
11859-
options.snapshot_mode = hide_internals ? HeapSnapshotMode::kRegular
11860-
: HeapSnapshotMode::kExposeInternals;
11861-
options.numerics_mode = capture_numeric_value
11862-
? NumericsMode::kExposeNumericValues
11863-
: NumericsMode::kHideNumericValues;
11864-
return TakeHeapSnapshot(options);
11865-
}
11866-
1186711852
const HeapSnapshot* HeapProfiler::TakeHeapSnapshot(
1186811853
ActivityControl* control, ContextNameResolver* resolver,
1186911854
bool hide_internals, bool capture_numeric_value) {
@@ -11878,20 +11863,6 @@ const HeapSnapshot* HeapProfiler::TakeHeapSnapshot(
1187811863
return TakeHeapSnapshot(options);
1187911864
}
1188011865

11881-
const HeapSnapshot* HeapProfiler::TakeHeapSnapshot(ActivityControl* control,
11882-
std::nullptr_t resolver,
11883-
bool hide_internals,
11884-
bool capture_numeric_value) {
11885-
HeapSnapshotOptions options;
11886-
options.control = control;
11887-
options.snapshot_mode = hide_internals ? HeapSnapshotMode::kRegular
11888-
: HeapSnapshotMode::kExposeInternals;
11889-
options.numerics_mode = capture_numeric_value
11890-
? NumericsMode::kExposeNumericValues
11891-
: NumericsMode::kHideNumericValues;
11892-
return TakeHeapSnapshot(options);
11893-
}
11894-
1189511866
std::vector<v8::Local<v8::Value>> HeapProfiler::GetDetachedJSWrapperObjects() {
1189611867
return reinterpret_cast<i::HeapProfiler*>(this)
1189711868
->GetDetachedJSWrapperObjects();

deps/v8/src/profiler/heap-profiler.cc

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,9 @@ HeapSnapshot* HeapProfiler::TakeSnapshot(
146146
use_cpp_class_name.emplace(heap()->cpp_heap());
147147
}
148148

149-
// Allow usages of v8::HeapProfiler::ObjectNameResolver for now.
150-
// TODO(https://crbug.com/333672197): remove.
151-
START_ALLOW_USE_DEPRECATED()
152-
HeapSnapshotGenerator generator(
153-
result, options.control, options.global_object_name_resolver,
154-
options.context_name_resolver, heap(), options.stack_state);
155-
END_ALLOW_USE_DEPRECATED()
149+
HeapSnapshotGenerator generator(result, options.control,
150+
options.context_name_resolver, heap(),
151+
options.stack_state);
156152
if (!generator.GenerateSnapshot()) {
157153
delete result;
158154
result = nullptr;
@@ -186,13 +182,9 @@ void HeapProfiler::WriteSnapshotToDiskAfterGC(HeapSnapshotMode snapshot_mode) {
186182
v8::HeapProfiler::HeapSnapshotOptions options;
187183
std::unique_ptr<HeapSnapshot> result(
188184
new HeapSnapshot(this, snapshot_mode, options.numerics_mode));
189-
// Allow usages of v8::HeapProfiler::ObjectNameResolver for now.
190-
// TODO(https://crbug.com/333672197): remove.
191-
START_ALLOW_USE_DEPRECATED()
192-
HeapSnapshotGenerator generator(
193-
result.get(), options.control, options.global_object_name_resolver,
194-
options.context_name_resolver, heap(), options.stack_state);
195-
END_ALLOW_USE_DEPRECATED()
185+
HeapSnapshotGenerator generator(result.get(), options.control,
186+
options.context_name_resolver, heap(),
187+
options.stack_state);
196188
if (!generator.GenerateSnapshotAfterGC()) return;
197189
i::FileOutputStream stream(filename.c_str());
198190
if (stream.IsOpen()) {

deps/v8/src/profiler/heap-snapshot-generator.cc

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -823,18 +823,16 @@ void HeapObjectsMap::RemoveDeadEntries() {
823823
entries_map_.occupancy());
824824
}
825825

826-
V8HeapExplorer::V8HeapExplorer(
827-
HeapSnapshot* snapshot, SnapshottingProgressReportingInterface* progress,
828-
v8::HeapProfiler::ObjectNameResolver* resolver,
829-
v8::HeapProfiler::ContextNameResolver* context_resolver)
826+
V8HeapExplorer::V8HeapExplorer(HeapSnapshot* snapshot,
827+
SnapshottingProgressReportingInterface* progress,
828+
v8::HeapProfiler::ContextNameResolver* resolver)
830829
: heap_(snapshot->profiler()->heap_object_map()->heap()),
831830
snapshot_(snapshot),
832831
names_(snapshot_->profiler()->names()),
833832
heap_object_map_(snapshot_->profiler()->heap_object_map()),
834833
progress_(progress),
835834
generator_(nullptr),
836-
global_object_name_resolver_(resolver),
837-
native_context_name_resolver_(context_resolver) {}
835+
native_context_name_resolver_(resolver) {}
838836

839837
HeapEntry* V8HeapExplorer::AllocateEntry(HeapThing ptr) {
840838
return AddEntry(
@@ -3020,43 +3018,20 @@ class NativeContextEnumerator : public RootVisitor {
30203018

30213019
V8HeapExplorer::TemporaryNativeContextTags
30223020
V8HeapExplorer::CollectTemporaryNativeContextTags() {
3023-
if (!global_object_name_resolver_ && !native_context_name_resolver_) {
3024-
return {};
3025-
}
3021+
if (!native_context_name_resolver_) return {};
30263022

30273023
Isolate* isolate = heap_->isolate();
30283024
TemporaryNativeContextTags native_context_tags;
30293025
HandleScope scope(isolate);
30303026
NativeContextEnumerator enumerator(
30313027
isolate, [this, isolate, &native_context_tags](
30323028
DirectHandle<NativeContext> native_context) {
3033-
if (native_context_name_resolver_) {
3034-
v8::Local<v8::Context> context = Utils::ToLocal(native_context);
3035-
if (const char* tag =
3036-
native_context_name_resolver_->GetName(context)) {
3037-
native_context_tags.emplace_back(
3038-
Global<v8::Context>(reinterpret_cast<v8::Isolate*>(isolate),
3039-
context),
3040-
tag);
3041-
native_context_tags.back().first.SetWeak();
3042-
}
3043-
return;
3044-
}
3045-
3046-
DirectHandle<JSObject> global(native_context->global_object(), isolate);
3047-
if (const char* tag =
3048-
global_object_name_resolver_->GetName(Utils::ToLocal(global))) {
3049-
native_context_tags.emplace_back(
3050-
Global<v8::Context>(reinterpret_cast<v8::Isolate*>(isolate),
3051-
Utils::ToLocal(native_context)),
3052-
tag);
3053-
native_context_tags.back().first.SetWeak();
3054-
return;
3055-
}
3029+
v8::Local<v8::Context> context = Utils::ToLocal(native_context);
3030+
const char* tag = native_context_name_resolver_->GetName(context);
30563031
native_context_tags.emplace_back(
30573032
Global<v8::Context>(reinterpret_cast<v8::Isolate*>(isolate),
3058-
Utils::ToLocal(native_context)),
3059-
nullptr);
3033+
context),
3034+
tag);
30603035
native_context_tags.back().first.SetWeak();
30613036
});
30623037
isolate->global_handles()->IterateAllRoots(&enumerator);
@@ -3364,12 +3339,11 @@ bool NativeObjectsExplorer::IterateAndExtractReferences(
33643339

33653340
HeapSnapshotGenerator::HeapSnapshotGenerator(
33663341
HeapSnapshot* snapshot, v8::ActivityControl* control,
3367-
v8::HeapProfiler::ObjectNameResolver* resolver,
3368-
v8::HeapProfiler::ContextNameResolver* context_resolver, Heap* heap,
3342+
v8::HeapProfiler::ContextNameResolver* resolver, Heap* heap,
33693343
cppgc::EmbedderStackState stack_state)
33703344
: snapshot_(snapshot),
33713345
control_(control),
3372-
v8_heap_explorer_(snapshot_, this, resolver, context_resolver),
3346+
v8_heap_explorer_(snapshot_, this, resolver),
33733347
dom_explorer_(snapshot_, this),
33743348
heap_(heap),
33753349
stack_state_(stack_state) {}

deps/v8/src/profiler/heap-snapshot-generator.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,7 @@ class V8_EXPORT_PRIVATE V8HeapExplorer : public HeapEntriesAllocator {
413413
public:
414414
V8HeapExplorer(HeapSnapshot* snapshot,
415415
SnapshottingProgressReportingInterface* progress,
416-
v8::HeapProfiler::ObjectNameResolver* resolver,
417-
v8::HeapProfiler::ContextNameResolver* context_resolver);
416+
v8::HeapProfiler::ContextNameResolver* resolver);
418417
~V8HeapExplorer() override = default;
419418
V8HeapExplorer(const V8HeapExplorer&) = delete;
420419
V8HeapExplorer& operator=(const V8HeapExplorer&) = delete;
@@ -610,7 +609,6 @@ class V8_EXPORT_PRIVATE V8HeapExplorer : public HeapEntriesAllocator {
610609
native_context_tag_map_;
611610
UnorderedHeapObjectMap<const char*> strong_gc_subroot_names_;
612611
std::unordered_set<Tagged<NativeContext>, Object::Hasher> user_roots_;
613-
v8::HeapProfiler::ObjectNameResolver* global_object_name_resolver_;
614612
v8::HeapProfiler::ContextNameResolver* native_context_name_resolver_;
615613

616614
std::vector<bool> visited_fields_;
@@ -660,11 +658,9 @@ class HeapSnapshotGenerator : public SnapshottingProgressReportingInterface {
660658
// their representations in heap snapshots.
661659
using SmiEntriesMap = std::unordered_map<int, HeapEntry*>;
662660

663-
HeapSnapshotGenerator(
664-
HeapSnapshot* snapshot, v8::ActivityControl* control,
665-
v8::HeapProfiler::ObjectNameResolver* resolver,
666-
v8::HeapProfiler::ContextNameResolver* context_name_resolver, Heap* heap,
667-
cppgc::EmbedderStackState stack_state);
661+
HeapSnapshotGenerator(HeapSnapshot* snapshot, v8::ActivityControl* control,
662+
v8::HeapProfiler::ContextNameResolver* resolver,
663+
Heap* heap, cppgc::EmbedderStackState stack_state);
668664
HeapSnapshotGenerator(const HeapSnapshotGenerator&) = delete;
669665
HeapSnapshotGenerator& operator=(const HeapSnapshotGenerator&) = delete;
670666
bool GenerateSnapshot();

deps/v8/test/cctest/test-heap-profiler.cc

Lines changed: 0 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -2176,129 +2176,6 @@ TEST(DeleteHeapSnapshot) {
21762176
CHECK(!FindHeapSnapshot(heap_profiler, s3));
21772177
}
21782178

2179-
class NameResolver : public v8::HeapProfiler::ObjectNameResolver {
2180-
public:
2181-
const char* GetName(v8::Local<v8::Object> object) override {
2182-
return "Global object name";
2183-
}
2184-
};
2185-
2186-
TEST(GlobalObjectNameSimple) {
2187-
LocalContext env;
2188-
v8::HandleScope scope(env.isolate());
2189-
v8::HeapProfiler* heap_profiler = env.isolate()->GetHeapProfiler();
2190-
2191-
CompileRun("document = { URL:\"abcdefgh\" };");
2192-
2193-
// Allow usages of v8::HeapProfiler::ObjectNameResolver for now.
2194-
// TODO(https://crbug.com/333672197): remove.
2195-
START_ALLOW_USE_DEPRECATED()
2196-
NameResolver name_resolver;
2197-
const v8::HeapSnapshot* snapshot =
2198-
heap_profiler->TakeHeapSnapshot(nullptr, &name_resolver);
2199-
END_ALLOW_USE_DEPRECATED()
2200-
CHECK(ValidateSnapshot(snapshot));
2201-
const v8::HeapGraphNode* native_context = GetNativeContext(snapshot);
2202-
CHECK_NOT_NULL(native_context);
2203-
CHECK_EQ(std::string("system / NativeContext / Global object name"),
2204-
std::string(GetName(native_context)));
2205-
2206-
const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
2207-
CHECK_NOT_NULL(global);
2208-
CHECK_EQ(std::string("Object (global*) / Global object name"),
2209-
std::string(GetName(global)));
2210-
2211-
const v8::HeapGraphNode* global_proxy = GetProperty(
2212-
env.isolate(), global, v8::HeapGraphEdge::kInternal, "global_proxy");
2213-
CHECK_NOT_NULL(global_proxy);
2214-
CHECK_EQ(std::string("Object (global) / Global object name"),
2215-
std::string(GetName(global_proxy)));
2216-
}
2217-
2218-
TEST(GlobalObjectName) {
2219-
v8::Isolate* isolate = CcTest::isolate();
2220-
v8::HandleScope scope(isolate);
2221-
2222-
v8::Local<v8::FunctionTemplate> global_constructor =
2223-
v8::FunctionTemplate::New(isolate);
2224-
global_constructor->SetClassName(v8_str("MyGlobal"));
2225-
2226-
v8::Local<v8::ObjectTemplate> global_template =
2227-
v8::ObjectTemplate::New(isolate, global_constructor);
2228-
LocalContext env(isolate, nullptr, global_template);
2229-
2230-
v8::HeapProfiler* heap_profiler = env.isolate()->GetHeapProfiler();
2231-
2232-
CompileRun("document = { URL:\"abcdefgh\" };");
2233-
2234-
// Allow usages of v8::HeapProfiler::ObjectNameResolver for now.
2235-
// TODO(https://crbug.com/333672197): remove.
2236-
START_ALLOW_USE_DEPRECATED()
2237-
NameResolver name_resolver;
2238-
const v8::HeapSnapshot* snapshot =
2239-
heap_profiler->TakeHeapSnapshot(nullptr, &name_resolver);
2240-
END_ALLOW_USE_DEPRECATED()
2241-
CHECK(ValidateSnapshot(snapshot));
2242-
const v8::HeapGraphNode* native_context = GetNativeContext(snapshot);
2243-
CHECK_NOT_NULL(native_context);
2244-
CHECK_EQ(std::string("system / NativeContext / Global object name"),
2245-
std::string(GetName(native_context)));
2246-
2247-
const v8::HeapGraphNode* global = GetGlobalObject(snapshot, false);
2248-
CHECK_NOT_NULL(global);
2249-
CHECK_EQ(std::string("MyGlobal (global*) / Global object name"),
2250-
std::string(GetName(global)));
2251-
2252-
const v8::HeapGraphNode* global_proxy = GetProperty(
2253-
env.isolate(), global, v8::HeapGraphEdge::kInternal, "global_proxy");
2254-
CHECK_NOT_NULL(global_proxy);
2255-
CHECK_EQ(std::string("MyGlobal (global) / Global object name"),
2256-
std::string(GetName(global_proxy)));
2257-
}
2258-
2259-
TEST(GlobalObjectNameDetached) {
2260-
v8::Isolate* isolate = CcTest::isolate();
2261-
v8::HandleScope scope(isolate);
2262-
2263-
v8::Local<v8::FunctionTemplate> global_constructor =
2264-
v8::FunctionTemplate::New(isolate);
2265-
global_constructor->SetClassName(v8_str("MyGlobal"));
2266-
2267-
v8::Local<v8::ObjectTemplate> global_template =
2268-
v8::ObjectTemplate::New(isolate, global_constructor);
2269-
LocalContext env(isolate, nullptr, global_template);
2270-
2271-
v8::HeapProfiler* heap_profiler = env.isolate()->GetHeapProfiler();
2272-
2273-
CompileRun("document = { URL:\"abcdefgh\" };");
2274-
2275-
env->DetachGlobal();
2276-
2277-
// Allow usages of v8::HeapProfiler::ObjectNameResolver for now.
2278-
// TODO(https://crbug.com/333672197): remove.
2279-
START_ALLOW_USE_DEPRECATED()
2280-
NameResolver name_resolver;
2281-
const v8::HeapSnapshot* snapshot =
2282-
heap_profiler->TakeHeapSnapshot(nullptr, &name_resolver);
2283-
END_ALLOW_USE_DEPRECATED()
2284-
CHECK(ValidateSnapshot(snapshot));
2285-
const v8::HeapGraphNode* native_context = GetNativeContext(snapshot);
2286-
CHECK_NOT_NULL(native_context);
2287-
CHECK_EQ(std::string("system / NativeContext / Global object name"),
2288-
std::string(GetName(native_context)));
2289-
2290-
const v8::HeapGraphNode* global = GetGlobalObject(snapshot, false);
2291-
CHECK_NOT_NULL(global);
2292-
CHECK_EQ(std::string("MyGlobal (global*) / Global object name"),
2293-
std::string(GetName(global)));
2294-
2295-
const v8::HeapGraphNode* global_proxy = GetProperty(
2296-
env.isolate(), global, v8::HeapGraphEdge::kInternal, "global_proxy");
2297-
CHECK_NOT_NULL(global_proxy);
2298-
CHECK_EQ(std::string("Object (global) / <detached>"),
2299-
std::string(GetName(global_proxy)));
2300-
}
2301-
23022179
class ContextNameResolver : public v8::HeapProfiler::ContextNameResolver {
23032180
public:
23042181
const char* GetName(v8::Local<v8::Context> context) override {

0 commit comments

Comments
 (0)