Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: test/cctest/test-heap-profiler.cc

Issue 1074943002: Split TemplateHashMapImpl::Lookup into two methods (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix arm (and ppc) builds Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« test/cctest/test-api.cc ('K') | « test/cctest/test-hashmap.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 i::HashMap visited(AddressesMatch); 67 i::HashMap visited(AddressesMatch);
68 i::List<i::HeapEntry*> list(10); 68 i::List<i::HeapEntry*> list(10);
69 list.Add(root); 69 list.Add(root);
70 CheckEntry(root); 70 CheckEntry(root);
71 while (!list.is_empty()) { 71 while (!list.is_empty()) {
72 i::HeapEntry* entry = list.RemoveLast(); 72 i::HeapEntry* entry = list.RemoveLast();
73 i::Vector<i::HeapGraphEdge*> children = entry->children(); 73 i::Vector<i::HeapGraphEdge*> children = entry->children();
74 for (int i = 0; i < children.length(); ++i) { 74 for (int i = 0; i < children.length(); ++i) {
75 if (children[i]->type() == i::HeapGraphEdge::kShortcut) continue; 75 if (children[i]->type() == i::HeapGraphEdge::kShortcut) continue;
76 i::HeapEntry* child = children[i]->to(); 76 i::HeapEntry* child = children[i]->to();
77 i::HashMap::Entry* entry = visited.Lookup( 77 i::HashMap::Entry* entry = visited.LookupOrInsert(
78 reinterpret_cast<void*>(child), 78 reinterpret_cast<void*>(child),
79 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(child)), 79 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(child)));
80 true);
81 if (entry->value) 80 if (entry->value)
82 continue; 81 continue;
83 entry->value = reinterpret_cast<void*>(1); 82 entry->value = reinterpret_cast<void*>(1);
84 list.Add(child); 83 list.Add(child);
85 CheckEntry(child); 84 CheckEntry(child);
86 } 85 }
87 } 86 }
88 } 87 }
89 88
90 bool has_A2; 89 bool has_A2;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 138
140 139
141 // Check that snapshot has no unretained entries except root. 140 // Check that snapshot has no unretained entries except root.
142 static bool ValidateSnapshot(const v8::HeapSnapshot* snapshot, int depth = 3) { 141 static bool ValidateSnapshot(const v8::HeapSnapshot* snapshot, int depth = 3) {
143 i::HeapSnapshot* heap_snapshot = const_cast<i::HeapSnapshot*>( 142 i::HeapSnapshot* heap_snapshot = const_cast<i::HeapSnapshot*>(
144 reinterpret_cast<const i::HeapSnapshot*>(snapshot)); 143 reinterpret_cast<const i::HeapSnapshot*>(snapshot));
145 144
146 i::HashMap visited(AddressesMatch); 145 i::HashMap visited(AddressesMatch);
147 i::List<i::HeapGraphEdge>& edges = heap_snapshot->edges(); 146 i::List<i::HeapGraphEdge>& edges = heap_snapshot->edges();
148 for (int i = 0; i < edges.length(); ++i) { 147 for (int i = 0; i < edges.length(); ++i) {
149 i::HashMap::Entry* entry = visited.Lookup( 148 i::HashMap::Entry* entry = visited.LookupOrInsert(
150 reinterpret_cast<void*>(edges[i].to()), 149 reinterpret_cast<void*>(edges[i].to()),
151 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(edges[i].to())), 150 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(edges[i].to())));
152 true);
153 uint32_t ref_count = static_cast<uint32_t>( 151 uint32_t ref_count = static_cast<uint32_t>(
154 reinterpret_cast<uintptr_t>(entry->value)); 152 reinterpret_cast<uintptr_t>(entry->value));
155 entry->value = reinterpret_cast<void*>(ref_count + 1); 153 entry->value = reinterpret_cast<void*>(ref_count + 1);
156 } 154 }
157 uint32_t unretained_entries_count = 0; 155 uint32_t unretained_entries_count = 0;
158 i::List<i::HeapEntry>& entries = heap_snapshot->entries(); 156 i::List<i::HeapEntry>& entries = heap_snapshot->entries();
159 for (int i = 0; i < entries.length(); ++i) { 157 for (int i = 0; i < entries.length(); ++i) {
160 i::HashMap::Entry* entry = visited.Lookup( 158 i::HashMap::Entry* entry = visited.Lookup(
161 reinterpret_cast<void*>(&entries[i]), 159 reinterpret_cast<void*>(&entries[i]),
162 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(&entries[i])), 160 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(&entries[i])));
163 false);
164 if (!entry && entries[i].id() != 1) { 161 if (!entry && entries[i].id() != 1) {
165 entries[i].Print("entry with no retainer", "", depth, 0); 162 entries[i].Print("entry with no retainer", "", depth, 0);
166 ++unretained_entries_count; 163 ++unretained_entries_count;
167 } 164 }
168 } 165 }
169 return unretained_entries_count == 0; 166 return unretained_entries_count == 0;
170 } 167 }
171 168
172 169
173 TEST(HeapSnapshot) { 170 TEST(HeapSnapshot) {
(...skipping 2589 matching lines...) Expand 10 before | Expand all | Expand 10 after
2763 map.AddRange(ToAddress(0x180), 0x80, 6U); 2760 map.AddRange(ToAddress(0x180), 0x80, 6U);
2764 map.AddRange(ToAddress(0x180), 0x80, 7U); 2761 map.AddRange(ToAddress(0x180), 0x80, 7U);
2765 CHECK_EQ(7u, map.GetTraceNodeId(ToAddress(0x180))); 2762 CHECK_EQ(7u, map.GetTraceNodeId(ToAddress(0x180)));
2766 CHECK_EQ(5u, map.GetTraceNodeId(ToAddress(0x200))); 2763 CHECK_EQ(5u, map.GetTraceNodeId(ToAddress(0x200)));
2767 CHECK_EQ(3u, map.size()); 2764 CHECK_EQ(3u, map.size());
2768 2765
2769 map.Clear(); 2766 map.Clear();
2770 CHECK_EQ(0u, map.size()); 2767 CHECK_EQ(0u, map.size());
2771 CHECK_EQ(0u, map.GetTraceNodeId(ToAddress(0x400))); 2768 CHECK_EQ(0u, map.GetTraceNodeId(ToAddress(0x400)));
2772 } 2769 }
OLDNEW
« test/cctest/test-api.cc ('K') | « test/cctest/test-hashmap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698