Chromium Code Reviews| Index: src/profiler/heap-snapshot-generator.cc |
| diff --git a/src/profiler/heap-snapshot-generator.cc b/src/profiler/heap-snapshot-generator.cc |
| index 7d0e95889a74f5cd866929c91b3741e4a18d3b24..6b632b9811246f442de91ad5f18c3fd2bdc1b04f 100644 |
| --- a/src/profiler/heap-snapshot-generator.cc |
| +++ b/src/profiler/heap-snapshot-generator.cc |
| @@ -1193,16 +1193,16 @@ void V8HeapExplorer::ExtractJSCollectionReferences(int entry, |
| JSCollection::kTableOffset); |
| } |
| - |
| -void V8HeapExplorer::ExtractJSWeakCollectionReferences( |
| - int entry, JSWeakCollection* collection) { |
| - MarkAsWeakContainer(collection->table()); |
| - SetInternalReference(collection, entry, |
| - "table", collection->table(), |
| +void V8HeapExplorer::ExtractJSWeakCollectionReferences(int entry, |
| + JSWeakCollection* obj) { |
| + if (obj->table()->IsHashTable()) { |
| + ObjectHashTable* table = ObjectHashTable::cast(obj->table()); |
| + TagFixedArraySubType(table, JS_WEAK_COLLECTION_SUB_TYPE); |
| + } |
| + SetInternalReference(obj, entry, "table", obj->table(), |
| JSWeakCollection::kTableOffset); |
| } |
| - |
| void V8HeapExplorer::ExtractContextReferences(int entry, Context* context) { |
| if (context == context->declaration_context()) { |
| ScopeInfo* scope_info = context->closure()->shared()->scope_info(); |
| @@ -1529,20 +1529,33 @@ void V8HeapExplorer::ExtractJSArrayBufferReferences( |
| entry, "backing_store", data_entry); |
| } |
| - |
| void V8HeapExplorer::ExtractFixedArrayReferences(int entry, FixedArray* array) { |
| - bool is_weak = weak_containers_.Contains(array); |
| - for (int i = 0, l = array->length(); i < l; ++i) { |
| - if (is_weak) { |
| - SetWeakReference(array, entry, |
| - i, array->get(i), array->OffsetOfElementAt(i)); |
| - } else { |
| - SetInternalReference(array, entry, |
| - i, array->get(i), array->OffsetOfElementAt(i)); |
| + auto it = array_types_.find(array); |
| + if (it == array_types_.end()) { |
| + for (int i = 0, l = array->length(); i < l; ++i) { |
| + SetInternalReference(array, entry, i, array->get(i), |
| + array->OffsetOfElementAt(i)); |
| } |
| + return; |
| } |
| -} |
| + switch (it->second) { |
| + 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. |
| + |
| + default: |
| + for (int i = 0, l = array->length(); i < l; ++i) { |
| + SetInternalReference(array, entry, i, array->get(i), |
| + array->OffsetOfElementAt(i)); |
| + } |
| + break; |
| + } |
| +} |
| void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) { |
| Isolate* isolate = js_obj->GetIsolate(); |
| @@ -2128,14 +2141,11 @@ void V8HeapExplorer::TagObject(Object* obj, const char* tag) { |
| } |
| } |
| - |
| -void V8HeapExplorer::MarkAsWeakContainer(Object* object) { |
| - if (IsEssentialObject(object) && object->IsFixedArray()) { |
| - weak_containers_.Insert(object); |
| - } |
| +void V8HeapExplorer::TagFixedArraySubType(const FixedArray* array, |
| + FixedArraySubInstanceType type) { |
| + array_types_[array] = type; |
|
ulan
2016/08/04 08:54:20
Maybe add a check that array is not tagged yet or
alph
2016/08/04 18:28:27
Good idea. Done.
|
| } |
| - |
| class GlobalObjectsEnumerator : public ObjectVisitor { |
| public: |
| void VisitPointers(Object** start, Object** end) override { |