OLD | NEW |
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 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 } else if (obj->IsString()) { | 967 } else if (obj->IsString()) { |
968 ExtractStringReferences(entry, String::cast(obj)); | 968 ExtractStringReferences(entry, String::cast(obj)); |
969 } else if (obj->IsContext()) { | 969 } else if (obj->IsContext()) { |
970 ExtractContextReferences(entry, Context::cast(obj)); | 970 ExtractContextReferences(entry, Context::cast(obj)); |
971 } else if (obj->IsMap()) { | 971 } else if (obj->IsMap()) { |
972 ExtractMapReferences(entry, Map::cast(obj)); | 972 ExtractMapReferences(entry, Map::cast(obj)); |
973 } else if (obj->IsSharedFunctionInfo()) { | 973 } else if (obj->IsSharedFunctionInfo()) { |
974 ExtractSharedFunctionInfoReferences(entry, SharedFunctionInfo::cast(obj)); | 974 ExtractSharedFunctionInfoReferences(entry, SharedFunctionInfo::cast(obj)); |
975 } else if (obj->IsScript()) { | 975 } else if (obj->IsScript()) { |
976 ExtractScriptReferences(entry, Script::cast(obj)); | 976 ExtractScriptReferences(entry, Script::cast(obj)); |
| 977 } else if (obj->IsAccessorPair()) { |
| 978 ExtractAccessorPairReferences(entry, AccessorPair::cast(obj)); |
977 } else if (obj->IsCodeCache()) { | 979 } else if (obj->IsCodeCache()) { |
978 ExtractCodeCacheReferences(entry, CodeCache::cast(obj)); | 980 ExtractCodeCacheReferences(entry, CodeCache::cast(obj)); |
979 } else if (obj->IsCode()) { | 981 } else if (obj->IsCode()) { |
980 ExtractCodeReferences(entry, Code::cast(obj)); | 982 ExtractCodeReferences(entry, Code::cast(obj)); |
981 } else if (obj->IsCell()) { | 983 } else if (obj->IsCell()) { |
982 ExtractCellReferences(entry, Cell::cast(obj)); | 984 ExtractCellReferences(entry, Cell::cast(obj)); |
983 extract_indexed_refs = false; | 985 extract_indexed_refs = false; |
984 } else if (obj->IsPropertyCell()) { | 986 } else if (obj->IsPropertyCell()) { |
985 ExtractPropertyCellReferences( | 987 ExtractPropertyCellReferences( |
986 entry, PropertyCell::cast(obj)); | 988 entry, PropertyCell::cast(obj)); |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 SetInternalReference(obj, entry, | 1237 SetInternalReference(obj, entry, |
1236 "context_data", script->context_data(), | 1238 "context_data", script->context_data(), |
1237 Script::kContextOffset); | 1239 Script::kContextOffset); |
1238 TagObject(script->line_ends(), "(script line ends)"); | 1240 TagObject(script->line_ends(), "(script line ends)"); |
1239 SetInternalReference(obj, entry, | 1241 SetInternalReference(obj, entry, |
1240 "line_ends", script->line_ends(), | 1242 "line_ends", script->line_ends(), |
1241 Script::kLineEndsOffset); | 1243 Script::kLineEndsOffset); |
1242 } | 1244 } |
1243 | 1245 |
1244 | 1246 |
| 1247 void V8HeapExplorer::ExtractAccessorPairReferences( |
| 1248 int entry, AccessorPair* accessors) { |
| 1249 SetInternalReference(accessors, entry, "getter", accessors->getter(), |
| 1250 AccessorPair::kGetterOffset); |
| 1251 SetInternalReference(accessors, entry, "setter", accessors->setter(), |
| 1252 AccessorPair::kSetterOffset); |
| 1253 } |
| 1254 |
| 1255 |
1245 void V8HeapExplorer::ExtractCodeCacheReferences( | 1256 void V8HeapExplorer::ExtractCodeCacheReferences( |
1246 int entry, CodeCache* code_cache) { | 1257 int entry, CodeCache* code_cache) { |
1247 TagObject(code_cache->default_cache(), "(default code cache)"); | 1258 TagObject(code_cache->default_cache(), "(default code cache)"); |
1248 SetInternalReference(code_cache, entry, | 1259 SetInternalReference(code_cache, entry, |
1249 "default_cache", code_cache->default_cache(), | 1260 "default_cache", code_cache->default_cache(), |
1250 CodeCache::kDefaultCacheOffset); | 1261 CodeCache::kDefaultCacheOffset); |
1251 TagObject(code_cache->normal_type_cache(), "(code type cache)"); | 1262 TagObject(code_cache->normal_type_cache(), "(code type cache)"); |
1252 SetInternalReference(code_cache, entry, | 1263 SetInternalReference(code_cache, entry, |
1253 "type_cache", code_cache->normal_type_cache(), | 1264 "type_cache", code_cache->normal_type_cache(), |
1254 CodeCache::kNormalTypeCacheOffset); | 1265 CodeCache::kNormalTypeCacheOffset); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 SetInternalReference(js_obj, entry, "hidden_properties", value); | 1357 SetInternalReference(js_obj, entry, "hidden_properties", value); |
1347 } | 1358 } |
1348 } | 1359 } |
1349 break; | 1360 break; |
1350 } | 1361 } |
1351 case CONSTANT_FUNCTION: | 1362 case CONSTANT_FUNCTION: |
1352 SetPropertyReference( | 1363 SetPropertyReference( |
1353 js_obj, entry, | 1364 js_obj, entry, |
1354 descs->GetKey(i), descs->GetConstantFunction(i)); | 1365 descs->GetKey(i), descs->GetConstantFunction(i)); |
1355 break; | 1366 break; |
1356 case CALLBACKS: { | 1367 case CALLBACKS: |
1357 Object* callback_obj = descs->GetValue(i); | 1368 ExtractAccessorPairProperty( |
1358 if (callback_obj->IsAccessorPair()) { | 1369 js_obj, entry, |
1359 AccessorPair* accessors = AccessorPair::cast(callback_obj); | 1370 descs->GetKey(i), descs->GetValue(i)); |
1360 if (Object* getter = accessors->getter()) { | |
1361 SetPropertyReference(js_obj, entry, descs->GetKey(i), | |
1362 getter, "get-%s"); | |
1363 } | |
1364 if (Object* setter = accessors->setter()) { | |
1365 SetPropertyReference(js_obj, entry, descs->GetKey(i), | |
1366 setter, "set-%s"); | |
1367 } | |
1368 } | |
1369 break; | 1371 break; |
1370 } | |
1371 case NORMAL: // only in slow mode | 1372 case NORMAL: // only in slow mode |
1372 case HANDLER: // only in lookup results, not in descriptors | 1373 case HANDLER: // only in lookup results, not in descriptors |
1373 case INTERCEPTOR: // only in lookup results, not in descriptors | 1374 case INTERCEPTOR: // only in lookup results, not in descriptors |
1374 break; | 1375 break; |
1375 case TRANSITION: | 1376 case TRANSITION: |
1376 case NONEXISTENT: | 1377 case NONEXISTENT: |
1377 UNREACHABLE(); | 1378 UNREACHABLE(); |
1378 break; | 1379 break; |
1379 } | 1380 } |
1380 } | 1381 } |
1381 } else { | 1382 } else { |
1382 NameDictionary* dictionary = js_obj->property_dictionary(); | 1383 NameDictionary* dictionary = js_obj->property_dictionary(); |
1383 int length = dictionary->Capacity(); | 1384 int length = dictionary->Capacity(); |
1384 for (int i = 0; i < length; ++i) { | 1385 for (int i = 0; i < length; ++i) { |
1385 Object* k = dictionary->KeyAt(i); | 1386 Object* k = dictionary->KeyAt(i); |
1386 if (dictionary->IsKey(k)) { | 1387 if (dictionary->IsKey(k)) { |
1387 Object* target = dictionary->ValueAt(i); | 1388 Object* target = dictionary->ValueAt(i); |
1388 // We assume that global objects can only have slow properties. | 1389 // We assume that global objects can only have slow properties. |
1389 Object* value = target->IsPropertyCell() | 1390 Object* value = target->IsPropertyCell() |
1390 ? PropertyCell::cast(target)->value() | 1391 ? PropertyCell::cast(target)->value() |
1391 : target; | 1392 : target; |
1392 if (k != heap_->hidden_string()) { | 1393 if (k == heap_->hidden_string()) { |
1393 SetPropertyReference(js_obj, entry, String::cast(k), value); | |
1394 } else { | |
1395 TagObject(value, "(hidden properties)"); | 1394 TagObject(value, "(hidden properties)"); |
1396 SetInternalReference(js_obj, entry, "hidden_properties", value); | 1395 SetInternalReference(js_obj, entry, "hidden_properties", value); |
| 1396 continue; |
1397 } | 1397 } |
| 1398 if (ExtractAccessorPairProperty(js_obj, entry, k, value)) continue; |
| 1399 SetPropertyReference(js_obj, entry, String::cast(k), value); |
1398 } | 1400 } |
1399 } | 1401 } |
1400 } | 1402 } |
1401 } | 1403 } |
1402 | 1404 |
1403 | 1405 |
| 1406 bool V8HeapExplorer::ExtractAccessorPairProperty( |
| 1407 JSObject* js_obj, int entry, Object* key, Object* callback_obj) { |
| 1408 if (!callback_obj->IsAccessorPair()) return false; |
| 1409 AccessorPair* accessors = AccessorPair::cast(callback_obj); |
| 1410 Object* getter = accessors->getter(); |
| 1411 if (!getter->IsOddball()) { |
| 1412 SetPropertyReference(js_obj, entry, String::cast(key), getter, "get %s"); |
| 1413 } |
| 1414 Object* setter = accessors->setter(); |
| 1415 if (!setter->IsOddball()) { |
| 1416 SetPropertyReference(js_obj, entry, String::cast(key), setter, "set %s"); |
| 1417 } |
| 1418 return true; |
| 1419 } |
| 1420 |
| 1421 |
1404 void V8HeapExplorer::ExtractElementReferences(JSObject* js_obj, int entry) { | 1422 void V8HeapExplorer::ExtractElementReferences(JSObject* js_obj, int entry) { |
1405 if (js_obj->HasFastObjectElements()) { | 1423 if (js_obj->HasFastObjectElements()) { |
1406 FixedArray* elements = FixedArray::cast(js_obj->elements()); | 1424 FixedArray* elements = FixedArray::cast(js_obj->elements()); |
1407 int length = js_obj->IsJSArray() ? | 1425 int length = js_obj->IsJSArray() ? |
1408 Smi::cast(JSArray::cast(js_obj)->length())->value() : | 1426 Smi::cast(JSArray::cast(js_obj)->length())->value() : |
1409 elements->length(); | 1427 elements->length(); |
1410 for (int i = 0; i < length; ++i) { | 1428 for (int i = 0; i < length; ++i) { |
1411 if (!elements->get(i)->IsTheHole()) { | 1429 if (!elements->get(i)->IsTheHole()) { |
1412 SetElementReference(js_obj, entry, i, elements->get(i)); | 1430 SetElementReference(js_obj, entry, i, elements->get(i)); |
1413 } | 1431 } |
(...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2668 | 2686 |
2669 | 2687 |
2670 void HeapSnapshotJSONSerializer::SortHashMap( | 2688 void HeapSnapshotJSONSerializer::SortHashMap( |
2671 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 2689 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
2672 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 2690 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
2673 sorted_entries->Add(p); | 2691 sorted_entries->Add(p); |
2674 sorted_entries->Sort(SortUsingEntryValue); | 2692 sorted_entries->Sort(SortUsingEntryValue); |
2675 } | 2693 } |
2676 | 2694 |
2677 } } // namespace v8::internal | 2695 } } // namespace v8::internal |
OLD | NEW |