Commit 73c62c84 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

profiler: Provide raw heap snapshots

Omit user roots when raw heap snapshots are used, i.e., when
the gn flag v8_enable_raw_heap_snapshots is enabled. For regular
Chrome production builds this is not the case.

Blink CL: https://crrev.com/c/1529096

Bug: chromium:936797
Change-Id: I5ae0ec1ecfab9a76352d8ce927d1c40e707262cc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1528994
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarAlexei Filippov <alph@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60351}
parent ffabcbe8
......@@ -345,6 +345,9 @@ config("features") {
}
defines +=
[ "V8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=${v8_typed_array_max_size_in_heap}" ]
if (v8_enable_raw_heap_snapshots) {
defines += [ "V8_ENABLE_RAW_HEAP_SNAPSHOTS" ]
}
if (v8_enable_future) {
defines += [ "V8_ENABLE_FUTURE" ]
}
......
......@@ -31,8 +31,12 @@ declare_args() {
# Support for backtrace_symbols on linux.
v8_enable_backtrace = ""
# Enables full heap snapshots containing internals. Used for debugging memory
# Enables raw heap snapshots containing internals. Used for debugging memory
# on platform and embedder level.
v8_enable_raw_heap_snapshots = false
# See v8_enable_raw_heap_snapshots.
# TODO(mlippautz): Remove after adjusting Blink embedder code.
v8_enable_full_heap_snapshots = false
# Enable the snapshot feature, for fast context creation.
......
......@@ -292,6 +292,12 @@ HARMONY_SHIPPING(FLAG_SHIPPING_FEATURES)
DEFINE_BOOL(icu_timezone_data, true, "get information about timezones from ICU")
#endif
#ifdef V8_ENABLE_RAW_HEAP_SNAPSHOTS
#define V8_ENABLE_RAW_HEAP_SNAPSHOTS_BOOL true
#else
#define V8_ENABLE_RAW_HEAP_SNAPSHOTS_BOOL false
#endif // V8_ENABLE_RAW_HEAP_SNAPSHOTS
#ifdef V8_LITE_MODE
#define V8_LITE_BOOL true
#else
......@@ -1536,6 +1542,9 @@ DEFINE_BOOL(unbox_double_fields, V8_DOUBLE_FIELDS_UNBOXING,
"enable in-object double fields unboxing (64-bit only)")
DEFINE_IMPLICATION(unbox_double_fields, track_double_fields)
DEFINE_BOOL(raw_heap_snapshots, V8_ENABLE_RAW_HEAP_SNAPSHOTS_BOOL,
"enable raw heap snapshots contain garbage collection internals")
DEFINE_BOOL(lite_mode, V8_LITE_BOOL,
"enables trade-off of performance for memory savings "
"(Lite mode only)")
......
......@@ -1681,6 +1681,10 @@ void V8HeapExplorer::SetGcSubrootReference(Root root, const char* description,
edge_type, description, child_entry, names_);
}
// For full heap snapshots we do not emit user roots but rather rely on
// regular GC roots to retain objects.
if (FLAG_raw_heap_snapshots) return;
// Add a shortcut to JS global object reference at snapshot root.
// That allows the user to easily find global objects. They are
// also used as starting points in distance calculations.
......@@ -1837,7 +1841,7 @@ const char* EmbedderGraphNodeName(StringsStorage* names,
}
HeapEntry::Type EmbedderGraphNodeType(EmbedderGraphImpl::Node* node) {
return HeapEntry::kNative;
return node->IsRootNode() ? HeapEntry::kSynthetic : HeapEntry::kNative;
}
// Merges the names of an embedder node and its wrapper node.
......
......@@ -1672,11 +1672,11 @@ TEST(HeapSnapshotRetainedObjectInfo) {
CHECK(ValidateSnapshot(snapshot));
const v8::HeapGraphNode* native_group_aaa =
GetNode(snapshot->GetRoot(), v8::HeapGraphNode::kNative, "aaa-group");
CHECK(native_group_aaa);
GetNode(snapshot->GetRoot(), v8::HeapGraphNode::kSynthetic, "aaa-group");
CHECK_NOT_NULL(native_group_aaa);
const v8::HeapGraphNode* native_group_ccc =
GetNode(snapshot->GetRoot(), v8::HeapGraphNode::kNative, "ccc-group");
CHECK(native_group_ccc);
GetNode(snapshot->GetRoot(), v8::HeapGraphNode::kSynthetic, "ccc-group");
CHECK_NOT_NULL(native_group_ccc);
const v8::HeapGraphNode* n_AAA =
GetNode(native_group_aaa, v8::HeapGraphNode::kString, "AAA");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment