Commit aba8a815 authored by alph's avatar alph Committed by Commit bot

Add WeakCell support to heap profiler.

Review-Url: https://codereview.chromium.org/2204873003
Cr-Commit-Position: refs/heads/master@{#38245}
parent 0a920f60
......@@ -1047,6 +1047,8 @@ bool V8HeapExplorer::ExtractReferencesPass1(int entry, HeapObject* obj) {
ExtractBoxReferences(entry, Box::cast(obj));
} else if (obj->IsCell()) {
ExtractCellReferences(entry, Cell::cast(obj));
} else if (obj->IsWeakCell()) {
ExtractWeakCellReferences(entry, WeakCell::cast(obj));
} else if (obj->IsPropertyCell()) {
ExtractPropertyCellReferences(entry, PropertyCell::cast(obj));
} else if (obj->IsAllocationSite()) {
......@@ -1475,16 +1477,19 @@ void V8HeapExplorer::ExtractCodeReferences(int entry, Code* code) {
}
}
void V8HeapExplorer::ExtractBoxReferences(int entry, Box* box) {
SetInternalReference(box, entry, "value", box->value(), Box::kValueOffset);
}
void V8HeapExplorer::ExtractCellReferences(int entry, Cell* cell) {
SetInternalReference(cell, entry, "value", cell->value(), Cell::kValueOffset);
}
void V8HeapExplorer::ExtractWeakCellReferences(int entry, WeakCell* weak_cell) {
TagObject(weak_cell, "(weak cell)");
SetWeakReference(weak_cell, entry, "value", weak_cell->value(),
WeakCell::kValueOffset);
}
void V8HeapExplorer::ExtractPropertyCellReferences(int entry,
PropertyCell* cell) {
......@@ -1844,6 +1849,8 @@ bool V8HeapExplorer::IsEssentialHiddenReference(Object* parent,
if (parent->IsAllocationSite() &&
field_offset == AllocationSite::kWeakNextOffset)
return false;
if (parent->IsWeakCell() && field_offset == WeakCell::kNextOffset)
return false;
// TODO(ulan): JSFunction, Code, and Context also have next weak link, which
// is non-essential. Currently they are handled as normal weak links.
// Move them here.
......
......@@ -385,6 +385,7 @@ class V8HeapExplorer : public HeapEntriesAllocator {
void ExtractCodeReferences(int entry, Code* code);
void ExtractBoxReferences(int entry, Box* box);
void ExtractCellReferences(int entry, Cell* cell);
void ExtractWeakCellReferences(int entry, WeakCell* weak_cell);
void ExtractPropertyCellReferences(int entry, PropertyCell* cell);
void ExtractAllocationSiteReferences(int entry, AllocationSite* site);
void ExtractJSArrayBufferReferences(int entry, JSArrayBuffer* buffer);
......
......@@ -692,7 +692,9 @@ TEST(HeapSnapshotMap) {
CHECK(GetProperty(map, v8::HeapGraphEdge::kInternal, "prototype"));
CHECK(GetProperty(map, v8::HeapGraphEdge::kInternal, "back_pointer"));
CHECK(GetProperty(map, v8::HeapGraphEdge::kInternal, "descriptors"));
CHECK(GetProperty(map, v8::HeapGraphEdge::kInternal, "weak_cell_cache"));
const v8::HeapGraphNode* weak_cell =
GetProperty(map, v8::HeapGraphEdge::kInternal, "weak_cell_cache");
CHECK(GetProperty(weak_cell, v8::HeapGraphEdge::kWeak, "value"));
}
TEST(HeapSnapshotInternalReferences) {
......
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