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

Side by Side Diff: src/heap-snapshot-generator.cc

Issue 185543014: filler Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 void HeapEntry::SetIndexedReference(HeapGraphEdge::Type type, 95 void HeapEntry::SetIndexedReference(HeapGraphEdge::Type type,
96 int index, 96 int index,
97 HeapEntry* entry) { 97 HeapEntry* entry) {
98 HeapGraphEdge edge(type, index, this->index(), entry->index()); 98 HeapGraphEdge edge(type, index, this->index(), entry->index());
99 snapshot_->edges().Add(edge); 99 snapshot_->edges().Add(edge);
100 ++children_count_; 100 ++children_count_;
101 } 101 }
102 102
103 103
104 void HeapEntry::SetIndexedAutoIndexReference(HeapGraphEdge::Type type,
105 HeapEntry* child_entry) {
106 int index = children_count() + 1;
107 SetIndexedReference(type, index, child_entry);
108 }
109
110
111 void HeapEntry::SetNamedAutoIndexReference(HeapGraphEdge::Type type,
112 HeapEntry* child_entry,
113 StringsStorage* names) {
114 int index = children_count() + 1;
115 SetNamedReference(type, names->GetName(index), child_entry);
116 }
117
118
104 void HeapEntry::Print( 119 void HeapEntry::Print(
105 const char* prefix, const char* edge_name, int max_depth, int indent) { 120 const char* prefix, const char* edge_name, int max_depth, int indent) {
106 STATIC_CHECK(sizeof(unsigned) == sizeof(id())); 121 STATIC_CHECK(sizeof(unsigned) == sizeof(id()));
107 OS::Print("%6" V8PRIuPTR " @%6u %*c %s%s: ", 122 OS::Print("%6" V8PRIuPTR " @%6u %*c %s%s: ",
108 self_size(), id(), indent, ' ', prefix, edge_name); 123 self_size(), id(), indent, ' ', prefix, edge_name);
109 if (type() != kString) { 124 if (type() != kString) {
110 OS::Print("%s %.40s\n", TypeAsString(), name_); 125 OS::Print("%s %.40s\n", TypeAsString(), name_);
111 } else { 126 } else {
112 OS::Print("\""); 127 OS::Print("\"");
113 const char* c = name_; 128 const char* c = name_;
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 objects_count++; 995 objects_count++;
981 } 996 }
982 return objects_count; 997 return objects_count;
983 } 998 }
984 999
985 1000
986 class IndexedReferencesExtractor : public ObjectVisitor { 1001 class IndexedReferencesExtractor : public ObjectVisitor {
987 public: 1002 public:
988 IndexedReferencesExtractor(V8HeapExplorer* generator, 1003 IndexedReferencesExtractor(V8HeapExplorer* generator,
989 HeapObject* parent_obj, 1004 HeapObject* parent_obj,
990 int parent) 1005 HeapEntry* parent)
991 : generator_(generator), 1006 : generator_(generator),
992 parent_obj_(parent_obj), 1007 parent_obj_(parent_obj),
993 parent_(parent), 1008 parent_(parent),
994 next_index_(0) { 1009 next_index_(0) {
995 } 1010 }
996 void VisitCodeEntry(Address entry_address) { 1011 void VisitCodeEntry(Address entry_address) {
997 Code* code = Code::cast(Code::GetObjectFromEntryAddress(entry_address)); 1012 Code* code = Code::cast(Code::GetObjectFromEntryAddress(entry_address));
998 generator_->SetInternalReference(parent_obj_, parent_, "code", code); 1013 generator_->SetInternalReference(parent_obj_, parent_, "code", code);
999 generator_->TagCodeObject(code); 1014 generator_->TagCodeObject(code);
1000 } 1015 }
(...skipping 17 matching lines...) Expand all
1018 if ((*field)->IsFailure()) { 1033 if ((*field)->IsFailure()) {
1019 intptr_t untagged = reinterpret_cast<intptr_t>(*field) & ~kFailureTagMask; 1034 intptr_t untagged = reinterpret_cast<intptr_t>(*field) & ~kFailureTagMask;
1020 *field = reinterpret_cast<Object*>(untagged | kHeapObjectTag); 1035 *field = reinterpret_cast<Object*>(untagged | kHeapObjectTag);
1021 ASSERT((*field)->IsHeapObject()); 1036 ASSERT((*field)->IsHeapObject());
1022 return true; 1037 return true;
1023 } 1038 }
1024 return false; 1039 return false;
1025 } 1040 }
1026 V8HeapExplorer* generator_; 1041 V8HeapExplorer* generator_;
1027 HeapObject* parent_obj_; 1042 HeapObject* parent_obj_;
1028 int parent_; 1043 HeapEntry* parent_;
1029 int next_index_; 1044 int next_index_;
1030 }; 1045 };
1031 1046
1032 1047
1033 void V8HeapExplorer::ExtractReferences(HeapObject* obj) { 1048 void V8HeapExplorer::ExtractReferences(HeapObject* obj) {
1034 HeapEntry* heap_entry = GetEntry(obj); 1049 HeapEntry* entry = GetEntry(obj);
1035 if (heap_entry == NULL) return; // No interest in this object. 1050 if (entry == NULL) return; // No interest in this object.
1036 int entry = heap_entry->index();
1037 1051
1038 if (obj->IsJSGlobalProxy()) { 1052 if (obj->IsJSGlobalProxy()) {
1039 ExtractJSGlobalProxyReferences(entry, JSGlobalProxy::cast(obj)); 1053 ExtractJSGlobalProxyReferences(entry, JSGlobalProxy::cast(obj));
1040 } else if (obj->IsJSArrayBuffer()) { 1054 } else if (obj->IsJSArrayBuffer()) {
1041 ExtractJSArrayBufferReferences(entry, JSArrayBuffer::cast(obj)); 1055 ExtractJSArrayBufferReferences(entry, JSArrayBuffer::cast(obj));
1042 } else if (obj->IsJSObject()) { 1056 } else if (obj->IsJSObject()) {
1043 ExtractJSObjectReferences(entry, JSObject::cast(obj)); 1057 ExtractJSObjectReferences(entry, JSObject::cast(obj));
1044 } else if (obj->IsString()) { 1058 } else if (obj->IsString()) {
1045 ExtractStringReferences(entry, String::cast(obj)); 1059 ExtractStringReferences(entry, String::cast(obj));
1046 } else if (obj->IsContext()) { 1060 } else if (obj->IsContext()) {
(...skipping 22 matching lines...) Expand all
1069 SetInternalReference(obj, entry, "map", obj->map(), HeapObject::kMapOffset); 1083 SetInternalReference(obj, entry, "map", obj->map(), HeapObject::kMapOffset);
1070 1084
1071 // Extract unvisited fields as hidden references and restore tags 1085 // Extract unvisited fields as hidden references and restore tags
1072 // of visited fields. 1086 // of visited fields.
1073 IndexedReferencesExtractor refs_extractor(this, obj, entry); 1087 IndexedReferencesExtractor refs_extractor(this, obj, entry);
1074 obj->Iterate(&refs_extractor); 1088 obj->Iterate(&refs_extractor);
1075 } 1089 }
1076 1090
1077 1091
1078 void V8HeapExplorer::ExtractJSGlobalProxyReferences( 1092 void V8HeapExplorer::ExtractJSGlobalProxyReferences(
1079 int entry, JSGlobalProxy* proxy) { 1093 HeapEntry* entry, JSGlobalProxy* proxy) {
1080 SetInternalReference(proxy, entry, 1094 SetInternalReference(proxy, entry,
1081 "native_context", proxy->native_context(), 1095 "native_context", proxy->native_context(),
1082 JSGlobalProxy::kNativeContextOffset); 1096 JSGlobalProxy::kNativeContextOffset);
1083 } 1097 }
1084 1098
1085 1099
1086 void V8HeapExplorer::ExtractJSObjectReferences( 1100 void V8HeapExplorer::ExtractJSObjectReferences(
1087 int entry, JSObject* js_obj) { 1101 HeapEntry* entry, JSObject* js_obj) {
1088 HeapObject* obj = js_obj; 1102 HeapObject* obj = js_obj;
1089 ExtractClosureReferences(js_obj, entry); 1103 ExtractClosureReferences(js_obj, entry);
1090 ExtractPropertyReferences(js_obj, entry); 1104 ExtractPropertyReferences(js_obj, entry);
1091 ExtractElementReferences(js_obj, entry); 1105 ExtractElementReferences(js_obj, entry);
1092 ExtractInternalReferences(js_obj, entry); 1106 ExtractInternalReferences(js_obj, entry);
1093 SetPropertyReference( 1107 SetPropertyReference(
1094 obj, entry, heap_->proto_string(), js_obj->GetPrototype()); 1108 obj, entry, heap_->proto_string(), js_obj->GetPrototype());
1095 if (obj->IsJSFunction()) { 1109 if (obj->IsJSFunction()) {
1096 JSFunction* js_fun = JSFunction::cast(js_obj); 1110 JSFunction* js_fun = JSFunction::cast(js_obj);
1097 Object* proto_or_map = js_fun->prototype_or_initial_map(); 1111 Object* proto_or_map = js_fun->prototype_or_initial_map();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 SetInternalReference(obj, entry, 1176 SetInternalReference(obj, entry,
1163 "properties", js_obj->properties(), 1177 "properties", js_obj->properties(),
1164 JSObject::kPropertiesOffset); 1178 JSObject::kPropertiesOffset);
1165 TagObject(js_obj->elements(), "(object elements)"); 1179 TagObject(js_obj->elements(), "(object elements)");
1166 SetInternalReference(obj, entry, 1180 SetInternalReference(obj, entry,
1167 "elements", js_obj->elements(), 1181 "elements", js_obj->elements(),
1168 JSObject::kElementsOffset); 1182 JSObject::kElementsOffset);
1169 } 1183 }
1170 1184
1171 1185
1172 void V8HeapExplorer::ExtractStringReferences(int entry, String* string) { 1186 void V8HeapExplorer::ExtractStringReferences(HeapEntry* entry, String* string) {
1173 if (string->IsConsString()) { 1187 if (string->IsConsString()) {
1174 ConsString* cs = ConsString::cast(string); 1188 ConsString* cs = ConsString::cast(string);
1175 SetInternalReference(cs, entry, "first", cs->first(), 1189 SetInternalReference(cs, entry, "first", cs->first(),
1176 ConsString::kFirstOffset); 1190 ConsString::kFirstOffset);
1177 SetInternalReference(cs, entry, "second", cs->second(), 1191 SetInternalReference(cs, entry, "second", cs->second(),
1178 ConsString::kSecondOffset); 1192 ConsString::kSecondOffset);
1179 } else if (string->IsSlicedString()) { 1193 } else if (string->IsSlicedString()) {
1180 SlicedString* ss = SlicedString::cast(string); 1194 SlicedString* ss = SlicedString::cast(string);
1181 SetInternalReference(ss, entry, "parent", ss->parent(), 1195 SetInternalReference(ss, entry, "parent", ss->parent(),
1182 SlicedString::kParentOffset); 1196 SlicedString::kParentOffset);
1183 } 1197 }
1184 } 1198 }
1185 1199
1186 1200
1187 void V8HeapExplorer::ExtractContextReferences(int entry, Context* context) { 1201 void V8HeapExplorer::ExtractContextReferences(HeapEntry* entry, Context* context ) {
1188 if (context == context->declaration_context()) { 1202 if (context == context->declaration_context()) {
1189 ScopeInfo* scope_info = context->closure()->shared()->scope_info(); 1203 ScopeInfo* scope_info = context->closure()->shared()->scope_info();
1190 // Add context allocated locals. 1204 // Add context allocated locals.
1191 int context_locals = scope_info->ContextLocalCount(); 1205 int context_locals = scope_info->ContextLocalCount();
1192 for (int i = 0; i < context_locals; ++i) { 1206 for (int i = 0; i < context_locals; ++i) {
1193 String* local_name = scope_info->ContextLocalName(i); 1207 String* local_name = scope_info->ContextLocalName(i);
1194 int idx = Context::MIN_CONTEXT_SLOTS + i; 1208 int idx = Context::MIN_CONTEXT_SLOTS + i;
1195 SetContextReference(context, entry, local_name, context->get(idx), 1209 SetContextReference(context, entry, local_name, context->get(idx),
1196 Context::OffsetOfElementAt(idx)); 1210 Context::OffsetOfElementAt(idx));
1197 } 1211 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 EXTRACT_CONTEXT_FIELD(NEXT_CONTEXT_LINK, unused, next_context_link); 1246 EXTRACT_CONTEXT_FIELD(NEXT_CONTEXT_LINK, unused, next_context_link);
1233 #undef EXTRACT_CONTEXT_FIELD 1247 #undef EXTRACT_CONTEXT_FIELD
1234 STATIC_CHECK(Context::OPTIMIZED_FUNCTIONS_LIST == Context::FIRST_WEAK_SLOT); 1248 STATIC_CHECK(Context::OPTIMIZED_FUNCTIONS_LIST == Context::FIRST_WEAK_SLOT);
1235 STATIC_CHECK(Context::NEXT_CONTEXT_LINK + 1 1249 STATIC_CHECK(Context::NEXT_CONTEXT_LINK + 1
1236 == Context::NATIVE_CONTEXT_SLOTS); 1250 == Context::NATIVE_CONTEXT_SLOTS);
1237 STATIC_CHECK(Context::FIRST_WEAK_SLOT + 5 == Context::NATIVE_CONTEXT_SLOTS); 1251 STATIC_CHECK(Context::FIRST_WEAK_SLOT + 5 == Context::NATIVE_CONTEXT_SLOTS);
1238 } 1252 }
1239 } 1253 }
1240 1254
1241 1255
1242 void V8HeapExplorer::ExtractMapReferences(int entry, Map* map) { 1256 void V8HeapExplorer::ExtractMapReferences(HeapEntry* entry, Map* map) {
1243 if (map->HasTransitionArray()) { 1257 if (map->HasTransitionArray()) {
1244 TransitionArray* transitions = map->transitions(); 1258 TransitionArray* transitions = map->transitions();
1245 int transitions_entry = GetEntry(transitions)->index(); 1259 HeapEntry* transitions_entry = GetEntry(transitions);
1246 Object* back_pointer = transitions->back_pointer_storage(); 1260 Object* back_pointer = transitions->back_pointer_storage();
1247 TagObject(back_pointer, "(back pointer)"); 1261 TagObject(back_pointer, "(back pointer)");
1248 SetInternalReference(transitions, transitions_entry, 1262 SetInternalReference(transitions, transitions_entry,
1249 "back_pointer", back_pointer); 1263 "back_pointer", back_pointer);
1250 TagObject(transitions, "(transition array)"); 1264 TagObject(transitions, "(transition array)");
1251 SetInternalReference(map, entry, 1265 SetInternalReference(map, entry,
1252 "transitions", transitions, 1266 "transitions", transitions,
1253 Map::kTransitionsOrBackPointerOffset); 1267 Map::kTransitionsOrBackPointerOffset);
1254 } else { 1268 } else {
1255 Object* back_pointer = map->GetBackPointer(); 1269 Object* back_pointer = map->GetBackPointer();
(...skipping 17 matching lines...) Expand all
1273 "constructor", map->constructor(), 1287 "constructor", map->constructor(),
1274 Map::kConstructorOffset); 1288 Map::kConstructorOffset);
1275 TagObject(map->dependent_code(), "(dependent code)"); 1289 TagObject(map->dependent_code(), "(dependent code)");
1276 SetInternalReference(map, entry, 1290 SetInternalReference(map, entry,
1277 "dependent_code", map->dependent_code(), 1291 "dependent_code", map->dependent_code(),
1278 Map::kDependentCodeOffset); 1292 Map::kDependentCodeOffset);
1279 } 1293 }
1280 1294
1281 1295
1282 void V8HeapExplorer::ExtractSharedFunctionInfoReferences( 1296 void V8HeapExplorer::ExtractSharedFunctionInfoReferences(
1283 int entry, SharedFunctionInfo* shared) { 1297 HeapEntry* entry, SharedFunctionInfo* shared) {
1284 HeapObject* obj = shared; 1298 HeapObject* obj = shared;
1285 String* shared_name = shared->DebugName(); 1299 String* shared_name = shared->DebugName();
1286 const char* name = NULL; 1300 const char* name = NULL;
1287 if (shared_name != *heap_->isolate()->factory()->empty_string()) { 1301 if (shared_name != *heap_->isolate()->factory()->empty_string()) {
1288 name = names_->GetName(shared_name); 1302 name = names_->GetName(shared_name);
1289 TagObject(shared->code(), names_->GetFormatted("(code for %s)", name)); 1303 TagObject(shared->code(), names_->GetFormatted("(code for %s)", name));
1290 } else { 1304 } else {
1291 TagObject(shared->code(), names_->GetFormatted("(%s code)", 1305 TagObject(shared->code(), names_->GetFormatted("(%s code)",
1292 Code::Kind2String(shared->code()->kind()))); 1306 Code::Kind2String(shared->code()->kind())));
1293 } 1307 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 SharedFunctionInfo::kInferredNameOffset); 1340 SharedFunctionInfo::kInferredNameOffset);
1327 SetInternalReference(obj, entry, 1341 SetInternalReference(obj, entry,
1328 "optimized_code_map", shared->optimized_code_map(), 1342 "optimized_code_map", shared->optimized_code_map(),
1329 SharedFunctionInfo::kOptimizedCodeMapOffset); 1343 SharedFunctionInfo::kOptimizedCodeMapOffset);
1330 SetWeakReference(obj, entry, 1344 SetWeakReference(obj, entry,
1331 "initial_map", shared->initial_map(), 1345 "initial_map", shared->initial_map(),
1332 SharedFunctionInfo::kInitialMapOffset); 1346 SharedFunctionInfo::kInitialMapOffset);
1333 } 1347 }
1334 1348
1335 1349
1336 void V8HeapExplorer::ExtractScriptReferences(int entry, Script* script) { 1350 void V8HeapExplorer::ExtractScriptReferences(HeapEntry* entry, Script* script) {
1337 HeapObject* obj = script; 1351 HeapObject* obj = script;
1338 SetInternalReference(obj, entry, 1352 SetInternalReference(obj, entry,
1339 "source", script->source(), 1353 "source", script->source(),
1340 Script::kSourceOffset); 1354 Script::kSourceOffset);
1341 SetInternalReference(obj, entry, 1355 SetInternalReference(obj, entry,
1342 "name", script->name(), 1356 "name", script->name(),
1343 Script::kNameOffset); 1357 Script::kNameOffset);
1344 SetInternalReference(obj, entry, 1358 SetInternalReference(obj, entry,
1345 "data", script->data(), 1359 "data", script->data(),
1346 Script::kDataOffset); 1360 Script::kDataOffset);
1347 SetInternalReference(obj, entry, 1361 SetInternalReference(obj, entry,
1348 "context_data", script->context_data(), 1362 "context_data", script->context_data(),
1349 Script::kContextOffset); 1363 Script::kContextOffset);
1350 TagObject(script->line_ends(), "(script line ends)"); 1364 TagObject(script->line_ends(), "(script line ends)");
1351 SetInternalReference(obj, entry, 1365 SetInternalReference(obj, entry,
1352 "line_ends", script->line_ends(), 1366 "line_ends", script->line_ends(),
1353 Script::kLineEndsOffset); 1367 Script::kLineEndsOffset);
1354 } 1368 }
1355 1369
1356 1370
1357 void V8HeapExplorer::ExtractAccessorPairReferences( 1371 void V8HeapExplorer::ExtractAccessorPairReferences(
1358 int entry, AccessorPair* accessors) { 1372 HeapEntry* entry, AccessorPair* accessors) {
1359 SetInternalReference(accessors, entry, "getter", accessors->getter(), 1373 SetInternalReference(accessors, entry, "getter", accessors->getter(),
1360 AccessorPair::kGetterOffset); 1374 AccessorPair::kGetterOffset);
1361 SetInternalReference(accessors, entry, "setter", accessors->setter(), 1375 SetInternalReference(accessors, entry, "setter", accessors->setter(),
1362 AccessorPair::kSetterOffset); 1376 AccessorPair::kSetterOffset);
1363 } 1377 }
1364 1378
1365 1379
1366 void V8HeapExplorer::ExtractCodeCacheReferences( 1380 void V8HeapExplorer::ExtractCodeCacheReferences(
1367 int entry, CodeCache* code_cache) { 1381 HeapEntry* entry, CodeCache* code_cache) {
1368 TagObject(code_cache->default_cache(), "(default code cache)"); 1382 TagObject(code_cache->default_cache(), "(default code cache)");
1369 SetInternalReference(code_cache, entry, 1383 SetInternalReference(code_cache, entry,
1370 "default_cache", code_cache->default_cache(), 1384 "default_cache", code_cache->default_cache(),
1371 CodeCache::kDefaultCacheOffset); 1385 CodeCache::kDefaultCacheOffset);
1372 TagObject(code_cache->normal_type_cache(), "(code type cache)"); 1386 TagObject(code_cache->normal_type_cache(), "(code type cache)");
1373 SetInternalReference(code_cache, entry, 1387 SetInternalReference(code_cache, entry,
1374 "type_cache", code_cache->normal_type_cache(), 1388 "type_cache", code_cache->normal_type_cache(),
1375 CodeCache::kNormalTypeCacheOffset); 1389 CodeCache::kNormalTypeCacheOffset);
1376 } 1390 }
1377 1391
1378 1392
1379 void V8HeapExplorer::TagBuiltinCodeObject(Code* code, const char* name) { 1393 void V8HeapExplorer::TagBuiltinCodeObject(Code* code, const char* name) {
1380 TagObject(code, names_->GetFormatted("(%s builtin)", name)); 1394 TagObject(code, names_->GetFormatted("(%s builtin)", name));
1381 } 1395 }
1382 1396
1383 1397
1384 void V8HeapExplorer::TagCodeObject(Code* code) { 1398 void V8HeapExplorer::TagCodeObject(Code* code) {
1385 if (code->kind() == Code::STUB) { 1399 if (code->kind() == Code::STUB) {
1386 TagObject(code, names_->GetFormatted( 1400 TagObject(code, names_->GetFormatted(
1387 "(%s code)", CodeStub::MajorName( 1401 "(%s code)", CodeStub::MajorName(
1388 static_cast<CodeStub::Major>(code->major_key()), true))); 1402 static_cast<CodeStub::Major>(code->major_key()), true)));
1389 } 1403 }
1390 } 1404 }
1391 1405
1392 1406
1393 void V8HeapExplorer::ExtractCodeReferences(int entry, Code* code) { 1407 void V8HeapExplorer::ExtractCodeReferences(HeapEntry* entry, Code* code) {
1394 TagCodeObject(code); 1408 TagCodeObject(code);
1395 TagObject(code->relocation_info(), "(code relocation info)"); 1409 TagObject(code->relocation_info(), "(code relocation info)");
1396 SetInternalReference(code, entry, 1410 SetInternalReference(code, entry,
1397 "relocation_info", code->relocation_info(), 1411 "relocation_info", code->relocation_info(),
1398 Code::kRelocationInfoOffset); 1412 Code::kRelocationInfoOffset);
1399 SetInternalReference(code, entry, 1413 SetInternalReference(code, entry,
1400 "handler_table", code->handler_table(), 1414 "handler_table", code->handler_table(),
1401 Code::kHandlerTableOffset); 1415 Code::kHandlerTableOffset);
1402 TagObject(code->deoptimization_data(), "(code deopt data)"); 1416 TagObject(code->deoptimization_data(), "(code deopt data)");
1403 SetInternalReference(code, entry, 1417 SetInternalReference(code, entry,
(...skipping 11 matching lines...) Expand all
1415 "constant_pool", code->constant_pool(), 1429 "constant_pool", code->constant_pool(),
1416 Code::kConstantPoolOffset); 1430 Code::kConstantPoolOffset);
1417 if (code->kind() == Code::OPTIMIZED_FUNCTION) { 1431 if (code->kind() == Code::OPTIMIZED_FUNCTION) {
1418 SetWeakReference(code, entry, 1432 SetWeakReference(code, entry,
1419 "next_code_link", code->next_code_link(), 1433 "next_code_link", code->next_code_link(),
1420 Code::kNextCodeLinkOffset); 1434 Code::kNextCodeLinkOffset);
1421 } 1435 }
1422 } 1436 }
1423 1437
1424 1438
1425 void V8HeapExplorer::ExtractBoxReferences(int entry, Box* box) { 1439 void V8HeapExplorer::ExtractBoxReferences(HeapEntry* entry, Box* box) {
1426 SetInternalReference(box, entry, "value", box->value(), Box::kValueOffset); 1440 SetInternalReference(box, entry, "value", box->value(), Box::kValueOffset);
1427 } 1441 }
1428 1442
1429 1443
1430 void V8HeapExplorer::ExtractCellReferences(int entry, Cell* cell) { 1444 void V8HeapExplorer::ExtractCellReferences(HeapEntry* entry, Cell* cell) {
1431 SetInternalReference(cell, entry, "value", cell->value(), Cell::kValueOffset); 1445 SetInternalReference(cell, entry, "value", cell->value(), Cell::kValueOffset);
1432 } 1446 }
1433 1447
1434 1448
1435 void V8HeapExplorer::ExtractPropertyCellReferences(int entry, 1449 void V8HeapExplorer::ExtractPropertyCellReferences(HeapEntry* entry,
1436 PropertyCell* cell) { 1450 PropertyCell* cell) {
1437 ExtractCellReferences(entry, cell); 1451 ExtractCellReferences(entry, cell);
1438 SetInternalReference(cell, entry, "type", cell->type(), 1452 SetInternalReference(cell, entry, "type", cell->type(),
1439 PropertyCell::kTypeOffset); 1453 PropertyCell::kTypeOffset);
1440 SetInternalReference(cell, entry, "dependent_code", cell->dependent_code(), 1454 SetInternalReference(cell, entry, "dependent_code", cell->dependent_code(),
1441 PropertyCell::kDependentCodeOffset); 1455 PropertyCell::kDependentCodeOffset);
1442 } 1456 }
1443 1457
1444 1458
1445 void V8HeapExplorer::ExtractAllocationSiteReferences(int entry, 1459 void V8HeapExplorer::ExtractAllocationSiteReferences(HeapEntry* entry,
1446 AllocationSite* site) { 1460 AllocationSite* site) {
1447 SetInternalReference(site, entry, "transition_info", site->transition_info(), 1461 SetInternalReference(site, entry, "transition_info", site->transition_info(),
1448 AllocationSite::kTransitionInfoOffset); 1462 AllocationSite::kTransitionInfoOffset);
1449 SetInternalReference(site, entry, "nested_site", site->nested_site(), 1463 SetInternalReference(site, entry, "nested_site", site->nested_site(),
1450 AllocationSite::kNestedSiteOffset); 1464 AllocationSite::kNestedSiteOffset);
1451 SetInternalReference(site, entry, "dependent_code", site->dependent_code(), 1465 SetInternalReference(site, entry, "dependent_code", site->dependent_code(),
1452 AllocationSite::kDependentCodeOffset); 1466 AllocationSite::kDependentCodeOffset);
1453 // Do not visit weak_next as it is not visited by the StaticVisitor, 1467 // Do not visit weak_next as it is not visited by the StaticVisitor,
1454 // and we're not very interested in weak_next field here. 1468 // and we're not very interested in weak_next field here.
1455 STATIC_CHECK(AllocationSite::kWeakNextOffset >= 1469 STATIC_CHECK(AllocationSite::kWeakNextOffset >=
(...skipping 12 matching lines...) Expand all
1468 static_cast<Address>(ptr), 1482 static_cast<Address>(ptr),
1469 HeapEntry::kNative, "system / JSArrayBufferData", size_); 1483 HeapEntry::kNative, "system / JSArrayBufferData", size_);
1470 } 1484 }
1471 private: 1485 private:
1472 size_t size_; 1486 size_t size_;
1473 V8HeapExplorer* explorer_; 1487 V8HeapExplorer* explorer_;
1474 }; 1488 };
1475 1489
1476 1490
1477 void V8HeapExplorer::ExtractJSArrayBufferReferences( 1491 void V8HeapExplorer::ExtractJSArrayBufferReferences(
1478 int entry, JSArrayBuffer* buffer) { 1492 HeapEntry* entry, JSArrayBuffer* buffer) {
1479 SetWeakReference(buffer, entry, "weak_next", buffer->weak_next(), 1493 SetWeakReference(buffer, entry, "weak_next", buffer->weak_next(),
1480 JSArrayBuffer::kWeakNextOffset); 1494 JSArrayBuffer::kWeakNextOffset);
1481 SetWeakReference(buffer, entry, 1495 SetWeakReference(buffer, entry,
1482 "weak_first_view", buffer->weak_first_view(), 1496 "weak_first_view", buffer->weak_first_view(),
1483 JSArrayBuffer::kWeakFirstViewOffset); 1497 JSArrayBuffer::kWeakFirstViewOffset);
1484 // Setup a reference to a native memory backing_store object. 1498 // Setup a reference to a native memory backing_store object.
1485 if (!buffer->backing_store()) 1499 if (!buffer->backing_store())
1486 return; 1500 return;
1487 size_t data_size = NumberToSize(heap_->isolate(), buffer->byte_length()); 1501 size_t data_size = NumberToSize(heap_->isolate(), buffer->byte_length());
1488 JSArrayBufferDataEntryAllocator allocator(data_size, this); 1502 JSArrayBufferDataEntryAllocator allocator(data_size, this);
1489 HeapEntry* data_entry = 1503 HeapEntry* data_entry =
1490 filler_->FindOrAddEntry(buffer->backing_store(), &allocator); 1504 filler_->FindOrAddEntry(buffer->backing_store(), &allocator);
1491 filler_->SetNamedReference(HeapGraphEdge::kInternal, 1505 entry->SetNamedReference(HeapGraphEdge::kInternal,
1492 entry, "backing_store", data_entry); 1506 "backing_store", data_entry);
1493 } 1507 }
1494 1508
1495 1509
1496 void V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj, int entry) { 1510 void V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj, HeapEntry* entry ) {
1497 if (!js_obj->IsJSFunction()) return; 1511 if (!js_obj->IsJSFunction()) return;
1498 1512
1499 JSFunction* func = JSFunction::cast(js_obj); 1513 JSFunction* func = JSFunction::cast(js_obj);
1500 if (func->shared()->bound()) { 1514 if (func->shared()->bound()) {
1501 FixedArray* bindings = func->function_bindings(); 1515 FixedArray* bindings = func->function_bindings();
1502 SetNativeBindReference(js_obj, entry, "bound_this", 1516 SetNativeBindReference(js_obj, entry, "bound_this",
1503 bindings->get(JSFunction::kBoundThisIndex)); 1517 bindings->get(JSFunction::kBoundThisIndex));
1504 SetNativeBindReference(js_obj, entry, "bound_function", 1518 SetNativeBindReference(js_obj, entry, "bound_function",
1505 bindings->get(JSFunction::kBoundFunctionIndex)); 1519 bindings->get(JSFunction::kBoundFunctionIndex));
1506 for (int i = JSFunction::kBoundArgumentsStartIndex; 1520 for (int i = JSFunction::kBoundArgumentsStartIndex;
1507 i < bindings->length(); i++) { 1521 i < bindings->length(); i++) {
1508 const char* reference_name = names_->GetFormatted( 1522 const char* reference_name = names_->GetFormatted(
1509 "bound_argument_%d", 1523 "bound_argument_%d",
1510 i - JSFunction::kBoundArgumentsStartIndex); 1524 i - JSFunction::kBoundArgumentsStartIndex);
1511 SetNativeBindReference(js_obj, entry, reference_name, 1525 SetNativeBindReference(js_obj, entry, reference_name,
1512 bindings->get(i)); 1526 bindings->get(i));
1513 } 1527 }
1514 } 1528 }
1515 } 1529 }
1516 1530
1517 1531
1518 void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) { 1532 void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, HeapEntry* entr y) {
1519 if (js_obj->HasFastProperties()) { 1533 if (js_obj->HasFastProperties()) {
1520 DescriptorArray* descs = js_obj->map()->instance_descriptors(); 1534 DescriptorArray* descs = js_obj->map()->instance_descriptors();
1521 int real_size = js_obj->map()->NumberOfOwnDescriptors(); 1535 int real_size = js_obj->map()->NumberOfOwnDescriptors();
1522 for (int i = 0; i < real_size; i++) { 1536 for (int i = 0; i < real_size; i++) {
1523 switch (descs->GetType(i)) { 1537 switch (descs->GetType(i)) {
1524 case FIELD: { 1538 case FIELD: {
1525 int index = descs->GetFieldIndex(i); 1539 int index = descs->GetFieldIndex(i);
1526 1540
1527 Name* k = descs->GetKey(i); 1541 Name* k = descs->GetKey(i);
1528 if (index < js_obj->map()->inobject_properties()) { 1542 if (index < js_obj->map()->inobject_properties()) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 } 1603 }
1590 if (ExtractAccessorPairProperty(js_obj, entry, k, value)) continue; 1604 if (ExtractAccessorPairProperty(js_obj, entry, k, value)) continue;
1591 SetPropertyReference(js_obj, entry, String::cast(k), value); 1605 SetPropertyReference(js_obj, entry, String::cast(k), value);
1592 } 1606 }
1593 } 1607 }
1594 } 1608 }
1595 } 1609 }
1596 1610
1597 1611
1598 bool V8HeapExplorer::ExtractAccessorPairProperty( 1612 bool V8HeapExplorer::ExtractAccessorPairProperty(
1599 JSObject* js_obj, int entry, Object* key, Object* callback_obj) { 1613 JSObject* js_obj, HeapEntry* entry, Object* key, Object* callback_obj) {
1600 if (!callback_obj->IsAccessorPair()) return false; 1614 if (!callback_obj->IsAccessorPair()) return false;
1601 AccessorPair* accessors = AccessorPair::cast(callback_obj); 1615 AccessorPair* accessors = AccessorPair::cast(callback_obj);
1602 Object* getter = accessors->getter(); 1616 Object* getter = accessors->getter();
1603 if (!getter->IsOddball()) { 1617 if (!getter->IsOddball()) {
1604 SetPropertyReference(js_obj, entry, String::cast(key), getter, "get %s"); 1618 SetPropertyReference(js_obj, entry, String::cast(key), getter, "get %s");
1605 } 1619 }
1606 Object* setter = accessors->setter(); 1620 Object* setter = accessors->setter();
1607 if (!setter->IsOddball()) { 1621 if (!setter->IsOddball()) {
1608 SetPropertyReference(js_obj, entry, String::cast(key), setter, "set %s"); 1622 SetPropertyReference(js_obj, entry, String::cast(key), setter, "set %s");
1609 } 1623 }
1610 return true; 1624 return true;
1611 } 1625 }
1612 1626
1613 1627
1614 void V8HeapExplorer::ExtractElementReferences(JSObject* js_obj, int entry) { 1628 void V8HeapExplorer::ExtractElementReferences(JSObject* js_obj, HeapEntry* entry ) {
1615 if (js_obj->HasFastObjectElements()) { 1629 if (js_obj->HasFastObjectElements()) {
1616 FixedArray* elements = FixedArray::cast(js_obj->elements()); 1630 FixedArray* elements = FixedArray::cast(js_obj->elements());
1617 int length = js_obj->IsJSArray() ? 1631 int length = js_obj->IsJSArray() ?
1618 Smi::cast(JSArray::cast(js_obj)->length())->value() : 1632 Smi::cast(JSArray::cast(js_obj)->length())->value() :
1619 elements->length(); 1633 elements->length();
1620 for (int i = 0; i < length; ++i) { 1634 for (int i = 0; i < length; ++i) {
1621 if (!elements->get(i)->IsTheHole()) { 1635 if (!elements->get(i)->IsTheHole()) {
1622 SetElementReference(js_obj, entry, i, elements->get(i)); 1636 SetElementReference(js_obj, entry, i, elements->get(i));
1623 } 1637 }
1624 } 1638 }
1625 } else if (js_obj->HasDictionaryElements()) { 1639 } else if (js_obj->HasDictionaryElements()) {
1626 SeededNumberDictionary* dictionary = js_obj->element_dictionary(); 1640 SeededNumberDictionary* dictionary = js_obj->element_dictionary();
1627 int length = dictionary->Capacity(); 1641 int length = dictionary->Capacity();
1628 for (int i = 0; i < length; ++i) { 1642 for (int i = 0; i < length; ++i) {
1629 Object* k = dictionary->KeyAt(i); 1643 Object* k = dictionary->KeyAt(i);
1630 if (dictionary->IsKey(k)) { 1644 if (dictionary->IsKey(k)) {
1631 ASSERT(k->IsNumber()); 1645 ASSERT(k->IsNumber());
1632 uint32_t index = static_cast<uint32_t>(k->Number()); 1646 uint32_t index = static_cast<uint32_t>(k->Number());
1633 SetElementReference(js_obj, entry, index, dictionary->ValueAt(i)); 1647 SetElementReference(js_obj, entry, index, dictionary->ValueAt(i));
1634 } 1648 }
1635 } 1649 }
1636 } 1650 }
1637 } 1651 }
1638 1652
1639 1653
1640 void V8HeapExplorer::ExtractInternalReferences(JSObject* js_obj, int entry) { 1654 void V8HeapExplorer::ExtractInternalReferences(JSObject* js_obj, HeapEntry* entr y) {
1641 int length = js_obj->GetInternalFieldCount(); 1655 int length = js_obj->GetInternalFieldCount();
1642 for (int i = 0; i < length; ++i) { 1656 for (int i = 0; i < length; ++i) {
1643 Object* o = js_obj->GetInternalField(i); 1657 Object* o = js_obj->GetInternalField(i);
1644 SetInternalReference( 1658 SetInternalReference(
1645 js_obj, entry, i, o, js_obj->GetInternalFieldOffset(i)); 1659 js_obj, entry, i, o, js_obj->GetInternalFieldOffset(i));
1646 } 1660 }
1647 } 1661 }
1648 1662
1649 1663
1650 String* V8HeapExplorer::GetConstructorName(JSObject* object) { 1664 String* V8HeapExplorer::GetConstructorName(JSObject* object) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 && object != heap_->cell_map() 1810 && object != heap_->cell_map()
1797 && object != heap_->global_property_cell_map() 1811 && object != heap_->global_property_cell_map()
1798 && object != heap_->shared_function_info_map() 1812 && object != heap_->shared_function_info_map()
1799 && object != heap_->free_space_map() 1813 && object != heap_->free_space_map()
1800 && object != heap_->one_pointer_filler_map() 1814 && object != heap_->one_pointer_filler_map()
1801 && object != heap_->two_pointer_filler_map(); 1815 && object != heap_->two_pointer_filler_map();
1802 } 1816 }
1803 1817
1804 1818
1805 void V8HeapExplorer::SetContextReference(HeapObject* parent_obj, 1819 void V8HeapExplorer::SetContextReference(HeapObject* parent_obj,
1806 int parent_entry, 1820 HeapEntry* parent_entry,
1807 String* reference_name, 1821 String* reference_name,
1808 Object* child_obj, 1822 Object* child_obj,
1809 int field_offset) { 1823 int field_offset) {
1810 ASSERT(parent_entry == GetEntry(parent_obj)->index()); 1824 ASSERT(parent_entry == GetEntry(parent_obj));
1811 HeapEntry* child_entry = GetEntry(child_obj); 1825 HeapEntry* child_entry = GetEntry(child_obj);
1812 if (child_entry != NULL) { 1826 if (child_entry != NULL) {
1813 filler_->SetNamedReference(HeapGraphEdge::kContextVariable, 1827 parent_entry->SetNamedReference(HeapGraphEdge::kContextVariable,
1814 parent_entry, 1828 names_->GetName(reference_name),
1815 names_->GetName(reference_name), 1829 child_entry);
1816 child_entry);
1817 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset); 1830 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset);
1818 } 1831 }
1819 } 1832 }
1820 1833
1821 1834
1822 void V8HeapExplorer::SetNativeBindReference(HeapObject* parent_obj, 1835 void V8HeapExplorer::SetNativeBindReference(HeapObject* parent_obj,
1823 int parent_entry, 1836 HeapEntry* parent_entry,
1824 const char* reference_name, 1837 const char* reference_name,
1825 Object* child_obj) { 1838 Object* child_obj) {
1826 ASSERT(parent_entry == GetEntry(parent_obj)->index()); 1839 ASSERT(parent_entry == GetEntry(parent_obj));
1827 HeapEntry* child_entry = GetEntry(child_obj); 1840 HeapEntry* child_entry = GetEntry(child_obj);
1828 if (child_entry != NULL) { 1841 if (child_entry != NULL) {
1829 filler_->SetNamedReference(HeapGraphEdge::kShortcut, 1842 parent_entry->SetNamedReference(HeapGraphEdge::kShortcut,
1830 parent_entry, 1843 reference_name,
1831 reference_name, 1844 child_entry);
1832 child_entry);
1833 } 1845 }
1834 } 1846 }
1835 1847
1836 1848
1837 void V8HeapExplorer::SetElementReference(HeapObject* parent_obj, 1849 void V8HeapExplorer::SetElementReference(HeapObject* parent_obj,
1838 int parent_entry, 1850 HeapEntry* parent_entry,
1839 int index, 1851 int index,
1840 Object* child_obj) { 1852 Object* child_obj) {
1841 ASSERT(parent_entry == GetEntry(parent_obj)->index()); 1853 ASSERT(parent_entry == GetEntry(parent_obj)->index());
1842 HeapEntry* child_entry = GetEntry(child_obj); 1854 HeapEntry* child_entry = GetEntry(child_obj);
1843 if (child_entry != NULL) { 1855 if (child_entry != NULL) {
1844 filler_->SetIndexedReference(HeapGraphEdge::kElement, 1856 parent_entry->SetIndexedReference(HeapGraphEdge::kElement,
1845 parent_entry, 1857 index,
1846 index, 1858 child_entry);
1847 child_entry);
1848 } 1859 }
1849 } 1860 }
1850 1861
1851 1862
1852 void V8HeapExplorer::SetInternalReference(HeapObject* parent_obj, 1863 void V8HeapExplorer::SetInternalReference(HeapObject* parent_obj,
1853 int parent_entry, 1864 HeapEntry* parent_entry,
1854 const char* reference_name, 1865 const char* reference_name,
1855 Object* child_obj, 1866 Object* child_obj,
1856 int field_offset) { 1867 int field_offset) {
1857 ASSERT(parent_entry == GetEntry(parent_obj)->index()); 1868 ASSERT(parent_entry == GetEntry(parent_obj));
1858 HeapEntry* child_entry = GetEntry(child_obj); 1869 HeapEntry* child_entry = GetEntry(child_obj);
1859 if (child_entry == NULL) return; 1870 if (child_entry == NULL) return;
1860 if (IsEssentialObject(child_obj)) { 1871 if (IsEssentialObject(child_obj)) {
1861 filler_->SetNamedReference(HeapGraphEdge::kInternal, 1872 parent_entry->SetNamedReference(HeapGraphEdge::kInternal,
1862 parent_entry, 1873 reference_name,
1863 reference_name, 1874 child_entry);
1864 child_entry);
1865 } 1875 }
1866 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset); 1876 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset);
1867 } 1877 }
1868 1878
1869 1879
1870 void V8HeapExplorer::SetInternalReference(HeapObject* parent_obj, 1880 void V8HeapExplorer::SetInternalReference(HeapObject* parent_obj,
1871 int parent_entry, 1881 HeapEntry* parent_entry,
1872 int index, 1882 int index,
1873 Object* child_obj, 1883 Object* child_obj,
1874 int field_offset) { 1884 int field_offset) {
1875 ASSERT(parent_entry == GetEntry(parent_obj)->index()); 1885 ASSERT(parent_entry == GetEntry(parent_obj));
1876 HeapEntry* child_entry = GetEntry(child_obj); 1886 HeapEntry* child_entry = GetEntry(child_obj);
1877 if (child_entry == NULL) return; 1887 if (child_entry == NULL) return;
1878 if (IsEssentialObject(child_obj)) { 1888 if (IsEssentialObject(child_obj)) {
1879 filler_->SetNamedReference(HeapGraphEdge::kInternal, 1889 parent_entry->SetNamedReference(HeapGraphEdge::kInternal,
1880 parent_entry, 1890 names_->GetName(index),
1881 names_->GetName(index), 1891 child_entry);
1882 child_entry);
1883 } 1892 }
1884 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset); 1893 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset);
1885 } 1894 }
1886 1895
1887 1896
1888 void V8HeapExplorer::SetHiddenReference(HeapObject* parent_obj, 1897 void V8HeapExplorer::SetHiddenReference(HeapObject* parent_obj,
1889 int parent_entry, 1898 HeapEntry* parent_entry,
1890 int index, 1899 int index,
1891 Object* child_obj) { 1900 Object* child_obj) {
1892 ASSERT(parent_entry == GetEntry(parent_obj)->index()); 1901 ASSERT(parent_entry == GetEntry(parent_obj));
1893 HeapEntry* child_entry = GetEntry(child_obj); 1902 HeapEntry* child_entry = GetEntry(child_obj);
1894 if (child_entry != NULL && IsEssentialObject(child_obj)) { 1903 if (child_entry != NULL && IsEssentialObject(child_obj)) {
1895 filler_->SetIndexedReference(HeapGraphEdge::kHidden, 1904 parent_entry->SetIndexedReference(HeapGraphEdge::kHidden,
1896 parent_entry, 1905 index,
1897 index, 1906 child_entry);
1898 child_entry);
1899 } 1907 }
1900 } 1908 }
1901 1909
1902 1910
1903 void V8HeapExplorer::SetWeakReference(HeapObject* parent_obj, 1911 void V8HeapExplorer::SetWeakReference(HeapObject* parent_obj,
1904 int parent_entry, 1912 HeapEntry* parent_entry,
1905 const char* reference_name, 1913 const char* reference_name,
1906 Object* child_obj, 1914 Object* child_obj,
1907 int field_offset) { 1915 int field_offset) {
1908 ASSERT(parent_entry == GetEntry(parent_obj)->index()); 1916 ASSERT(parent_entry == GetEntry(parent_obj));
1909 HeapEntry* child_entry = GetEntry(child_obj); 1917 HeapEntry* child_entry = GetEntry(child_obj);
1910 if (child_entry == NULL) return; 1918 if (child_entry == NULL) return;
1911 if (IsEssentialObject(child_obj)) { 1919 if (IsEssentialObject(child_obj)) {
1912 filler_->SetNamedReference(HeapGraphEdge::kWeak, 1920 parent_entry->SetNamedReference(
1913 parent_entry, 1921 HeapGraphEdge::kWeak, reference_name, child_entry);
1914 reference_name,
1915 child_entry);
1916 } 1922 }
1917 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset); 1923 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset);
1918 } 1924 }
1919 1925
1920 1926
1921 void V8HeapExplorer::SetPropertyReference(HeapObject* parent_obj, 1927 void V8HeapExplorer::SetPropertyReference(HeapObject* parent_obj,
1922 int parent_entry, 1928 HeapEntry* parent_entry,
1923 Name* reference_name, 1929 Name* reference_name,
1924 Object* child_obj, 1930 Object* child_obj,
1925 const char* name_format_string, 1931 const char* name_format_string,
1926 int field_offset) { 1932 int field_offset) {
1927 ASSERT(parent_entry == GetEntry(parent_obj)->index()); 1933 ASSERT(parent_entry == GetEntry(parent_obj));
1928 HeapEntry* child_entry = GetEntry(child_obj); 1934 HeapEntry* child_entry = GetEntry(child_obj);
1929 if (child_entry != NULL) { 1935 if (child_entry != NULL) {
1930 HeapGraphEdge::Type type = 1936 HeapGraphEdge::Type type =
1931 reference_name->IsSymbol() || String::cast(reference_name)->length() > 0 1937 reference_name->IsSymbol() || String::cast(reference_name)->length() > 0
1932 ? HeapGraphEdge::kProperty : HeapGraphEdge::kInternal; 1938 ? HeapGraphEdge::kProperty : HeapGraphEdge::kInternal;
1933 const char* name = name_format_string != NULL && reference_name->IsString() 1939 const char* name = name_format_string != NULL && reference_name->IsString()
1934 ? names_->GetFormatted( 1940 ? names_->GetFormatted(
1935 name_format_string, 1941 name_format_string,
1936 String::cast(reference_name)->ToCString( 1942 String::cast(reference_name)->ToCString(
1937 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL).get()) : 1943 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL).get()) :
1938 names_->GetName(reference_name); 1944 names_->GetName(reference_name);
1939 1945
1940 filler_->SetNamedReference(type, 1946 parent_entry->SetNamedReference(type, name, child_entry);
1941 parent_entry,
1942 name,
1943 child_entry);
1944 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset); 1947 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset);
1945 } 1948 }
1946 } 1949 }
1947 1950
1948 1951
1949 void V8HeapExplorer::SetRootGcRootsReference() { 1952 void V8HeapExplorer::SetRootGcRootsReference() {
1950 filler_->SetIndexedAutoIndexReference( 1953 snapshot_->root()->SetIndexedAutoIndexReference(
1951 HeapGraphEdge::kElement, 1954 HeapGraphEdge::kElement,
1952 snapshot_->root()->index(),
1953 snapshot_->gc_roots()); 1955 snapshot_->gc_roots());
1954 } 1956 }
1955 1957
1956 1958
1957 void V8HeapExplorer::SetUserGlobalReference(Object* child_obj) { 1959 void V8HeapExplorer::SetUserGlobalReference(Object* child_obj) {
1958 HeapEntry* child_entry = GetEntry(child_obj); 1960 HeapEntry* child_entry = GetEntry(child_obj);
1959 ASSERT(child_entry != NULL); 1961 ASSERT(child_entry != NULL);
1960 filler_->SetNamedAutoIndexReference( 1962 snapshot_->root()->SetNamedAutoIndexReference(
1961 HeapGraphEdge::kShortcut, 1963 HeapGraphEdge::kShortcut,
1962 snapshot_->root()->index(), 1964 child_entry,
1963 child_entry); 1965 names_);
1964 } 1966 }
1965 1967
1966 1968
1967 void V8HeapExplorer::SetGcRootsReference(VisitorSynchronization::SyncTag tag) { 1969 void V8HeapExplorer::SetGcRootsReference(VisitorSynchronization::SyncTag tag) {
1968 filler_->SetIndexedAutoIndexReference( 1970 snapshot_->gc_roots()->SetIndexedAutoIndexReference(
1969 HeapGraphEdge::kElement, 1971 HeapGraphEdge::kElement,
1970 snapshot_->gc_roots()->index(),
1971 snapshot_->gc_subroot(tag)); 1972 snapshot_->gc_subroot(tag));
1972 } 1973 }
1973 1974
1974 1975
1975 void V8HeapExplorer::SetGcSubrootReference( 1976 void V8HeapExplorer::SetGcSubrootReference(
1976 VisitorSynchronization::SyncTag tag, bool is_weak, Object* child_obj) { 1977 VisitorSynchronization::SyncTag tag, bool is_weak, Object* child_obj) {
1977 HeapEntry* child_entry = GetEntry(child_obj); 1978 HeapEntry* child_entry = GetEntry(child_obj);
1978 if (child_entry != NULL) { 1979 if (child_entry != NULL) {
1979 const char* name = GetStrongGcSubrootName(child_obj); 1980 const char* name = GetStrongGcSubrootName(child_obj);
1980 if (name != NULL) { 1981 if (name != NULL) {
1981 filler_->SetNamedReference( 1982 snapshot_->gc_subroot(tag)->SetNamedReference(
1982 HeapGraphEdge::kInternal, 1983 HeapGraphEdge::kInternal,
1983 snapshot_->gc_subroot(tag)->index(),
1984 name, 1984 name,
1985 child_entry); 1985 child_entry);
1986 } else { 1986 } else {
1987 if (is_weak) { 1987 if (is_weak) {
1988 filler_->SetNamedAutoIndexReference( 1988 snapshot_->gc_subroot(tag)->SetNamedAutoIndexReference(
1989 HeapGraphEdge::kWeak, 1989 HeapGraphEdge::kWeak,
1990 snapshot_->gc_subroot(tag)->index(), 1990 child_entry,
1991 child_entry); 1991 names_);
1992 } else { 1992 } else {
1993 filler_->SetIndexedAutoIndexReference( 1993 snapshot_->gc_subroot(tag)->SetIndexedAutoIndexReference(
1994 HeapGraphEdge::kElement, 1994 HeapGraphEdge::kElement,
1995 snapshot_->gc_subroot(tag)->index(),
1996 child_entry); 1995 child_entry);
1997 } 1996 }
1998 } 1997 }
1999 1998
2000 // Add a shortcut to JS global object reference at snapshot root. 1999 // Add a shortcut to JS global object reference at snapshot root.
2001 if (child_obj->IsNativeContext()) { 2000 if (child_obj->IsNativeContext()) {
2002 Context* context = Context::cast(child_obj); 2001 Context* context = Context::cast(child_obj);
2003 GlobalObject* global = context->global_object(); 2002 GlobalObject* global = context->global_object();
2004 if (global->IsJSGlobalObject()) { 2003 if (global->IsJSGlobalObject()) {
2005 bool is_debug_object = false; 2004 bool is_debug_object = false;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
2222 } 2221 }
2223 2222
2224 2223
2225 void NativeObjectsExplorer::FillImplicitReferences() { 2224 void NativeObjectsExplorer::FillImplicitReferences() {
2226 Isolate* isolate = isolate_; 2225 Isolate* isolate = isolate_;
2227 List<ImplicitRefGroup*>* groups = 2226 List<ImplicitRefGroup*>* groups =
2228 isolate->global_handles()->implicit_ref_groups(); 2227 isolate->global_handles()->implicit_ref_groups();
2229 for (int i = 0; i < groups->length(); ++i) { 2228 for (int i = 0; i < groups->length(); ++i) {
2230 ImplicitRefGroup* group = groups->at(i); 2229 ImplicitRefGroup* group = groups->at(i);
2231 HeapObject* parent = *group->parent; 2230 HeapObject* parent = *group->parent;
2232 int parent_entry = 2231 HeapEntry* parent_entry =
2233 filler_->FindOrAddEntry(parent, native_entries_allocator_)->index(); 2232 filler_->FindOrAddEntry(parent, native_entries_allocator_);
2234 ASSERT(parent_entry != HeapEntry::kNoEntry); 2233 ASSERT(parent_entry != NULL);
2235 Object*** children = group->children; 2234 Object*** children = group->children;
2236 for (size_t j = 0; j < group->length; ++j) { 2235 for (size_t j = 0; j < group->length; ++j) {
2237 Object* child = *children[j]; 2236 Object* child = *children[j];
2238 HeapEntry* child_entry = 2237 HeapEntry* child_entry =
2239 filler_->FindOrAddEntry(child, native_entries_allocator_); 2238 filler_->FindOrAddEntry(child, native_entries_allocator_);
2240 filler_->SetNamedReference( 2239 parent_entry->SetNamedReference(
2241 HeapGraphEdge::kInternal, 2240 HeapGraphEdge::kInternal,
2242 parent_entry,
2243 "native", 2241 "native",
2244 child_entry); 2242 child_entry);
2245 } 2243 }
2246 } 2244 }
2247 isolate->global_handles()->RemoveImplicitRefGroups(); 2245 isolate->global_handles()->RemoveImplicitRefGroups();
2248 } 2246 }
2249 2247
2250 List<HeapObject*>* NativeObjectsExplorer::GetListMaybeDisposeInfo( 2248 List<HeapObject*>* NativeObjectsExplorer::GetListMaybeDisposeInfo(
2251 v8::RetainedObjectInfo* info) { 2249 v8::RetainedObjectInfo* info) {
2252 HashMap::Entry* entry = 2250 HashMap::Entry* entry =
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2330 2328
2331 void NativeObjectsExplorer::SetNativeRootReference( 2329 void NativeObjectsExplorer::SetNativeRootReference(
2332 v8::RetainedObjectInfo* info) { 2330 v8::RetainedObjectInfo* info) {
2333 HeapEntry* child_entry = 2331 HeapEntry* child_entry =
2334 filler_->FindOrAddEntry(info, native_entries_allocator_); 2332 filler_->FindOrAddEntry(info, native_entries_allocator_);
2335 ASSERT(child_entry != NULL); 2333 ASSERT(child_entry != NULL);
2336 NativeGroupRetainedObjectInfo* group_info = 2334 NativeGroupRetainedObjectInfo* group_info =
2337 FindOrAddGroupInfo(info->GetGroupLabel()); 2335 FindOrAddGroupInfo(info->GetGroupLabel());
2338 HeapEntry* group_entry = 2336 HeapEntry* group_entry =
2339 filler_->FindOrAddEntry(group_info, synthetic_entries_allocator_); 2337 filler_->FindOrAddEntry(group_info, synthetic_entries_allocator_);
2340 filler_->SetNamedAutoIndexReference( 2338 group_entry->SetNamedAutoIndexReference(
2341 HeapGraphEdge::kInternal, 2339 HeapGraphEdge::kInternal,
2342 group_entry->index(), 2340 child_entry,
2343 child_entry); 2341 names_);
2344 } 2342 }
2345 2343
2346 2344
2347 void NativeObjectsExplorer::SetWrapperNativeReferences( 2345 void NativeObjectsExplorer::SetWrapperNativeReferences(
2348 HeapObject* wrapper, v8::RetainedObjectInfo* info) { 2346 HeapObject* wrapper, v8::RetainedObjectInfo* info) {
2349 HeapEntry* wrapper_entry = filler_->FindEntry(wrapper); 2347 HeapEntry* wrapper_entry = filler_->FindEntry(wrapper);
2350 ASSERT(wrapper_entry != NULL); 2348 ASSERT(wrapper_entry != NULL);
2351 HeapEntry* info_entry = 2349 HeapEntry* info_entry =
2352 filler_->FindOrAddEntry(info, native_entries_allocator_); 2350 filler_->FindOrAddEntry(info, native_entries_allocator_);
2353 ASSERT(info_entry != NULL); 2351 ASSERT(info_entry != NULL);
2354 filler_->SetNamedReference(HeapGraphEdge::kInternal, 2352 wrapper_entry->SetNamedReference(HeapGraphEdge::kInternal,
2355 wrapper_entry->index(), 2353 "native",
2356 "native", 2354 info_entry);
2357 info_entry); 2355 info_entry->SetIndexedAutoIndexReference(HeapGraphEdge::kElement,
2358 filler_->SetIndexedAutoIndexReference(HeapGraphEdge::kElement, 2356 wrapper_entry);
2359 info_entry->index(),
2360 wrapper_entry);
2361 } 2357 }
2362 2358
2363 2359
2364 void NativeObjectsExplorer::SetRootNativeRootsReference() { 2360 void NativeObjectsExplorer::SetRootNativeRootsReference() {
2365 for (HashMap::Entry* entry = native_groups_.Start(); 2361 for (HashMap::Entry* entry = native_groups_.Start();
2366 entry; 2362 entry;
2367 entry = native_groups_.Next(entry)) { 2363 entry = native_groups_.Next(entry)) {
2368 NativeGroupRetainedObjectInfo* group_info = 2364 NativeGroupRetainedObjectInfo* group_info =
2369 static_cast<NativeGroupRetainedObjectInfo*>(entry->value); 2365 static_cast<NativeGroupRetainedObjectInfo*>(entry->value);
2370 HeapEntry* group_entry = 2366 HeapEntry* group_entry =
2371 filler_->FindOrAddEntry(group_info, native_entries_allocator_); 2367 filler_->FindOrAddEntry(group_info, native_entries_allocator_);
2372 ASSERT(group_entry != NULL); 2368 ASSERT(group_entry != NULL);
2373 filler_->SetIndexedAutoIndexReference( 2369 snapshot_->root()->SetIndexedAutoIndexReference(
2374 HeapGraphEdge::kElement, 2370 HeapGraphEdge::kElement,
2375 snapshot_->root()->index(),
2376 group_entry); 2371 group_entry);
2377 } 2372 }
2378 } 2373 }
2379 2374
2380 2375
2381 void NativeObjectsExplorer::VisitSubtreeWrapper(Object** p, uint16_t class_id) { 2376 void NativeObjectsExplorer::VisitSubtreeWrapper(Object** p, uint16_t class_id) {
2382 if (in_groups_.Contains(*p)) return; 2377 if (in_groups_.Contains(*p)) return;
2383 Isolate* isolate = isolate_; 2378 Isolate* isolate = isolate_;
2384 v8::RetainedObjectInfo* info = 2379 v8::RetainedObjectInfo* info =
2385 isolate->heap_profiler()->ExecuteWrapperClassCallback(class_id, p); 2380 isolate->heap_profiler()->ExecuteWrapperClassCallback(class_id, p);
(...skipping 14 matching lines...) Expand all
2400 return entry; 2395 return entry;
2401 } 2396 }
2402 HeapEntry* FindEntry(HeapThing ptr) { 2397 HeapEntry* FindEntry(HeapThing ptr) {
2403 int index = entries_->Map(ptr); 2398 int index = entries_->Map(ptr);
2404 return index != HeapEntry::kNoEntry ? &snapshot_->entries()[index] : NULL; 2399 return index != HeapEntry::kNoEntry ? &snapshot_->entries()[index] : NULL;
2405 } 2400 }
2406 HeapEntry* FindOrAddEntry(HeapThing ptr, HeapEntriesAllocator* allocator) { 2401 HeapEntry* FindOrAddEntry(HeapThing ptr, HeapEntriesAllocator* allocator) {
2407 HeapEntry* entry = FindEntry(ptr); 2402 HeapEntry* entry = FindEntry(ptr);
2408 return entry != NULL ? entry : AddEntry(ptr, allocator); 2403 return entry != NULL ? entry : AddEntry(ptr, allocator);
2409 } 2404 }
2410 void SetIndexedReference(HeapGraphEdge::Type type,
2411 int parent,
2412 int index,
2413 HeapEntry* child_entry) {
2414 HeapEntry* parent_entry = &snapshot_->entries()[parent];
2415 parent_entry->SetIndexedReference(type, index, child_entry);
2416 }
2417 void SetIndexedAutoIndexReference(HeapGraphEdge::Type type,
2418 int parent,
2419 HeapEntry* child_entry) {
2420 HeapEntry* parent_entry = &snapshot_->entries()[parent];
2421 int index = parent_entry->children_count() + 1;
2422 parent_entry->SetIndexedReference(type, index, child_entry);
2423 }
2424 void SetNamedReference(HeapGraphEdge::Type type,
2425 int parent,
2426 const char* reference_name,
2427 HeapEntry* child_entry) {
2428 HeapEntry* parent_entry = &snapshot_->entries()[parent];
2429 parent_entry->SetNamedReference(type, reference_name, child_entry);
2430 }
2431 void SetNamedAutoIndexReference(HeapGraphEdge::Type type,
2432 int parent,
2433 HeapEntry* child_entry) {
2434 HeapEntry* parent_entry = &snapshot_->entries()[parent];
2435 int index = parent_entry->children_count() + 1;
2436 parent_entry->SetNamedReference(
2437 type,
2438 names_->GetName(index),
2439 child_entry);
2440 }
2441 2405
2442 private: 2406 private:
2443 HeapSnapshot* snapshot_; 2407 HeapSnapshot* snapshot_;
2444 StringsStorage* names_; 2408 StringsStorage* names_;
2445 HeapEntriesMap* entries_; 2409 HeapEntriesMap* entries_;
2446 }; 2410 };
2447 2411
2448 2412
2449 HeapSnapshotGenerator::HeapSnapshotGenerator( 2413 HeapSnapshotGenerator::HeapSnapshotGenerator(
2450 HeapSnapshot* snapshot, 2414 HeapSnapshot* snapshot,
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
3061 writer_->AddString("\"<dummy>\""); 3025 writer_->AddString("\"<dummy>\"");
3062 for (int i = 1; i < sorted_strings.length(); ++i) { 3026 for (int i = 1; i < sorted_strings.length(); ++i) {
3063 writer_->AddCharacter(','); 3027 writer_->AddCharacter(',');
3064 SerializeString(sorted_strings[i]); 3028 SerializeString(sorted_strings[i]);
3065 if (writer_->aborted()) return; 3029 if (writer_->aborted()) return;
3066 } 3030 }
3067 } 3031 }
3068 3032
3069 3033
3070 } } // namespace v8::internal 3034 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698