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

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

Issue 9748007: HeapProfiler doesn't track array movements when it is shifting. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: A test was added Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/builtins.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 // 2 //
3 // Tests for heap profiler 3 // Tests for heap profiler
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "cctest.h" 7 #include "cctest.h"
8 #include "heap-profiler.h" 8 #include "heap-profiler.h"
9 #include "snapshot.h" 9 #include "snapshot.h"
10 #include "utils-inl.h" 10 #include "utils-inl.h"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 345
346 346
347 // Trying to introduce a check helper for uint64_t causes many 347 // Trying to introduce a check helper for uint64_t causes many
348 // overloading ambiguities, so it seems easier just to cast 348 // overloading ambiguities, so it seems easier just to cast
349 // them to a signed type. 349 // them to a signed type.
350 #define CHECK_EQ_UINT64_T(a, b) \ 350 #define CHECK_EQ_UINT64_T(a, b) \
351 CHECK_EQ(static_cast<int64_t>(a), static_cast<int64_t>(b)) 351 CHECK_EQ(static_cast<int64_t>(a), static_cast<int64_t>(b))
352 #define CHECK_NE_UINT64_T(a, b) \ 352 #define CHECK_NE_UINT64_T(a, b) \
353 CHECK((a) != (b)) // NOLINT 353 CHECK((a) != (b)) // NOLINT
354 354
355 TEST(HeapEntryIdsAndArrayShift) {
356 v8::HandleScope scope;
357 LocalContext env;
358
359 CompileRun(
360 "function AnObject() {\n"
361 " this.first = 'first';\n"
362 " this.second = 'second';\n"
363 "}\n"
364 "var a = new Array();\n"
365 "for (var i = 0; i < 10; ++i)\n"
366 " a.push(new AnObject());\n");
367 const v8::HeapSnapshot* snapshot1 =
368 v8::HeapProfiler::TakeSnapshot(v8_str("s1"));
369
370 CompileRun(
371 "for (var i = 0; i < 1; ++i)\n"
372 " a.shift();\n");
373
374 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
375
376 const v8::HeapSnapshot* snapshot2 =
377 v8::HeapProfiler::TakeSnapshot(v8_str("s2"));
378
379 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1);
380 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2);
381 CHECK_NE_UINT64_T(0, global1->GetId());
382 CHECK_EQ_UINT64_T(global1->GetId(), global2->GetId());
383
384 const v8::HeapGraphNode* a1 =
385 GetProperty(global1, v8::HeapGraphEdge::kProperty, "a");
386 CHECK_NE(NULL, a1);
387 const v8::HeapGraphNode* e1 =
388 GetProperty(a1, v8::HeapGraphEdge::kHidden, "1");
389 CHECK_NE(NULL, e1);
390 const v8::HeapGraphNode* k1 =
391 GetProperty(e1, v8::HeapGraphEdge::kInternal, "elements");
392 CHECK_NE(NULL, k1);
393 const v8::HeapGraphNode* a2 =
394 GetProperty(global2, v8::HeapGraphEdge::kProperty, "a");
395 CHECK_NE(NULL, a2);
396 const v8::HeapGraphNode* e2 =
397 GetProperty(a2, v8::HeapGraphEdge::kHidden, "1");
398 CHECK_NE(NULL, e2);
399 const v8::HeapGraphNode* k2 =
400 GetProperty(e2, v8::HeapGraphEdge::kInternal, "elements");
401 CHECK_NE(NULL, k2);
402
403 CHECK_EQ_UINT64_T(a1->GetId(), a2->GetId());
404 CHECK_EQ_UINT64_T(e1->GetId(), e2->GetId());
405 CHECK_EQ_UINT64_T(k1->GetId(), k2->GetId());
406 }
407
355 TEST(HeapEntryIdsAndGC) { 408 TEST(HeapEntryIdsAndGC) {
356 v8::HandleScope scope; 409 v8::HandleScope scope;
357 LocalContext env; 410 LocalContext env;
358 411
359 CompileRun( 412 CompileRun(
360 "function A() {}\n" 413 "function A() {}\n"
361 "function B(x) { this.x = x; }\n" 414 "function B(x) { this.x = x; }\n"
362 "var a = new A();\n" 415 "var a = new A();\n"
363 "var b = new B(a);"); 416 "var b = new B(a);");
364 const v8::HeapSnapshot* snapshot1 = 417 const v8::HeapSnapshot* snapshot1 =
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 // Dipose the persistent handles in a different order. 1359 // Dipose the persistent handles in a different order.
1307 p_AAA.Dispose(); 1360 p_AAA.Dispose();
1308 CHECK_EQ(global_handle_count + 2, 1361 CHECK_EQ(global_handle_count + 2,
1309 v8::HeapProfiler::GetPersistentHandleCount()); 1362 v8::HeapProfiler::GetPersistentHandleCount());
1310 p_CCC.Dispose(); 1363 p_CCC.Dispose();
1311 CHECK_EQ(global_handle_count + 1, 1364 CHECK_EQ(global_handle_count + 1,
1312 v8::HeapProfiler::GetPersistentHandleCount()); 1365 v8::HeapProfiler::GetPersistentHandleCount());
1313 p_BBB.Dispose(); 1366 p_BBB.Dispose();
1314 CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount()); 1367 CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount());
1315 } 1368 }
OLDNEW
« no previous file with comments | « src/builtins.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698