| 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 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 | 885 |
| 886 | 886 |
| 887 class IndexedReferencesExtractor : public ObjectVisitor { | 887 class IndexedReferencesExtractor : public ObjectVisitor { |
| 888 public: | 888 public: |
| 889 IndexedReferencesExtractor(V8HeapExplorer* generator, | 889 IndexedReferencesExtractor(V8HeapExplorer* generator, |
| 890 HeapObject* parent_obj, | 890 HeapObject* parent_obj, |
| 891 int parent) | 891 int parent) |
| 892 : generator_(generator), | 892 : generator_(generator), |
| 893 parent_obj_(parent_obj), | 893 parent_obj_(parent_obj), |
| 894 parent_(parent), | 894 parent_(parent), |
| 895 next_index_(1) { | 895 next_index_(0) { |
| 896 } |
| 897 void VisitCodeEntry(Address entry_address) { |
| 898 Code* code = Code::cast(Code::GetObjectFromEntryAddress(entry_address)); |
| 899 generator_->SetInternalReference(parent_obj_, parent_, "code", code); |
| 900 generator_->TagObject(code, "(code)"); |
| 896 } | 901 } |
| 897 void VisitPointers(Object** start, Object** end) { | 902 void VisitPointers(Object** start, Object** end) { |
| 898 for (Object** p = start; p < end; p++) { | 903 for (Object** p = start; p < end; p++) { |
| 899 if (CheckVisitedAndUnmark(p)) continue; | 904 if (CheckVisitedAndUnmark(p)) continue; |
| 900 generator_->SetHiddenReference(parent_obj_, parent_, next_index_++, *p); | 905 generator_->SetHiddenReference(parent_obj_, parent_, next_index_++, *p); |
| 901 } | 906 } |
| 902 } | 907 } |
| 903 static void MarkVisitedField(HeapObject* obj, int offset) { | 908 static void MarkVisitedField(HeapObject* obj, int offset) { |
| 904 if (offset < 0) return; | 909 if (offset < 0) return; |
| 905 Address field = obj->address() + offset; | 910 Address field = obj->address() + offset; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 if (!proto_or_map->IsMap()) { | 995 if (!proto_or_map->IsMap()) { |
| 991 SetPropertyReference( | 996 SetPropertyReference( |
| 992 obj, entry, | 997 obj, entry, |
| 993 heap_->prototype_string(), proto_or_map, | 998 heap_->prototype_string(), proto_or_map, |
| 994 NULL, | 999 NULL, |
| 995 JSFunction::kPrototypeOrInitialMapOffset); | 1000 JSFunction::kPrototypeOrInitialMapOffset); |
| 996 } else { | 1001 } else { |
| 997 SetPropertyReference( | 1002 SetPropertyReference( |
| 998 obj, entry, | 1003 obj, entry, |
| 999 heap_->prototype_string(), js_fun->prototype()); | 1004 heap_->prototype_string(), js_fun->prototype()); |
| 1005 SetInternalReference( |
| 1006 obj, entry, "initial_map", proto_or_map, |
| 1007 JSFunction::kPrototypeOrInitialMapOffset); |
| 1000 } | 1008 } |
| 1001 } | 1009 } |
| 1002 SharedFunctionInfo* shared_info = js_fun->shared(); | 1010 SharedFunctionInfo* shared_info = js_fun->shared(); |
| 1003 // JSFunction has either bindings or literals and never both. | 1011 // JSFunction has either bindings or literals and never both. |
| 1004 bool bound = shared_info->bound(); | 1012 bool bound = shared_info->bound(); |
| 1005 TagObject(js_fun->literals_or_bindings(), | 1013 TagObject(js_fun->literals_or_bindings(), |
| 1006 bound ? "(function bindings)" : "(function literals)"); | 1014 bound ? "(function bindings)" : "(function literals)"); |
| 1007 SetInternalReference(js_fun, entry, | 1015 SetInternalReference(js_fun, entry, |
| 1008 bound ? "bindings" : "literals", | 1016 bound ? "bindings" : "literals", |
| 1009 js_fun->literals_or_bindings(), | 1017 js_fun->literals_or_bindings(), |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 Map::kDescriptorsOffset); | 1140 Map::kDescriptorsOffset); |
| 1133 | 1141 |
| 1134 SetInternalReference(map, entry, | 1142 SetInternalReference(map, entry, |
| 1135 "code_cache", map->code_cache(), | 1143 "code_cache", map->code_cache(), |
| 1136 Map::kCodeCacheOffset); | 1144 Map::kCodeCacheOffset); |
| 1137 SetInternalReference(map, entry, | 1145 SetInternalReference(map, entry, |
| 1138 "prototype", map->prototype(), Map::kPrototypeOffset); | 1146 "prototype", map->prototype(), Map::kPrototypeOffset); |
| 1139 SetInternalReference(map, entry, | 1147 SetInternalReference(map, entry, |
| 1140 "constructor", map->constructor(), | 1148 "constructor", map->constructor(), |
| 1141 Map::kConstructorOffset); | 1149 Map::kConstructorOffset); |
| 1150 TagObject(map->dependent_code(), "(dependent code)"); |
| 1151 SetInternalReference(map, entry, |
| 1152 "dependent_code", map->dependent_code(), |
| 1153 Map::kDependentCodeOffset); |
| 1142 } | 1154 } |
| 1143 | 1155 |
| 1144 | 1156 |
| 1145 void V8HeapExplorer::ExtractSharedFunctionInfoReferences( | 1157 void V8HeapExplorer::ExtractSharedFunctionInfoReferences( |
| 1146 int entry, SharedFunctionInfo* shared) { | 1158 int entry, SharedFunctionInfo* shared) { |
| 1147 HeapObject* obj = shared; | 1159 HeapObject* obj = shared; |
| 1148 SetInternalReference(obj, entry, | 1160 SetInternalReference(obj, entry, |
| 1149 "name", shared->name(), | 1161 "name", shared->name(), |
| 1150 SharedFunctionInfo::kNameOffset); | 1162 SharedFunctionInfo::kNameOffset); |
| 1151 TagObject(shared->code(), "(code)"); | 1163 TagObject(shared->code(), "(code)"); |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1666 } | 1678 } |
| 1667 | 1679 |
| 1668 | 1680 |
| 1669 void V8HeapExplorer::SetWeakReference(HeapObject* parent_obj, | 1681 void V8HeapExplorer::SetWeakReference(HeapObject* parent_obj, |
| 1670 int parent_entry, | 1682 int parent_entry, |
| 1671 int index, | 1683 int index, |
| 1672 Object* child_obj, | 1684 Object* child_obj, |
| 1673 int field_offset) { | 1685 int field_offset) { |
| 1674 ASSERT(parent_entry == GetEntry(parent_obj)->index()); | 1686 ASSERT(parent_entry == GetEntry(parent_obj)->index()); |
| 1675 HeapEntry* child_entry = GetEntry(child_obj); | 1687 HeapEntry* child_entry = GetEntry(child_obj); |
| 1676 if (child_entry != NULL) { | 1688 if (child_entry == NULL) return; |
| 1689 if (IsEssentialObject(child_obj)) { |
| 1677 filler_->SetIndexedReference(HeapGraphEdge::kWeak, | 1690 filler_->SetIndexedReference(HeapGraphEdge::kWeak, |
| 1678 parent_entry, | 1691 parent_entry, |
| 1679 index, | 1692 index, |
| 1680 child_entry); | 1693 child_entry); |
| 1681 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset); | |
| 1682 } | 1694 } |
| 1695 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset); |
| 1683 } | 1696 } |
| 1684 | 1697 |
| 1685 | 1698 |
| 1686 void V8HeapExplorer::SetPropertyReference(HeapObject* parent_obj, | 1699 void V8HeapExplorer::SetPropertyReference(HeapObject* parent_obj, |
| 1687 int parent_entry, | 1700 int parent_entry, |
| 1688 Name* reference_name, | 1701 Name* reference_name, |
| 1689 Object* child_obj, | 1702 Object* child_obj, |
| 1690 const char* name_format_string, | 1703 const char* name_format_string, |
| 1691 int field_offset) { | 1704 int field_offset) { |
| 1692 ASSERT(parent_entry == GetEntry(parent_obj)->index()); | 1705 ASSERT(parent_entry == GetEntry(parent_obj)->index()); |
| (...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2680 | 2693 |
| 2681 | 2694 |
| 2682 void HeapSnapshotJSONSerializer::SortHashMap( | 2695 void HeapSnapshotJSONSerializer::SortHashMap( |
| 2683 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 2696 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
| 2684 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 2697 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
| 2685 sorted_entries->Add(p); | 2698 sorted_entries->Add(p); |
| 2686 sorted_entries->Sort(SortUsingEntryValue); | 2699 sorted_entries->Sort(SortUsingEntryValue); |
| 2687 } | 2700 } |
| 2688 | 2701 |
| 2689 } } // namespace v8::internal | 2702 } } // namespace v8::internal |
| OLD | NEW |