| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 | 994 |
| 995 | 995 |
| 996 const char* HeapEntry::TypeAsString() { | 996 const char* HeapEntry::TypeAsString() { |
| 997 switch (type()) { | 997 switch (type()) { |
| 998 case kInternal: return "/internal/"; | 998 case kInternal: return "/internal/"; |
| 999 case kObject: return "/object/"; | 999 case kObject: return "/object/"; |
| 1000 case kClosure: return "/closure/"; | 1000 case kClosure: return "/closure/"; |
| 1001 case kString: return "/string/"; | 1001 case kString: return "/string/"; |
| 1002 case kCode: return "/code/"; | 1002 case kCode: return "/code/"; |
| 1003 case kArray: return "/array/"; | 1003 case kArray: return "/array/"; |
| 1004 case kRegExp: return "/regexp/"; |
| 1004 default: return "???"; | 1005 default: return "???"; |
| 1005 } | 1006 } |
| 1006 } | 1007 } |
| 1007 | 1008 |
| 1008 | 1009 |
| 1009 int HeapEntry::EntriesSize(int entries_count, | 1010 int HeapEntry::EntriesSize(int entries_count, |
| 1010 int children_count, | 1011 int children_count, |
| 1011 int retainers_count) { | 1012 int retainers_count) { |
| 1012 return sizeof(HeapEntry) * entries_count // NOLINT | 1013 return sizeof(HeapEntry) * entries_count // NOLINT |
| 1013 + sizeof(HeapGraphEdge) * children_count // NOLINT | 1014 + sizeof(HeapGraphEdge) * children_count // NOLINT |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 int retainers_count) { | 1278 int retainers_count) { |
| 1278 if (object == kInternalRootObject) { | 1279 if (object == kInternalRootObject) { |
| 1279 ASSERT(root_entry_ == NULL); | 1280 ASSERT(root_entry_ == NULL); |
| 1280 ASSERT(retainers_count == 0); | 1281 ASSERT(retainers_count == 0); |
| 1281 root_entry_ = AddEntry( | 1282 root_entry_ = AddEntry( |
| 1282 HeapEntry::kInternal, "", 0, 0, children_count, retainers_count); | 1283 HeapEntry::kInternal, "", 0, 0, children_count, retainers_count); |
| 1283 return root_entry_; | 1284 return root_entry_; |
| 1284 } else if (object->IsJSFunction()) { | 1285 } else if (object->IsJSFunction()) { |
| 1285 JSFunction* func = JSFunction::cast(object); | 1286 JSFunction* func = JSFunction::cast(object); |
| 1286 SharedFunctionInfo* shared = func->shared(); | 1287 SharedFunctionInfo* shared = func->shared(); |
| 1287 String* name = String::cast(shared->name())->length() > 0 ? | |
| 1288 String::cast(shared->name()) : shared->inferred_name(); | |
| 1289 return AddEntry(object, | 1288 return AddEntry(object, |
| 1290 HeapEntry::kClosure, | 1289 HeapEntry::kClosure, |
| 1291 collection_->GetFunctionName(name), | 1290 collection_->GetName(String::cast(shared->name())), |
| 1291 children_count, |
| 1292 retainers_count); |
| 1293 } else if (object->IsJSRegExp()) { |
| 1294 JSRegExp* re = JSRegExp::cast(object); |
| 1295 return AddEntry(object, |
| 1296 HeapEntry::kRegExp, |
| 1297 collection_->GetName(re->Pattern()), |
| 1292 children_count, | 1298 children_count, |
| 1293 retainers_count); | 1299 retainers_count); |
| 1294 } else if (object->IsJSObject()) { | 1300 } else if (object->IsJSObject()) { |
| 1295 return AddEntry(object, | 1301 return AddEntry(object, |
| 1296 HeapEntry::kObject, | 1302 HeapEntry::kObject, |
| 1297 collection_->GetName( | 1303 collection_->GetName( |
| 1298 JSObject::cast(object)->constructor_name()), | 1304 JSObject::cast(object)->constructor_name()), |
| 1299 children_count, | 1305 children_count, |
| 1300 retainers_count); | 1306 retainers_count); |
| 1301 } else if (object->IsString()) { | 1307 } else if (object->IsString()) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 retainers_count); | 1341 retainers_count); |
| 1336 } | 1342 } |
| 1337 // No interest in this object. | 1343 // No interest in this object. |
| 1338 return NULL; | 1344 return NULL; |
| 1339 } | 1345 } |
| 1340 | 1346 |
| 1341 | 1347 |
| 1342 bool HeapSnapshot::WillAddEntry(HeapObject* object) { | 1348 bool HeapSnapshot::WillAddEntry(HeapObject* object) { |
| 1343 return object == kInternalRootObject | 1349 return object == kInternalRootObject |
| 1344 || object->IsJSFunction() | 1350 || object->IsJSFunction() |
| 1351 || object->IsJSRegExp() |
| 1345 || object->IsJSObject() | 1352 || object->IsJSObject() |
| 1346 || object->IsString() | 1353 || object->IsString() |
| 1347 || object->IsCode() | 1354 || object->IsCode() |
| 1348 || object->IsSharedFunctionInfo() | 1355 || object->IsSharedFunctionInfo() |
| 1349 || object->IsScript() | 1356 || object->IsScript() |
| 1350 || object->IsFixedArray(); | 1357 || object->IsFixedArray(); |
| 1351 } | 1358 } |
| 1352 | 1359 |
| 1353 | 1360 |
| 1354 static void HeapEntryClearPaint(HeapEntry** entry_ptr) { | 1361 static void HeapEntryClearPaint(HeapEntry** entry_ptr) { |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1898 | 1905 |
| 1899 HeapEntry* entry = GetEntry(obj); | 1906 HeapEntry* entry = GetEntry(obj); |
| 1900 if (entry == NULL) return; // No interest in this object. | 1907 if (entry == NULL) return; // No interest in this object. |
| 1901 | 1908 |
| 1902 if (obj->IsJSObject()) { | 1909 if (obj->IsJSObject()) { |
| 1903 JSObject* js_obj = JSObject::cast(obj); | 1910 JSObject* js_obj = JSObject::cast(obj); |
| 1904 ExtractClosureReferences(js_obj, entry); | 1911 ExtractClosureReferences(js_obj, entry); |
| 1905 ExtractPropertyReferences(js_obj, entry); | 1912 ExtractPropertyReferences(js_obj, entry); |
| 1906 ExtractElementReferences(js_obj, entry); | 1913 ExtractElementReferences(js_obj, entry); |
| 1907 SetPropertyReference( | 1914 SetPropertyReference( |
| 1908 obj, entry, Heap::prototype_symbol(), js_obj->map()->prototype()); | 1915 obj, entry, Heap::Proto_symbol(), js_obj->GetPrototype()); |
| 1916 if (obj->IsJSFunction()) { |
| 1917 JSFunction* js_fun = JSFunction::cast(obj); |
| 1918 if (js_fun->has_prototype()) { |
| 1919 SetPropertyReference( |
| 1920 obj, entry, Heap::prototype_symbol(), js_fun->prototype()); |
| 1921 } |
| 1922 } |
| 1909 } else if (obj->IsString()) { | 1923 } else if (obj->IsString()) { |
| 1910 if (obj->IsConsString()) { | 1924 if (obj->IsConsString()) { |
| 1911 ConsString* cs = ConsString::cast(obj); | 1925 ConsString* cs = ConsString::cast(obj); |
| 1912 SetElementReference(obj, entry, 0, cs->first()); | 1926 SetInternalReference(obj, entry, "1", cs->first()); |
| 1913 SetElementReference(obj, entry, 1, cs->second()); | 1927 SetInternalReference(obj, entry, "2", cs->second()); |
| 1914 } | 1928 } |
| 1915 } else if (obj->IsCode() || obj->IsSharedFunctionInfo() || obj->IsScript()) { | 1929 } else if (obj->IsCode() || obj->IsSharedFunctionInfo() || obj->IsScript()) { |
| 1916 IndexedReferencesExtractor refs_extractor(this, obj, entry); | 1930 IndexedReferencesExtractor refs_extractor(this, obj, entry); |
| 1917 obj->Iterate(&refs_extractor); | 1931 obj->Iterate(&refs_extractor); |
| 1918 } else if (obj->IsFixedArray()) { | 1932 } else if (obj->IsFixedArray()) { |
| 1919 IndexedReferencesExtractor refs_extractor(this, obj, entry); | 1933 IndexedReferencesExtractor refs_extractor(this, obj, entry); |
| 1920 obj->Iterate(&refs_extractor); | 1934 obj->Iterate(&refs_extractor); |
| 1921 } | 1935 } |
| 1922 } | 1936 } |
| 1923 | 1937 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2048 } | 2062 } |
| 2049 } | 2063 } |
| 2050 | 2064 |
| 2051 | 2065 |
| 2052 void HeapSnapshotGenerator::SetPropertyReference(HeapObject* parent_obj, | 2066 void HeapSnapshotGenerator::SetPropertyReference(HeapObject* parent_obj, |
| 2053 HeapEntry* parent_entry, | 2067 HeapEntry* parent_entry, |
| 2054 String* reference_name, | 2068 String* reference_name, |
| 2055 Object* child_obj) { | 2069 Object* child_obj) { |
| 2056 HeapEntry* child_entry = GetEntry(child_obj); | 2070 HeapEntry* child_entry = GetEntry(child_obj); |
| 2057 if (child_entry != NULL) { | 2071 if (child_entry != NULL) { |
| 2058 filler_->SetNamedReference(HeapGraphEdge::kProperty, | 2072 HeapGraphEdge::Type type = reference_name->length() > 0 ? |
| 2073 HeapGraphEdge::kProperty : HeapGraphEdge::kInternal; |
| 2074 filler_->SetNamedReference(type, |
| 2059 parent_obj, | 2075 parent_obj, |
| 2060 parent_entry, | 2076 parent_entry, |
| 2061 collection_->GetName(reference_name), | 2077 collection_->GetName(reference_name), |
| 2062 child_obj, | 2078 child_obj, |
| 2063 child_entry); | 2079 child_entry); |
| 2064 } | 2080 } |
| 2065 } | 2081 } |
| 2066 | 2082 |
| 2067 | 2083 |
| 2068 void HeapSnapshotGenerator::SetRootReference(Object* child_obj) { | 2084 void HeapSnapshotGenerator::SetRootReference(Object* child_obj) { |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2344 "," JSON_S("self_size") | 2360 "," JSON_S("self_size") |
| 2345 "," JSON_S("children_count") | 2361 "," JSON_S("children_count") |
| 2346 "," JSON_S("children")) | 2362 "," JSON_S("children")) |
| 2347 "," JSON_S("types") ":" JSON_A( | 2363 "," JSON_S("types") ":" JSON_A( |
| 2348 JSON_A( | 2364 JSON_A( |
| 2349 JSON_S("internal") | 2365 JSON_S("internal") |
| 2350 "," JSON_S("array") | 2366 "," JSON_S("array") |
| 2351 "," JSON_S("string") | 2367 "," JSON_S("string") |
| 2352 "," JSON_S("object") | 2368 "," JSON_S("object") |
| 2353 "," JSON_S("code") | 2369 "," JSON_S("code") |
| 2354 "," JSON_S("closure")) | 2370 "," JSON_S("closure") |
| 2371 "," JSON_S("regexp")) |
| 2355 "," JSON_S("string") | 2372 "," JSON_S("string") |
| 2356 "," JSON_S("number") | 2373 "," JSON_S("number") |
| 2357 "," JSON_S("number") | 2374 "," JSON_S("number") |
| 2358 "," JSON_S("number") | 2375 "," JSON_S("number") |
| 2359 "," JSON_O( | 2376 "," JSON_O( |
| 2360 JSON_S("fields") ":" JSON_A( | 2377 JSON_S("fields") ":" JSON_A( |
| 2361 JSON_S("type") | 2378 JSON_S("type") |
| 2362 "," JSON_S("name_or_index") | 2379 "," JSON_S("name_or_index") |
| 2363 "," JSON_S("to_node")) | 2380 "," JSON_S("to_node")) |
| 2364 "," JSON_S("types") ":" JSON_A( | 2381 "," JSON_S("types") ":" JSON_A( |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2495 void HeapSnapshotJSONSerializer::SortHashMap( | 2512 void HeapSnapshotJSONSerializer::SortHashMap( |
| 2496 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 2513 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
| 2497 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 2514 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
| 2498 sorted_entries->Add(p); | 2515 sorted_entries->Add(p); |
| 2499 sorted_entries->Sort(SortUsingEntryValue); | 2516 sorted_entries->Sort(SortUsingEntryValue); |
| 2500 } | 2517 } |
| 2501 | 2518 |
| 2502 } } // namespace v8::internal | 2519 } } // namespace v8::internal |
| 2503 | 2520 |
| 2504 #endif // ENABLE_LOGGING_AND_PROFILING | 2521 #endif // ENABLE_LOGGING_AND_PROFILING |
| OLD | NEW |