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,
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,12 @@ 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) {
DCHECK(array_types_.find(array) == array_types_.end());
array_types_[array] = type;
}
class GlobalObjectsEnumerator : public ObjectVisitor {
public:
void VisitPointers(Object** start, Object** end) override {
......
......@@ -5,6 +5,8 @@
#ifndef V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_
#define V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_
#include <unordered_map>
#include "include/v8-profiler.h"
#include "src/base/platform/time.h"
#include "src/objects.h"
......@@ -453,7 +455,8 @@ class V8HeapExplorer : public HeapEntriesAllocator {
VisitorSynchronization::SyncTag tag, bool is_weak, Object* child);
const char* GetStrongGcSubrootName(Object* object);
void TagObject(Object* obj, const char* tag);
void MarkAsWeakContainer(Object* object);
void TagFixedArraySubType(const FixedArray* array,
FixedArraySubInstanceType type);
HeapEntry* GetEntry(Object* obj);
......@@ -466,7 +469,7 @@ class V8HeapExplorer : public HeapEntriesAllocator {
HeapObjectsSet objects_tags_;
HeapObjectsSet strong_gc_subroot_names_;
HeapObjectsSet user_roots_;
HeapObjectsSet weak_containers_;
std::unordered_map<const FixedArray*, FixedArraySubInstanceType> array_types_;
v8::HeapProfiler::ObjectNameResolver* global_object_name_resolver_;
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