| 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 13 matching lines...) Expand all Loading... |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "heap-snapshot-generator-inl.h" | 30 #include "heap-snapshot-generator-inl.h" |
| 31 | 31 |
| 32 #include "heap-profiler.h" | 32 #include "heap-profiler.h" |
| 33 #include "debug.h" | 33 #include "debug.h" |
| 34 #include "types.h" |
| 34 | 35 |
| 35 namespace v8 { | 36 namespace v8 { |
| 36 namespace internal { | 37 namespace internal { |
| 37 | 38 |
| 38 | 39 |
| 39 HeapGraphEdge::HeapGraphEdge(Type type, const char* name, int from, int to) | 40 HeapGraphEdge::HeapGraphEdge(Type type, const char* name, int from, int to) |
| 40 : type_(type), | 41 : type_(type), |
| 41 from_index_(from), | 42 from_index_(from), |
| 42 to_index_(to), | 43 to_index_(to), |
| 43 name_(name) { | 44 name_(name) { |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 const char* V8HeapExplorer::GetSystemEntryName(HeapObject* object) { | 882 const char* V8HeapExplorer::GetSystemEntryName(HeapObject* object) { |
| 882 switch (object->map()->instance_type()) { | 883 switch (object->map()->instance_type()) { |
| 883 case MAP_TYPE: | 884 case MAP_TYPE: |
| 884 switch (Map::cast(object)->instance_type()) { | 885 switch (Map::cast(object)->instance_type()) { |
| 885 #define MAKE_STRING_MAP_CASE(instance_type, size, name, Name) \ | 886 #define MAKE_STRING_MAP_CASE(instance_type, size, name, Name) \ |
| 886 case instance_type: return "system / Map (" #Name ")"; | 887 case instance_type: return "system / Map (" #Name ")"; |
| 887 STRING_TYPE_LIST(MAKE_STRING_MAP_CASE) | 888 STRING_TYPE_LIST(MAKE_STRING_MAP_CASE) |
| 888 #undef MAKE_STRING_MAP_CASE | 889 #undef MAKE_STRING_MAP_CASE |
| 889 default: return "system / Map"; | 890 default: return "system / Map"; |
| 890 } | 891 } |
| 891 case JS_GLOBAL_PROPERTY_CELL_TYPE: return "system / JSGlobalPropertyCell"; | 892 case CELL_TYPE: return "system / Cell"; |
| 893 case PROPERTY_CELL_TYPE: return "system / JSGlobalPropertyCell"; |
| 892 case FOREIGN_TYPE: return "system / Foreign"; | 894 case FOREIGN_TYPE: return "system / Foreign"; |
| 893 case ODDBALL_TYPE: return "system / Oddball"; | 895 case ODDBALL_TYPE: return "system / Oddball"; |
| 894 #define MAKE_STRUCT_CASE(NAME, Name, name) \ | 896 #define MAKE_STRUCT_CASE(NAME, Name, name) \ |
| 895 case NAME##_TYPE: return "system / "#Name; | 897 case NAME##_TYPE: return "system / "#Name; |
| 896 STRUCT_LIST(MAKE_STRUCT_CASE) | 898 STRUCT_LIST(MAKE_STRUCT_CASE) |
| 897 #undef MAKE_STRUCT_CASE | 899 #undef MAKE_STRUCT_CASE |
| 898 default: return "system"; | 900 default: return "system"; |
| 899 } | 901 } |
| 900 } | 902 } |
| 901 | 903 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 } else if (obj->IsMap()) { | 971 } else if (obj->IsMap()) { |
| 970 ExtractMapReferences(entry, Map::cast(obj)); | 972 ExtractMapReferences(entry, Map::cast(obj)); |
| 971 } else if (obj->IsSharedFunctionInfo()) { | 973 } else if (obj->IsSharedFunctionInfo()) { |
| 972 ExtractSharedFunctionInfoReferences(entry, SharedFunctionInfo::cast(obj)); | 974 ExtractSharedFunctionInfoReferences(entry, SharedFunctionInfo::cast(obj)); |
| 973 } else if (obj->IsScript()) { | 975 } else if (obj->IsScript()) { |
| 974 ExtractScriptReferences(entry, Script::cast(obj)); | 976 ExtractScriptReferences(entry, Script::cast(obj)); |
| 975 } else if (obj->IsCodeCache()) { | 977 } else if (obj->IsCodeCache()) { |
| 976 ExtractCodeCacheReferences(entry, CodeCache::cast(obj)); | 978 ExtractCodeCacheReferences(entry, CodeCache::cast(obj)); |
| 977 } else if (obj->IsCode()) { | 979 } else if (obj->IsCode()) { |
| 978 ExtractCodeReferences(entry, Code::cast(obj)); | 980 ExtractCodeReferences(entry, Code::cast(obj)); |
| 981 } else if (obj->IsCell()) { |
| 982 ExtractCellReferences(entry, Cell::cast(obj)); |
| 983 extract_indexed_refs = false; |
| 979 } else if (obj->IsJSGlobalPropertyCell()) { | 984 } else if (obj->IsJSGlobalPropertyCell()) { |
| 980 ExtractJSGlobalPropertyCellReferences( | 985 ExtractJSGlobalPropertyCellReferences( |
| 981 entry, JSGlobalPropertyCell::cast(obj)); | 986 entry, JSGlobalPropertyCell::cast(obj)); |
| 982 extract_indexed_refs = false; | 987 extract_indexed_refs = false; |
| 983 } | 988 } |
| 984 if (extract_indexed_refs) { | 989 if (extract_indexed_refs) { |
| 985 SetInternalReference(obj, entry, "map", obj->map(), HeapObject::kMapOffset); | 990 SetInternalReference(obj, entry, "map", obj->map(), HeapObject::kMapOffset); |
| 986 IndexedReferencesExtractor refs_extractor(this, obj, entry); | 991 IndexedReferencesExtractor refs_extractor(this, obj, entry); |
| 987 obj->Iterate(&refs_extractor); | 992 obj->Iterate(&refs_extractor); |
| 988 } | 993 } |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 SetInternalReference(code, entry, | 1271 SetInternalReference(code, entry, |
| 1267 "type_feedback_info", code->type_feedback_info(), | 1272 "type_feedback_info", code->type_feedback_info(), |
| 1268 Code::kTypeFeedbackInfoOffset); | 1273 Code::kTypeFeedbackInfoOffset); |
| 1269 } | 1274 } |
| 1270 SetInternalReference(code, entry, | 1275 SetInternalReference(code, entry, |
| 1271 "gc_metadata", code->gc_metadata(), | 1276 "gc_metadata", code->gc_metadata(), |
| 1272 Code::kGCMetadataOffset); | 1277 Code::kGCMetadataOffset); |
| 1273 } | 1278 } |
| 1274 | 1279 |
| 1275 | 1280 |
| 1281 void V8HeapExplorer::ExtractCellReferences(int entry, Cell* cell) { |
| 1282 SetInternalReference(cell, entry, "value", cell->value()); |
| 1283 } |
| 1284 |
| 1285 |
| 1276 void V8HeapExplorer::ExtractJSGlobalPropertyCellReferences( | 1286 void V8HeapExplorer::ExtractJSGlobalPropertyCellReferences( |
| 1277 int entry, JSGlobalPropertyCell* cell) { | 1287 int entry, JSGlobalPropertyCell* cell) { |
| 1278 SetInternalReference(cell, entry, "value", cell->value()); | 1288 SetInternalReference(cell, entry, "value", cell->value()); |
| 1289 SetInternalReference(cell, entry, "type", cell->type()); |
| 1279 } | 1290 } |
| 1280 | 1291 |
| 1281 | 1292 |
| 1282 void V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj, int entry) { | 1293 void V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj, int entry) { |
| 1283 if (!js_obj->IsJSFunction()) return; | 1294 if (!js_obj->IsJSFunction()) return; |
| 1284 | 1295 |
| 1285 JSFunction* func = JSFunction::cast(js_obj); | 1296 JSFunction* func = JSFunction::cast(js_obj); |
| 1286 if (func->shared()->bound()) { | 1297 if (func->shared()->bound()) { |
| 1287 FixedArray* bindings = func->function_bindings(); | 1298 FixedArray* bindings = func->function_bindings(); |
| 1288 SetNativeBindReference(js_obj, entry, "bound_this", | 1299 SetNativeBindReference(js_obj, entry, "bound_this", |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1555 } | 1566 } |
| 1556 | 1567 |
| 1557 | 1568 |
| 1558 bool V8HeapExplorer::IsEssentialObject(Object* object) { | 1569 bool V8HeapExplorer::IsEssentialObject(Object* object) { |
| 1559 return object->IsHeapObject() | 1570 return object->IsHeapObject() |
| 1560 && !object->IsOddball() | 1571 && !object->IsOddball() |
| 1561 && object != heap_->empty_byte_array() | 1572 && object != heap_->empty_byte_array() |
| 1562 && object != heap_->empty_fixed_array() | 1573 && object != heap_->empty_fixed_array() |
| 1563 && object != heap_->empty_descriptor_array() | 1574 && object != heap_->empty_descriptor_array() |
| 1564 && object != heap_->fixed_array_map() | 1575 && object != heap_->fixed_array_map() |
| 1576 && object != heap_->cell_map() |
| 1565 && object != heap_->global_property_cell_map() | 1577 && object != heap_->global_property_cell_map() |
| 1566 && object != heap_->shared_function_info_map() | 1578 && object != heap_->shared_function_info_map() |
| 1567 && object != heap_->free_space_map() | 1579 && object != heap_->free_space_map() |
| 1568 && object != heap_->one_pointer_filler_map() | 1580 && object != heap_->one_pointer_filler_map() |
| 1569 && object != heap_->two_pointer_filler_map(); | 1581 && object != heap_->two_pointer_filler_map(); |
| 1570 } | 1582 } |
| 1571 | 1583 |
| 1572 | 1584 |
| 1573 void V8HeapExplorer::SetContextReference(HeapObject* parent_obj, | 1585 void V8HeapExplorer::SetContextReference(HeapObject* parent_obj, |
| 1574 int parent_entry, | 1586 int parent_entry, |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2203 Isolate::Current()->heap()->CollectAllGarbage( | 2215 Isolate::Current()->heap()->CollectAllGarbage( |
| 2204 Heap::kMakeHeapIterableMask, | 2216 Heap::kMakeHeapIterableMask, |
| 2205 "HeapSnapshotGenerator::GenerateSnapshot"); | 2217 "HeapSnapshotGenerator::GenerateSnapshot"); |
| 2206 | 2218 |
| 2207 #ifdef VERIFY_HEAP | 2219 #ifdef VERIFY_HEAP |
| 2208 Heap* debug_heap = Isolate::Current()->heap(); | 2220 Heap* debug_heap = Isolate::Current()->heap(); |
| 2209 CHECK(!debug_heap->old_data_space()->was_swept_conservatively()); | 2221 CHECK(!debug_heap->old_data_space()->was_swept_conservatively()); |
| 2210 CHECK(!debug_heap->old_pointer_space()->was_swept_conservatively()); | 2222 CHECK(!debug_heap->old_pointer_space()->was_swept_conservatively()); |
| 2211 CHECK(!debug_heap->code_space()->was_swept_conservatively()); | 2223 CHECK(!debug_heap->code_space()->was_swept_conservatively()); |
| 2212 CHECK(!debug_heap->cell_space()->was_swept_conservatively()); | 2224 CHECK(!debug_heap->cell_space()->was_swept_conservatively()); |
| 2225 CHECK(!debug_heap->property_cell_space()-> |
| 2226 was_swept_conservatively()); |
| 2213 CHECK(!debug_heap->map_space()->was_swept_conservatively()); | 2227 CHECK(!debug_heap->map_space()->was_swept_conservatively()); |
| 2214 #endif | 2228 #endif |
| 2215 | 2229 |
| 2216 // The following code uses heap iterators, so we want the heap to be | 2230 // The following code uses heap iterators, so we want the heap to be |
| 2217 // stable. It should follow TagGlobalObjects as that can allocate. | 2231 // stable. It should follow TagGlobalObjects as that can allocate. |
| 2218 DisallowHeapAllocation no_alloc; | 2232 DisallowHeapAllocation no_alloc; |
| 2219 | 2233 |
| 2220 #ifdef VERIFY_HEAP | 2234 #ifdef VERIFY_HEAP |
| 2221 debug_heap->Verify(); | 2235 debug_heap->Verify(); |
| 2222 #endif | 2236 #endif |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2654 | 2668 |
| 2655 | 2669 |
| 2656 void HeapSnapshotJSONSerializer::SortHashMap( | 2670 void HeapSnapshotJSONSerializer::SortHashMap( |
| 2657 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 2671 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
| 2658 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 2672 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
| 2659 sorted_entries->Add(p); | 2673 sorted_entries->Add(p); |
| 2660 sorted_entries->Sort(SortUsingEntryValue); | 2674 sorted_entries->Sort(SortUsingEntryValue); |
| 2661 } | 2675 } |
| 2662 | 2676 |
| 2663 } } // namespace v8::internal | 2677 } } // namespace v8::internal |
| OLD | NEW |