| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 if (strcmp(entry->name(), "C2") == 0) has_C2 = true; | 62 if (strcmp(entry->name(), "C2") == 0) has_C2 = true; |
| 63 } | 63 } |
| 64 | 64 |
| 65 void CheckAllReachables(i::HeapEntry* root) { | 65 void CheckAllReachables(i::HeapEntry* root) { |
| 66 v8::base::HashMap visited; | 66 v8::base::HashMap visited; |
| 67 i::List<i::HeapEntry*> list(10); | 67 i::List<i::HeapEntry*> list(10); |
| 68 list.Add(root); | 68 list.Add(root); |
| 69 CheckEntry(root); | 69 CheckEntry(root); |
| 70 while (!list.is_empty()) { | 70 while (!list.is_empty()) { |
| 71 i::HeapEntry* entry = list.RemoveLast(); | 71 i::HeapEntry* entry = list.RemoveLast(); |
| 72 i::Vector<i::HeapGraphEdge*> children = entry->children(); | 72 for (int i = 0; i < entry->children_count(); ++i) { |
| 73 for (int i = 0; i < children.length(); ++i) { | 73 i::HeapGraphEdge* edge = entry->child(i); |
| 74 if (children[i]->type() == i::HeapGraphEdge::kShortcut) continue; | 74 if (edge->type() == i::HeapGraphEdge::kShortcut) continue; |
| 75 i::HeapEntry* child = children[i]->to(); | 75 i::HeapEntry* child = edge->to(); |
| 76 v8::base::HashMap::Entry* entry = visited.LookupOrInsert( | 76 v8::base::HashMap::Entry* entry = visited.LookupOrInsert( |
| 77 reinterpret_cast<void*>(child), | 77 reinterpret_cast<void*>(child), |
| 78 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(child))); | 78 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(child))); |
| 79 if (entry->value) | 79 if (entry->value) |
| 80 continue; | 80 continue; |
| 81 entry->value = reinterpret_cast<void*>(1); | 81 entry->value = reinterpret_cast<void*>(1); |
| 82 list.Add(child); | 82 list.Add(child); |
| 83 CheckEntry(child); | 83 CheckEntry(child); |
| 84 } | 84 } |
| 85 } | 85 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 return false; | 130 return false; |
| 131 } | 131 } |
| 132 | 132 |
| 133 | 133 |
| 134 // Check that snapshot has no unretained entries except root. | 134 // Check that snapshot has no unretained entries except root. |
| 135 static bool ValidateSnapshot(const v8::HeapSnapshot* snapshot, int depth = 3) { | 135 static bool ValidateSnapshot(const v8::HeapSnapshot* snapshot, int depth = 3) { |
| 136 i::HeapSnapshot* heap_snapshot = const_cast<i::HeapSnapshot*>( | 136 i::HeapSnapshot* heap_snapshot = const_cast<i::HeapSnapshot*>( |
| 137 reinterpret_cast<const i::HeapSnapshot*>(snapshot)); | 137 reinterpret_cast<const i::HeapSnapshot*>(snapshot)); |
| 138 | 138 |
| 139 v8::base::HashMap visited; | 139 v8::base::HashMap visited; |
| 140 i::List<i::HeapGraphEdge>& edges = heap_snapshot->edges(); | 140 std::deque<i::HeapGraphEdge>& edges = heap_snapshot->edges(); |
| 141 for (int i = 0; i < edges.length(); ++i) { | 141 for (size_t i = 0; i < edges.size(); ++i) { |
| 142 v8::base::HashMap::Entry* entry = visited.LookupOrInsert( | 142 v8::base::HashMap::Entry* entry = visited.LookupOrInsert( |
| 143 reinterpret_cast<void*>(edges[i].to()), | 143 reinterpret_cast<void*>(edges[i].to()), |
| 144 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(edges[i].to()))); | 144 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(edges[i].to()))); |
| 145 uint32_t ref_count = static_cast<uint32_t>( | 145 uint32_t ref_count = static_cast<uint32_t>( |
| 146 reinterpret_cast<uintptr_t>(entry->value)); | 146 reinterpret_cast<uintptr_t>(entry->value)); |
| 147 entry->value = reinterpret_cast<void*>(ref_count + 1); | 147 entry->value = reinterpret_cast<void*>(ref_count + 1); |
| 148 } | 148 } |
| 149 uint32_t unretained_entries_count = 0; | 149 uint32_t unretained_entries_count = 0; |
| 150 i::List<i::HeapEntry>& entries = heap_snapshot->entries(); | 150 i::List<i::HeapEntry>& entries = heap_snapshot->entries(); |
| 151 for (int i = 0; i < entries.length(); ++i) { | 151 for (int i = 0; i < entries.length(); ++i) { |
| (...skipping 2950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3102 " a[i] = i;\n" | 3102 " a[i] = i;\n" |
| 3103 " for (var i = 0; i < 3; ++i)\n" | 3103 " for (var i = 0; i < 3; ++i)\n" |
| 3104 " a.shift();\n" | 3104 " a.shift();\n" |
| 3105 "}\n"); | 3105 "}\n"); |
| 3106 | 3106 |
| 3107 CcTest::CollectGarbage(v8::internal::NEW_SPACE); | 3107 CcTest::CollectGarbage(v8::internal::NEW_SPACE); |
| 3108 // Should not crash. | 3108 // Should not crash. |
| 3109 | 3109 |
| 3110 heap_profiler->StopSamplingHeapProfiler(); | 3110 heap_profiler->StopSamplingHeapProfiler(); |
| 3111 } | 3111 } |
| OLD | NEW |