Commit e8636cd7 authored by Alexei Filippov's avatar Alexei Filippov Committed by Commit Bot

Reland "[heap-profiler] Do not treat WeakMap values as weak."

This is a reland of c34042cc
Original change's description:
> [heap-profiler] Do not treat WeakMap values as weak.
> 
> For the WeakHashTable objects only mark keys as weak while leaving values as strong references.
> 
> BUG=chomium:773722
> 
> Change-Id: Iabd5ba293d05fe68a2af6503fcdd711ecc182482
> Reviewed-on: https://chromium-review.googlesource.com/730771
> Commit-Queue: Alexei Filippov <alph@chromium.org>
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#48985}

TBR=ulan@chromium.org

Bug: chomium:773722
Change-Id: Icede16fde528d147cde5c3f6c72f2029876b099f
Reviewed-on: https://chromium-review.googlesource.com/740722Reviewed-by: 's avatarAlexei Filippov <alph@chromium.org>
Commit-Queue: Alexei Filippov <alph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48987}
parent f5a3b75f
...@@ -597,8 +597,6 @@ class WeakHashTable : public HashTable<WeakHashTable, WeakHashTableShape<2>> { ...@@ -597,8 +597,6 @@ class WeakHashTable : public HashTable<WeakHashTable, WeakHashTableShape<2>> {
Handle<HeapObject> key, Handle<HeapObject> key,
Handle<HeapObject> value); Handle<HeapObject> value);
static Handle<FixedArray> GetValues(Handle<WeakHashTable> table);
private: private:
friend class MarkCompactCollector; friend class MarkCompactCollector;
......
...@@ -1345,12 +1345,21 @@ void V8HeapExplorer::ExtractFixedArrayReferences(int entry, FixedArray* array) { ...@@ -1345,12 +1345,21 @@ void V8HeapExplorer::ExtractFixedArrayReferences(int entry, FixedArray* array) {
return; return;
} }
switch (it->second) { switch (it->second) {
case JS_WEAK_COLLECTION_SUB_TYPE: case JS_WEAK_COLLECTION_SUB_TYPE: {
for (int i = 0, l = array->length(); i < l; ++i) { ObjectHashTable* table = ObjectHashTable::cast(array);
SetWeakReference(array, entry, i, array->get(i), for (int i = 0, capacity = table->Capacity(); i < capacity; ++i) {
array->OffsetOfElementAt(i)); int key_index =
ObjectHashTable::EntryToIndex(i) + ObjectHashTable::kEntryKeyIndex;
int value_index = ObjectHashTable::EntryToValueIndex(i);
SetWeakReference(table, entry, key_index, table->get(key_index),
table->OffsetOfElementAt(key_index));
SetInternalReference(table, entry, value_index, table->get(value_index),
table->OffsetOfElementAt(value_index));
// TODO(alph): Add a strong link (shortcut?) from key to value per
// WeakMap the key was added to. See crbug.com/778739
} }
break; break;
}
// TODO(alph): Add special processing for other types of FixedArrays. // TODO(alph): Add special processing for other types of FixedArrays.
......
...@@ -558,7 +558,7 @@ TEST(HeapSnapshotWeakCollection) { ...@@ -558,7 +558,7 @@ TEST(HeapSnapshotWeakCollection) {
++weak_entries; ++weak_entries;
} }
} }
CHECK_EQ(2, weak_entries); CHECK_EQ(1, weak_entries); // Key is the only weak.
const v8::HeapGraphNode* wm_s = const v8::HeapGraphNode* wm_s =
GetProperty(env->GetIsolate(), wm, v8::HeapGraphEdge::kProperty, "str"); GetProperty(env->GetIsolate(), wm, v8::HeapGraphEdge::kProperty, "str");
CHECK(wm_s); CHECK(wm_s);
......
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