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

Initial implementation of dedicated FixedArray processing.

FixedArrays could be shown differently based on their subtypes.

Review-Url: https://codereview.chromium.org/2208753002
Cr-Commit-Position: refs/heads/master@{#38351}
parent 1269306a
...@@ -1193,16 +1193,16 @@ void V8HeapExplorer::ExtractJSCollectionReferences(int entry, ...@@ -1193,16 +1193,16 @@ void V8HeapExplorer::ExtractJSCollectionReferences(int entry,
JSCollection::kTableOffset); JSCollection::kTableOffset);
} }
void V8HeapExplorer::ExtractJSWeakCollectionReferences(int entry,
void V8HeapExplorer::ExtractJSWeakCollectionReferences( JSWeakCollection* obj) {
int entry, JSWeakCollection* collection) { if (obj->table()->IsHashTable()) {
MarkAsWeakContainer(collection->table()); ObjectHashTable* table = ObjectHashTable::cast(obj->table());
SetInternalReference(collection, entry, TagFixedArraySubType(table, JS_WEAK_COLLECTION_SUB_TYPE);
"table", collection->table(), }
SetInternalReference(obj, entry, "table", obj->table(),
JSWeakCollection::kTableOffset); JSWeakCollection::kTableOffset);
} }
void V8HeapExplorer::ExtractContextReferences(int entry, Context* context) { void V8HeapExplorer::ExtractContextReferences(int entry, Context* context) {
if (context == context->declaration_context()) { if (context == context->declaration_context()) {
ScopeInfo* scope_info = context->closure()->shared()->scope_info(); ScopeInfo* scope_info = context->closure()->shared()->scope_info();
...@@ -1529,20 +1529,33 @@ void V8HeapExplorer::ExtractJSArrayBufferReferences( ...@@ -1529,20 +1529,33 @@ void V8HeapExplorer::ExtractJSArrayBufferReferences(
entry, "backing_store", data_entry); entry, "backing_store", data_entry);
} }
void V8HeapExplorer::ExtractFixedArrayReferences(int entry, FixedArray* array) { void V8HeapExplorer::ExtractFixedArrayReferences(int entry, FixedArray* array) {
bool is_weak = weak_containers_.Contains(array); auto it = array_types_.find(array);
if (it == array_types_.end()) {
for (int i = 0, l = array->length(); i < l; ++i) { for (int i = 0, l = array->length(); i < l; ++i) {
if (is_weak) { SetInternalReference(array, entry, i, array->get(i),
SetWeakReference(array, entry, array->OffsetOfElementAt(i));
i, array->get(i), array->OffsetOfElementAt(i));
} else {
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) { void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) {
Isolate* isolate = js_obj->GetIsolate(); Isolate* isolate = js_obj->GetIsolate();
...@@ -2128,14 +2141,12 @@ void V8HeapExplorer::TagObject(Object* obj, const char* tag) { ...@@ -2128,14 +2141,12 @@ void V8HeapExplorer::TagObject(Object* obj, const char* tag) {
} }
} }
void V8HeapExplorer::TagFixedArraySubType(const FixedArray* array,
void V8HeapExplorer::MarkAsWeakContainer(Object* object) { FixedArraySubInstanceType type) {
if (IsEssentialObject(object) && object->IsFixedArray()) { DCHECK(array_types_.find(array) == array_types_.end());
weak_containers_.Insert(object); array_types_[array] = type;
}
} }
class GlobalObjectsEnumerator : public ObjectVisitor { class GlobalObjectsEnumerator : public ObjectVisitor {
public: public:
void VisitPointers(Object** start, Object** end) override { void VisitPointers(Object** start, Object** end) override {
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_ #ifndef V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_
#define V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_ #define V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_
#include <unordered_map>
#include "include/v8-profiler.h" #include "include/v8-profiler.h"
#include "src/base/platform/time.h" #include "src/base/platform/time.h"
#include "src/objects.h" #include "src/objects.h"
...@@ -453,7 +455,8 @@ class V8HeapExplorer : public HeapEntriesAllocator { ...@@ -453,7 +455,8 @@ class V8HeapExplorer : public HeapEntriesAllocator {
VisitorSynchronization::SyncTag tag, bool is_weak, Object* child); VisitorSynchronization::SyncTag tag, bool is_weak, Object* child);
const char* GetStrongGcSubrootName(Object* object); const char* GetStrongGcSubrootName(Object* object);
void TagObject(Object* obj, const char* tag); void TagObject(Object* obj, const char* tag);
void MarkAsWeakContainer(Object* object); void TagFixedArraySubType(const FixedArray* array,
FixedArraySubInstanceType type);
HeapEntry* GetEntry(Object* obj); HeapEntry* GetEntry(Object* obj);
...@@ -466,7 +469,7 @@ class V8HeapExplorer : public HeapEntriesAllocator { ...@@ -466,7 +469,7 @@ class V8HeapExplorer : public HeapEntriesAllocator {
HeapObjectsSet objects_tags_; HeapObjectsSet objects_tags_;
HeapObjectsSet strong_gc_subroot_names_; HeapObjectsSet strong_gc_subroot_names_;
HeapObjectsSet user_roots_; HeapObjectsSet user_roots_;
HeapObjectsSet weak_containers_; std::unordered_map<const FixedArray*, FixedArraySubInstanceType> array_types_;
v8::HeapProfiler::ObjectNameResolver* global_object_name_resolver_; v8::HeapProfiler::ObjectNameResolver* global_object_name_resolver_;
std::vector<bool> marks_; std::vector<bool> marks_;
......
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