Chromium Code Reviews

Side by Side 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.
Jump to:
View unified diff |
« no previous file with comments | « src/profiler/heap-snapshot-generator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/profiler/heap-snapshot-generator.h" 5 #include "src/profiler/heap-snapshot-generator.h"
6 6
7 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/conversions.h" 8 #include "src/conversions.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/objects-body-descriptors.h" 10 #include "src/objects-body-descriptors.h"
(...skipping 1175 matching lines...)
1186 Symbol::kNameOffset); 1186 Symbol::kNameOffset);
1187 } 1187 }
1188 1188
1189 1189
1190 void V8HeapExplorer::ExtractJSCollectionReferences(int entry, 1190 void V8HeapExplorer::ExtractJSCollectionReferences(int entry,
1191 JSCollection* collection) { 1191 JSCollection* collection) {
1192 SetInternalReference(collection, entry, "table", collection->table(), 1192 SetInternalReference(collection, entry, "table", collection->table(),
1193 JSCollection::kTableOffset); 1193 JSCollection::kTableOffset);
1194 } 1194 }
1195 1195
1196 1196 void V8HeapExplorer::ExtractJSWeakCollectionReferences(int entry,
1197 void V8HeapExplorer::ExtractJSWeakCollectionReferences( 1197 JSWeakCollection* obj) {
1198 int entry, JSWeakCollection* collection) { 1198 if (obj->table()->IsHashTable()) {
1199 MarkAsWeakContainer(collection->table()); 1199 ObjectHashTable* table = ObjectHashTable::cast(obj->table());
1200 SetInternalReference(collection, entry, 1200 TagFixedArraySubType(table, JS_WEAK_COLLECTION_SUB_TYPE);
1201 "table", collection->table(), 1201 }
1202 SetInternalReference(obj, entry, "table", obj->table(),
1202 JSWeakCollection::kTableOffset); 1203 JSWeakCollection::kTableOffset);
1203 } 1204 }
1204 1205
1205
1206 void V8HeapExplorer::ExtractContextReferences(int entry, Context* context) { 1206 void V8HeapExplorer::ExtractContextReferences(int entry, Context* context) {
1207 if (context == context->declaration_context()) { 1207 if (context == context->declaration_context()) {
1208 ScopeInfo* scope_info = context->closure()->shared()->scope_info(); 1208 ScopeInfo* scope_info = context->closure()->shared()->scope_info();
1209 // Add context allocated locals. 1209 // Add context allocated locals.
1210 int context_locals = scope_info->ContextLocalCount(); 1210 int context_locals = scope_info->ContextLocalCount();
1211 for (int i = 0; i < context_locals; ++i) { 1211 for (int i = 0; i < context_locals; ++i) {
1212 String* local_name = scope_info->ContextLocalName(i); 1212 String* local_name = scope_info->ContextLocalName(i);
1213 int idx = Context::MIN_CONTEXT_SLOTS + i; 1213 int idx = Context::MIN_CONTEXT_SLOTS + i;
1214 SetContextReference(context, entry, local_name, context->get(idx), 1214 SetContextReference(context, entry, local_name, context->get(idx),
1215 Context::OffsetOfElementAt(idx)); 1215 Context::OffsetOfElementAt(idx));
(...skipping 306 matching lines...)
1522 if (!buffer->backing_store()) 1522 if (!buffer->backing_store())
1523 return; 1523 return;
1524 size_t data_size = NumberToSize(heap_->isolate(), buffer->byte_length()); 1524 size_t data_size = NumberToSize(heap_->isolate(), buffer->byte_length());
1525 JSArrayBufferDataEntryAllocator allocator(data_size, this); 1525 JSArrayBufferDataEntryAllocator allocator(data_size, this);
1526 HeapEntry* data_entry = 1526 HeapEntry* data_entry =
1527 filler_->FindOrAddEntry(buffer->backing_store(), &allocator); 1527 filler_->FindOrAddEntry(buffer->backing_store(), &allocator);
1528 filler_->SetNamedReference(HeapGraphEdge::kInternal, 1528 filler_->SetNamedReference(HeapGraphEdge::kInternal,
1529 entry, "backing_store", data_entry); 1529 entry, "backing_store", data_entry);
1530 } 1530 }
1531 1531
1532 void V8HeapExplorer::ExtractFixedArrayReferences(int entry, FixedArray* array) {
1533 auto it = array_types_.find(array);
1534 if (it == array_types_.end()) {
1535 for (int i = 0, l = array->length(); i < l; ++i) {
1536 SetInternalReference(array, entry, i, array->get(i),
1537 array->OffsetOfElementAt(i));
1538 }
1539 return;
1540 }
1541 switch (it->second) {
1542 case JS_WEAK_COLLECTION_SUB_TYPE:
1543 for (int i = 0, l = array->length(); i < l; ++i) {
1544 SetWeakReference(array, entry, i, array->get(i),
1545 array->OffsetOfElementAt(i));
1546 }
1547 break;
1532 1548
1533 void V8HeapExplorer::ExtractFixedArrayReferences(int entry, FixedArray* array) { 1549 // TODO(alph): Add special processing for other types of FixedArrays.
1534 bool is_weak = weak_containers_.Contains(array); 1550
1535 for (int i = 0, l = array->length(); i < l; ++i) { 1551 default:
1536 if (is_weak) { 1552 for (int i = 0, l = array->length(); i < l; ++i) {
1537 SetWeakReference(array, entry, 1553 SetInternalReference(array, entry, i, array->get(i),
1538 i, array->get(i), array->OffsetOfElementAt(i)); 1554 array->OffsetOfElementAt(i));
1539 } else { 1555 }
1540 SetInternalReference(array, entry, 1556 break;
1541 i, array->get(i), array->OffsetOfElementAt(i));
1542 }
1543 } 1557 }
1544 } 1558 }
1545 1559
1546
1547 void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) { 1560 void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) {
1548 Isolate* isolate = js_obj->GetIsolate(); 1561 Isolate* isolate = js_obj->GetIsolate();
1549 if (js_obj->HasFastProperties()) { 1562 if (js_obj->HasFastProperties()) {
1550 DescriptorArray* descs = js_obj->map()->instance_descriptors(); 1563 DescriptorArray* descs = js_obj->map()->instance_descriptors();
1551 int real_size = js_obj->map()->NumberOfOwnDescriptors(); 1564 int real_size = js_obj->map()->NumberOfOwnDescriptors();
1552 for (int i = 0; i < real_size; i++) { 1565 for (int i = 0; i < real_size; i++) {
1553 PropertyDetails details = descs->GetDetails(i); 1566 PropertyDetails details = descs->GetDetails(i);
1554 switch (details.location()) { 1567 switch (details.location()) {
1555 case kField: { 1568 case kField: {
1556 Representation r = details.representation(); 1569 Representation r = details.representation();
(...skipping 564 matching lines...)
2121 2134
2122 void V8HeapExplorer::TagObject(Object* obj, const char* tag) { 2135 void V8HeapExplorer::TagObject(Object* obj, const char* tag) {
2123 if (IsEssentialObject(obj)) { 2136 if (IsEssentialObject(obj)) {
2124 HeapEntry* entry = GetEntry(obj); 2137 HeapEntry* entry = GetEntry(obj);
2125 if (entry->name()[0] == '\0') { 2138 if (entry->name()[0] == '\0') {
2126 entry->set_name(tag); 2139 entry->set_name(tag);
2127 } 2140 }
2128 } 2141 }
2129 } 2142 }
2130 2143
2131 2144 void V8HeapExplorer::TagFixedArraySubType(const FixedArray* array,
2132 void V8HeapExplorer::MarkAsWeakContainer(Object* object) { 2145 FixedArraySubInstanceType type) {
2133 if (IsEssentialObject(object) && object->IsFixedArray()) { 2146 DCHECK(array_types_.find(array) == array_types_.end());
2134 weak_containers_.Insert(object); 2147 array_types_[array] = type;
2135 }
2136 } 2148 }
2137 2149
2138
2139 class GlobalObjectsEnumerator : public ObjectVisitor { 2150 class GlobalObjectsEnumerator : public ObjectVisitor {
2140 public: 2151 public:
2141 void VisitPointers(Object** start, Object** end) override { 2152 void VisitPointers(Object** start, Object** end) override {
2142 for (Object** p = start; p < end; p++) { 2153 for (Object** p = start; p < end; p++) {
2143 if ((*p)->IsNativeContext()) { 2154 if ((*p)->IsNativeContext()) {
2144 Context* context = Context::cast(*p); 2155 Context* context = Context::cast(*p);
2145 JSObject* proxy = context->global_proxy(); 2156 JSObject* proxy = context->global_proxy();
2146 if (proxy->IsJSGlobalProxy()) { 2157 if (proxy->IsJSGlobalProxy()) {
2147 Object* global = proxy->map()->prototype(); 2158 Object* global = proxy->map()->prototype();
2148 if (global->IsJSGlobalObject()) { 2159 if (global->IsJSGlobalObject()) {
(...skipping 964 matching lines...)
3113 for (int i = 1; i < sorted_strings.length(); ++i) { 3124 for (int i = 1; i < sorted_strings.length(); ++i) {
3114 writer_->AddCharacter(','); 3125 writer_->AddCharacter(',');
3115 SerializeString(sorted_strings[i]); 3126 SerializeString(sorted_strings[i]);
3116 if (writer_->aborted()) return; 3127 if (writer_->aborted()) return;
3117 } 3128 }
3118 } 3129 }
3119 3130
3120 3131
3121 } // namespace internal 3132 } // namespace internal
3122 } // namespace v8 3133 } // namespace v8
OLDNEW
« 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