Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Unified Diff: src/profiler/heap-snapshot-generator.cc

Issue 2208753002: Initial implementation of dedicated FixedArray processing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: adding a DCHECK Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/profiler/heap-snapshot-generator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..76ce5e6226b566818f091a78c2489e088772d11b 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,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 {
« no previous file with comments | « src/profiler/heap-snapshot-generator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698