Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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 #####

Expand Down
26 changes: 3 additions & 23 deletions deps/v8/include/v8-profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
/**
Expand Down Expand Up @@ -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);

Expand Down
29 changes: 0 additions & 29 deletions deps/v8/src/api/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11849,21 +11849,6 @@ const HeapSnapshot* HeapProfiler::TakeHeapSnapshot(
reinterpret_cast<i::HeapProfiler*>(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) {
Expand All @@ -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<v8::Local<v8::Value>> HeapProfiler::GetDetachedJSWrapperObjects() {
return reinterpret_cast<i::HeapProfiler*>(this)
->GetDetachedJSWrapperObjects();
Expand Down
20 changes: 6 additions & 14 deletions deps/v8/src/profiler/heap-profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -186,13 +182,9 @@ void HeapProfiler::WriteSnapshotToDiskAfterGC(HeapSnapshotMode snapshot_mode) {
v8::HeapProfiler::HeapSnapshotOptions options;
std::unique_ptr<HeapSnapshot> 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()) {
Expand Down
48 changes: 11 additions & 37 deletions deps/v8/src/profiler/heap-snapshot-generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -3020,43 +3018,20 @@ 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;
HandleScope scope(isolate);
NativeContextEnumerator enumerator(
isolate, [this, isolate, &native_context_tags](
DirectHandle<NativeContext> native_context) {
if (native_context_name_resolver_) {
v8::Local<v8::Context> context = Utils::ToLocal(native_context);
if (const char* tag =
native_context_name_resolver_->GetName(context)) {
native_context_tags.emplace_back(
Global<v8::Context>(reinterpret_cast<v8::Isolate*>(isolate),
context),
tag);
native_context_tags.back().first.SetWeak();
}
return;
}

DirectHandle<JSObject> global(native_context->global_object(), isolate);
if (const char* tag =
global_object_name_resolver_->GetName(Utils::ToLocal(global))) {
native_context_tags.emplace_back(
Global<v8::Context>(reinterpret_cast<v8::Isolate*>(isolate),
Utils::ToLocal(native_context)),
tag);
native_context_tags.back().first.SetWeak();
return;
}
v8::Local<v8::Context> context = Utils::ToLocal(native_context);
const char* tag = native_context_name_resolver_->GetName(context);
native_context_tags.emplace_back(
Global<v8::Context>(reinterpret_cast<v8::Isolate*>(isolate),
Utils::ToLocal(native_context)),
nullptr);
context),
tag);
native_context_tags.back().first.SetWeak();
});
isolate->global_handles()->IterateAllRoots(&enumerator);
Expand Down Expand Up @@ -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) {}
Expand Down
12 changes: 4 additions & 8 deletions deps/v8/src/profiler/heap-snapshot-generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -610,7 +609,6 @@ class V8_EXPORT_PRIVATE V8HeapExplorer : public HeapEntriesAllocator {
native_context_tag_map_;
UnorderedHeapObjectMap<const char*> strong_gc_subroot_names_;
std::unordered_set<Tagged<NativeContext>, Object::Hasher> user_roots_;
v8::HeapProfiler::ObjectNameResolver* global_object_name_resolver_;
v8::HeapProfiler::ContextNameResolver* native_context_name_resolver_;

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

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();
Expand Down
123 changes: 0 additions & 123 deletions deps/v8/test/cctest/test-heap-profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2176,129 +2176,6 @@ TEST(DeleteHeapSnapshot) {
CHECK(!FindHeapSnapshot(heap_profiler, s3));
}

class NameResolver : public v8::HeapProfiler::ObjectNameResolver {
public:
const char* GetName(v8::Local<v8::Object> 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<v8::FunctionTemplate> global_constructor =
v8::FunctionTemplate::New(isolate);
global_constructor->SetClassName(v8_str("MyGlobal"));

v8::Local<v8::ObjectTemplate> 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<v8::FunctionTemplate> global_constructor =
v8::FunctionTemplate::New(isolate);
global_constructor->SetClassName(v8_str("MyGlobal"));

v8::Local<v8::ObjectTemplate> 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) / <detached>"),
std::string(GetName(global_proxy)));
}

class ContextNameResolver : public v8::HeapProfiler::ContextNameResolver {
public:
const char* GetName(v8::Local<v8::Context> context) override {
Expand Down
Loading
Loading