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

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

This reverts commit c34042cc.

Reason for revert: Wrong table type was used

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,alph@chromium.org,mlippautz@chromium.org

Change-Id: Ia2ddef5b2422d4cbb8c4710e24ed0885a9a5b284
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chomium:773722
Reviewed-on: https://chromium-review.googlesource.com/740721Reviewed-by: 's avatarAlexei Filippov <alph@chromium.org>
Commit-Queue: Alexei Filippov <alph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48986}
parent c34042cc
......@@ -597,15 +597,17 @@ class WeakHashTable : public HashTable<WeakHashTable, WeakHashTableShape<2>> {
Handle<HeapObject> key,
Handle<HeapObject> value);
// Returns the index to the value of an entry.
static inline int EntryToValueIndex(int entry) {
return EntryToIndex(entry) + 1;
}
static Handle<FixedArray> GetValues(Handle<WeakHashTable> table);
private:
friend class MarkCompactCollector;
void AddEntry(int entry, Handle<WeakCell> key, Handle<HeapObject> value);
// Returns the index to the value of an entry.
static inline int EntryToValueIndex(int entry) {
return EntryToIndex(entry) + 1;
}
};
// This is similar to the OrderedHashTable, except for the memory
......
......@@ -1345,21 +1345,12 @@ void V8HeapExplorer::ExtractFixedArrayReferences(int entry, FixedArray* array) {
return;
}
switch (it->second) {
case JS_WEAK_COLLECTION_SUB_TYPE: {
WeakHashTable* table = WeakHashTable::cast(array);
for (int i = 0, capacity = table->Capacity(); i < capacity; ++i) {
int key_index =
WeakHashTable::EntryToIndex(i) + WeakHashTable::kEntryKeyIndex;
int value_index = WeakHashTable::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
case JS_WEAK_COLLECTION_SUB_TYPE:
for (int i = 0, l = array->length(); i < l; ++i) {
SetWeakReference(array, entry, i, array->get(i),
array->OffsetOfElementAt(i));
}
break;
}
// TODO(alph): Add special processing for other types of FixedArrays.
......
......@@ -558,7 +558,7 @@ TEST(HeapSnapshotWeakCollection) {
++weak_entries;
}
}
CHECK_EQ(1, weak_entries); // Key is the only weak.
CHECK_EQ(2, weak_entries);
const v8::HeapGraphNode* wm_s =
GetProperty(env->GetIsolate(), wm, v8::HeapGraphEdge::kProperty, "str");
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