OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // | 2 // |
3 // Tests for heap profiler | 3 // Tests for heap profiler |
4 | 4 |
5 #ifdef ENABLE_LOGGING_AND_PROFILING | 5 #ifdef ENABLE_LOGGING_AND_PROFILING |
6 | 6 |
7 #include "v8.h" | 7 #include "v8.h" |
8 | 8 |
9 #include "cctest.h" | 9 #include "cctest.h" |
10 #include "heap-profiler.h" | 10 #include "heap-profiler.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 expected_source, value_source, | 135 expected_source, value_source, |
136 *stream.ToCString()); | 136 *stream.ToCString()); |
137 } | 137 } |
138 } | 138 } |
139 | 139 |
140 | 140 |
141 TEST(ClustersCoarserSimple) { | 141 TEST(ClustersCoarserSimple) { |
142 v8::HandleScope scope; | 142 v8::HandleScope scope; |
143 LocalContext env; | 143 LocalContext env; |
144 | 144 |
145 i::ZoneScope zn_scope(i::DELETE_ON_EXIT); | 145 i::ZoneScope zn_scope(i::Isolate::Current(), i::DELETE_ON_EXIT); |
146 | 146 |
147 JSObjectsRetainerTree tree; | 147 JSObjectsRetainerTree tree; |
148 JSObjectsCluster function(HEAP->function_class_symbol()); | 148 JSObjectsCluster function(HEAP->function_class_symbol()); |
149 JSObjectsCluster a(*FACTORY->NewStringFromAscii(i::CStrVector("A"))); | 149 JSObjectsCluster a(*FACTORY->NewStringFromAscii(i::CStrVector("A"))); |
150 JSObjectsCluster b(*FACTORY->NewStringFromAscii(i::CStrVector("B"))); | 150 JSObjectsCluster b(*FACTORY->NewStringFromAscii(i::CStrVector("B"))); |
151 | 151 |
152 // o1 <- Function | 152 // o1 <- Function |
153 JSObjectsCluster o1 = | 153 JSObjectsCluster o1 = |
154 AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x100, &function); | 154 AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x100, &function); |
155 // o2 <- Function | 155 // o2 <- Function |
(...skipping 17 matching lines...) Expand all Loading... |
173 CHECK_EQ(coarser.GetCoarseEquivalent(o3), coarser.GetCoarseEquivalent(o4)); | 173 CHECK_EQ(coarser.GetCoarseEquivalent(o3), coarser.GetCoarseEquivalent(o4)); |
174 CHECK_NE(coarser.GetCoarseEquivalent(o1), coarser.GetCoarseEquivalent(o3)); | 174 CHECK_NE(coarser.GetCoarseEquivalent(o1), coarser.GetCoarseEquivalent(o3)); |
175 CHECK_EQ(JSObjectsCluster(), coarser.GetCoarseEquivalent(o5)); | 175 CHECK_EQ(JSObjectsCluster(), coarser.GetCoarseEquivalent(o5)); |
176 } | 176 } |
177 | 177 |
178 | 178 |
179 TEST(ClustersCoarserMultipleConstructors) { | 179 TEST(ClustersCoarserMultipleConstructors) { |
180 v8::HandleScope scope; | 180 v8::HandleScope scope; |
181 LocalContext env; | 181 LocalContext env; |
182 | 182 |
183 i::ZoneScope zn_scope(i::DELETE_ON_EXIT); | 183 i::ZoneScope zn_scope(i::Isolate::Current(), i::DELETE_ON_EXIT); |
184 | 184 |
185 JSObjectsRetainerTree tree; | 185 JSObjectsRetainerTree tree; |
186 JSObjectsCluster function(HEAP->function_class_symbol()); | 186 JSObjectsCluster function(HEAP->function_class_symbol()); |
187 | 187 |
188 // o1 <- Function | 188 // o1 <- Function |
189 JSObjectsCluster o1 = | 189 JSObjectsCluster o1 = |
190 AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x100, &function); | 190 AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x100, &function); |
191 // a1 <- Function | 191 // a1 <- Function |
192 JSObjectsCluster a1 = | 192 JSObjectsCluster a1 = |
193 AddHeapObjectToTree(&tree, HEAP->Array_symbol(), 0x1000, &function); | 193 AddHeapObjectToTree(&tree, HEAP->Array_symbol(), 0x1000, &function); |
194 // o2 <- Function | 194 // o2 <- Function |
195 JSObjectsCluster o2 = | 195 JSObjectsCluster o2 = |
196 AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x200, &function); | 196 AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x200, &function); |
197 // a2 <- Function | 197 // a2 <- Function |
198 JSObjectsCluster a2 = | 198 JSObjectsCluster a2 = |
199 AddHeapObjectToTree(&tree, HEAP->Array_symbol(), 0x2000, &function); | 199 AddHeapObjectToTree(&tree, HEAP->Array_symbol(), 0x2000, &function); |
200 | 200 |
201 ClustersCoarser coarser; | 201 ClustersCoarser coarser; |
202 coarser.Process(&tree); | 202 coarser.Process(&tree); |
203 | 203 |
204 CHECK_EQ(coarser.GetCoarseEquivalent(o1), coarser.GetCoarseEquivalent(o2)); | 204 CHECK_EQ(coarser.GetCoarseEquivalent(o1), coarser.GetCoarseEquivalent(o2)); |
205 CHECK_EQ(coarser.GetCoarseEquivalent(a1), coarser.GetCoarseEquivalent(a2)); | 205 CHECK_EQ(coarser.GetCoarseEquivalent(a1), coarser.GetCoarseEquivalent(a2)); |
206 } | 206 } |
207 | 207 |
208 | 208 |
209 TEST(ClustersCoarserPathsTraversal) { | 209 TEST(ClustersCoarserPathsTraversal) { |
210 v8::HandleScope scope; | 210 v8::HandleScope scope; |
211 LocalContext env; | 211 LocalContext env; |
212 | 212 |
213 i::ZoneScope zn_scope(i::DELETE_ON_EXIT); | 213 i::ZoneScope zn_scope(i::Isolate::Current(), i::DELETE_ON_EXIT); |
214 | 214 |
215 JSObjectsRetainerTree tree; | 215 JSObjectsRetainerTree tree; |
216 | 216 |
217 // On the following graph: | 217 // On the following graph: |
218 // | 218 // |
219 // p | 219 // p |
220 // <- o21 <- o11 <- | 220 // <- o21 <- o11 <- |
221 // q o | 221 // q o |
222 // <- o22 <- o12 <- | 222 // <- o22 <- o12 <- |
223 // r | 223 // r |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 CHECK_EQ(coarser.GetCoarseEquivalent(q), coarser.GetCoarseEquivalent(r)); | 255 CHECK_EQ(coarser.GetCoarseEquivalent(q), coarser.GetCoarseEquivalent(r)); |
256 CHECK_NE(coarser.GetCoarseEquivalent(o11), coarser.GetCoarseEquivalent(p)); | 256 CHECK_NE(coarser.GetCoarseEquivalent(o11), coarser.GetCoarseEquivalent(p)); |
257 CHECK_NE(coarser.GetCoarseEquivalent(o21), coarser.GetCoarseEquivalent(p)); | 257 CHECK_NE(coarser.GetCoarseEquivalent(o21), coarser.GetCoarseEquivalent(p)); |
258 } | 258 } |
259 | 259 |
260 | 260 |
261 TEST(ClustersCoarserSelf) { | 261 TEST(ClustersCoarserSelf) { |
262 v8::HandleScope scope; | 262 v8::HandleScope scope; |
263 LocalContext env; | 263 LocalContext env; |
264 | 264 |
265 i::ZoneScope zn_scope(i::DELETE_ON_EXIT); | 265 i::ZoneScope zn_scope(i::Isolate::Current(), i::DELETE_ON_EXIT); |
266 | 266 |
267 JSObjectsRetainerTree tree; | 267 JSObjectsRetainerTree tree; |
268 | 268 |
269 // On the following graph: | 269 // On the following graph: |
270 // | 270 // |
271 // p (self-referencing) | 271 // p (self-referencing) |
272 // <- o1 <- | 272 // <- o1 <- |
273 // q (self-referencing) o | 273 // q (self-referencing) o |
274 // <- o2 <- | 274 // <- o2 <- |
275 // r (self-referencing) | 275 // r (self-referencing) |
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 const_cast<v8::HeapSnapshot*>(s2)->Delete(); | 1316 const_cast<v8::HeapSnapshot*>(s2)->Delete(); |
1317 CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount()); | 1317 CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount()); |
1318 CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid2)); | 1318 CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid2)); |
1319 CHECK_EQ(s3, v8::HeapProfiler::FindSnapshot(uid3)); | 1319 CHECK_EQ(s3, v8::HeapProfiler::FindSnapshot(uid3)); |
1320 const_cast<v8::HeapSnapshot*>(s3)->Delete(); | 1320 const_cast<v8::HeapSnapshot*>(s3)->Delete(); |
1321 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); | 1321 CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); |
1322 CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid3)); | 1322 CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid3)); |
1323 } | 1323 } |
1324 | 1324 |
1325 #endif // ENABLE_LOGGING_AND_PROFILING | 1325 #endif // ENABLE_LOGGING_AND_PROFILING |
OLD | NEW |