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 if (Object* getter = accessors->getter()) { | |
yurys
2013/06/24 19:00:37
Can this ever be NULL?
alph
2013/06/25 11:39:36
Done.
| |
1250 SetInternalReference(accessors, entry, | |
1251 "getter", getter, AccessorPair::kGetterOffset); | |
1252 } | |
1253 if (Object* setter = accessors->setter()) { | |
yurys
2013/06/24 19:00:37
And this? I'd think that it is either oddball or s
alph
2013/06/25 11:39:36
Done.
| |
1254 SetInternalReference(accessors, entry, | |
1255 "setter", setter, AccessorPair::kSetterOffset); | |
1256 } | |
1257 } | |
1258 | |
1259 | |
1245 void V8HeapExplorer::ExtractCodeCacheReferences( | 1260 void V8HeapExplorer::ExtractCodeCacheReferences( |
1246 int entry, CodeCache* code_cache) { | 1261 int entry, CodeCache* code_cache) { |
1247 TagObject(code_cache->default_cache(), "(default code cache)"); | 1262 TagObject(code_cache->default_cache(), "(default code cache)"); |
1248 SetInternalReference(code_cache, entry, | 1263 SetInternalReference(code_cache, entry, |
1249 "default_cache", code_cache->default_cache(), | 1264 "default_cache", code_cache->default_cache(), |
1250 CodeCache::kDefaultCacheOffset); | 1265 CodeCache::kDefaultCacheOffset); |
1251 TagObject(code_cache->normal_type_cache(), "(code type cache)"); | 1266 TagObject(code_cache->normal_type_cache(), "(code type cache)"); |
1252 SetInternalReference(code_cache, entry, | 1267 SetInternalReference(code_cache, entry, |
1253 "type_cache", code_cache->normal_type_cache(), | 1268 "type_cache", code_cache->normal_type_cache(), |
1254 CodeCache::kNormalTypeCacheOffset); | 1269 CodeCache::kNormalTypeCacheOffset); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1346 SetInternalReference(js_obj, entry, "hidden_properties", value); | 1361 SetInternalReference(js_obj, entry, "hidden_properties", value); |
1347 } | 1362 } |
1348 } | 1363 } |
1349 break; | 1364 break; |
1350 } | 1365 } |
1351 case CONSTANT_FUNCTION: | 1366 case CONSTANT_FUNCTION: |
1352 SetPropertyReference( | 1367 SetPropertyReference( |
1353 js_obj, entry, | 1368 js_obj, entry, |
1354 descs->GetKey(i), descs->GetConstantFunction(i)); | 1369 descs->GetKey(i), descs->GetConstantFunction(i)); |
1355 break; | 1370 break; |
1356 case CALLBACKS: { | 1371 case CALLBACKS: |
1357 Object* callback_obj = descs->GetValue(i); | 1372 ExtractAccessorPairProperty( |
1358 if (callback_obj->IsAccessorPair()) { | 1373 js_obj, entry, |
1359 AccessorPair* accessors = AccessorPair::cast(callback_obj); | 1374 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; | 1375 break; |
1370 } | |
1371 case NORMAL: // only in slow mode | 1376 case NORMAL: // only in slow mode |
1372 case HANDLER: // only in lookup results, not in descriptors | 1377 case HANDLER: // only in lookup results, not in descriptors |
1373 case INTERCEPTOR: // only in lookup results, not in descriptors | 1378 case INTERCEPTOR: // only in lookup results, not in descriptors |
1374 break; | 1379 break; |
1375 case TRANSITION: | 1380 case TRANSITION: |
1376 case NONEXISTENT: | 1381 case NONEXISTENT: |
1377 UNREACHABLE(); | 1382 UNREACHABLE(); |
1378 break; | 1383 break; |
1379 } | 1384 } |
1380 } | 1385 } |
1381 } else { | 1386 } else { |
1382 NameDictionary* dictionary = js_obj->property_dictionary(); | 1387 NameDictionary* dictionary = js_obj->property_dictionary(); |
1383 int length = dictionary->Capacity(); | 1388 int length = dictionary->Capacity(); |
1384 for (int i = 0; i < length; ++i) { | 1389 for (int i = 0; i < length; ++i) { |
1385 Object* k = dictionary->KeyAt(i); | 1390 Object* k = dictionary->KeyAt(i); |
1386 if (dictionary->IsKey(k)) { | 1391 if (dictionary->IsKey(k)) { |
1387 Object* target = dictionary->ValueAt(i); | 1392 Object* target = dictionary->ValueAt(i); |
1388 // We assume that global objects can only have slow properties. | 1393 // We assume that global objects can only have slow properties. |
1389 Object* value = target->IsPropertyCell() | 1394 Object* value = target->IsPropertyCell() |
1390 ? PropertyCell::cast(target)->value() | 1395 ? PropertyCell::cast(target)->value() |
1391 : target; | 1396 : target; |
1392 if (k != heap_->hidden_string()) { | 1397 if (k == heap_->hidden_string()) { |
1393 SetPropertyReference(js_obj, entry, String::cast(k), value); | |
1394 } else { | |
1395 TagObject(value, "(hidden properties)"); | 1398 TagObject(value, "(hidden properties)"); |
1396 SetInternalReference(js_obj, entry, "hidden_properties", value); | 1399 SetInternalReference(js_obj, entry, "hidden_properties", value); |
1400 continue; | |
1397 } | 1401 } |
1402 ExtractAccessorPairProperty(js_obj, entry, k, value); | |
1403 SetPropertyReference(js_obj, entry, String::cast(k), value); | |
1398 } | 1404 } |
1399 } | 1405 } |
1400 } | 1406 } |
1401 } | 1407 } |
1402 | 1408 |
1403 | 1409 |
1410 void V8HeapExplorer::ExtractAccessorPairProperty( | |
1411 JSObject* js_obj, int entry, Object* key, Object* callback_obj) { | |
1412 if (!callback_obj->IsAccessorPair()) return; | |
1413 AccessorPair* accessors = AccessorPair::cast(callback_obj); | |
1414 Object* getter = accessors->getter(); | |
1415 if (getter && !getter->IsOddball()) { | |
yurys
2013/06/24 19:00:37
Ditto.
alph
2013/06/25 11:39:36
Done.
| |
1416 SetPropertyReference(js_obj, entry, String::cast(key), getter, "get-%s"); | |
1417 } | |
1418 Object* setter = accessors->setter(); | |
1419 if (setter && !setter->IsOddball()) { | |
yurys
2013/06/24 19:00:37
Ditto.
alph
2013/06/25 11:39:36
Done.
| |
1420 SetPropertyReference(js_obj, entry, String::cast(key), setter, "set-%s"); | |
1421 } | |
1422 } | |
1423 | |
1424 | |
1404 void V8HeapExplorer::ExtractElementReferences(JSObject* js_obj, int entry) { | 1425 void V8HeapExplorer::ExtractElementReferences(JSObject* js_obj, int entry) { |
1405 if (js_obj->HasFastObjectElements()) { | 1426 if (js_obj->HasFastObjectElements()) { |
1406 FixedArray* elements = FixedArray::cast(js_obj->elements()); | 1427 FixedArray* elements = FixedArray::cast(js_obj->elements()); |
1407 int length = js_obj->IsJSArray() ? | 1428 int length = js_obj->IsJSArray() ? |
1408 Smi::cast(JSArray::cast(js_obj)->length())->value() : | 1429 Smi::cast(JSArray::cast(js_obj)->length())->value() : |
1409 elements->length(); | 1430 elements->length(); |
1410 for (int i = 0; i < length; ++i) { | 1431 for (int i = 0; i < length; ++i) { |
1411 if (!elements->get(i)->IsTheHole()) { | 1432 if (!elements->get(i)->IsTheHole()) { |
1412 SetElementReference(js_obj, entry, i, elements->get(i)); | 1433 SetElementReference(js_obj, entry, i, elements->get(i)); |
1413 } | 1434 } |
(...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2668 | 2689 |
2669 | 2690 |
2670 void HeapSnapshotJSONSerializer::SortHashMap( | 2691 void HeapSnapshotJSONSerializer::SortHashMap( |
2671 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 2692 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
2672 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 2693 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
2673 sorted_entries->Add(p); | 2694 sorted_entries->Add(p); |
2674 sorted_entries->Sort(SortUsingEntryValue); | 2695 sorted_entries->Sort(SortUsingEntryValue); |
2675 } | 2696 } |
2676 | 2697 |
2677 } } // namespace v8::internal | 2698 } } // namespace v8::internal |
OLD | NEW |