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

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

Issue 24169005: remove HEAP from tests (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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 | « test/cctest/test-heap.cc ('k') | test/cctest/test-log.cc » ('j') | 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 "for (var i = 0; i < 10000; ++i)\n" 498 "for (var i = 0; i < 10000; ++i)\n"
499 " a[i] = new A();\n"); 499 " a[i] = new A();\n");
500 const v8::HeapSnapshot* snapshot1 = 500 const v8::HeapSnapshot* snapshot1 =
501 heap_profiler->TakeHeapSnapshot(v8_str("snapshot1")); 501 heap_profiler->TakeHeapSnapshot(v8_str("snapshot1"));
502 CHECK(ValidateSnapshot(snapshot1)); 502 CHECK(ValidateSnapshot(snapshot1));
503 v8::SnapshotObjectId maxId1 = snapshot1->GetMaxSnapshotJSObjectId(); 503 v8::SnapshotObjectId maxId1 = snapshot1->GetMaxSnapshotJSObjectId();
504 504
505 CompileRun( 505 CompileRun(
506 "for (var i = 0; i < 10000; ++i)\n" 506 "for (var i = 0; i < 10000; ++i)\n"
507 " a[i] = new A();\n"); 507 " a[i] = new A();\n");
508 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); 508 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
509 509
510 const v8::HeapSnapshot* snapshot2 = 510 const v8::HeapSnapshot* snapshot2 =
511 heap_profiler->TakeHeapSnapshot(v8_str("snapshot2")); 511 heap_profiler->TakeHeapSnapshot(v8_str("snapshot2"));
512 CHECK(ValidateSnapshot(snapshot2)); 512 CHECK(ValidateSnapshot(snapshot2));
513 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); 513 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2);
514 514
515 const v8::HeapGraphNode* array_node = 515 const v8::HeapGraphNode* array_node =
516 GetProperty(global2, v8::HeapGraphEdge::kProperty, "a"); 516 GetProperty(global2, v8::HeapGraphEdge::kProperty, "a");
517 CHECK_NE(NULL, array_node); 517 CHECK_NE(NULL, array_node);
518 int wrong_count = 0; 518 int wrong_count = 0;
(...skipping 23 matching lines...) Expand all
542 "for (var i = 0; i < 10; ++i)\n" 542 "for (var i = 0; i < 10; ++i)\n"
543 " a.push(new AnObject());\n"); 543 " a.push(new AnObject());\n");
544 const v8::HeapSnapshot* snapshot1 = 544 const v8::HeapSnapshot* snapshot1 =
545 heap_profiler->TakeHeapSnapshot(v8_str("s1")); 545 heap_profiler->TakeHeapSnapshot(v8_str("s1"));
546 CHECK(ValidateSnapshot(snapshot1)); 546 CHECK(ValidateSnapshot(snapshot1));
547 547
548 CompileRun( 548 CompileRun(
549 "for (var i = 0; i < 1; ++i)\n" 549 "for (var i = 0; i < 1; ++i)\n"
550 " a.shift();\n"); 550 " a.shift();\n");
551 551
552 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); 552 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
553 553
554 const v8::HeapSnapshot* snapshot2 = 554 const v8::HeapSnapshot* snapshot2 =
555 heap_profiler->TakeHeapSnapshot(v8_str("s2")); 555 heap_profiler->TakeHeapSnapshot(v8_str("s2"));
556 CHECK(ValidateSnapshot(snapshot2)); 556 CHECK(ValidateSnapshot(snapshot2));
557 557
558 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1); 558 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1);
559 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); 559 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2);
560 CHECK_NE_SNAPSHOT_OBJECT_ID(0, global1->GetId()); 560 CHECK_NE_SNAPSHOT_OBJECT_ID(0, global1->GetId());
561 CHECK_EQ_SNAPSHOT_OBJECT_ID(global1->GetId(), global2->GetId()); 561 CHECK_EQ_SNAPSHOT_OBJECT_ID(global1->GetId(), global2->GetId());
562 562
(...skipping 24 matching lines...) Expand all
587 "function A() {}\n" 587 "function A() {}\n"
588 "function B(x) { this.x = x; }\n" 588 "function B(x) { this.x = x; }\n"
589 "var a = new A();\n" 589 "var a = new A();\n"
590 "var b = new B(a);"); 590 "var b = new B(a);");
591 v8::Local<v8::String> s1_str = v8_str("s1"); 591 v8::Local<v8::String> s1_str = v8_str("s1");
592 v8::Local<v8::String> s2_str = v8_str("s2"); 592 v8::Local<v8::String> s2_str = v8_str("s2");
593 const v8::HeapSnapshot* snapshot1 = 593 const v8::HeapSnapshot* snapshot1 =
594 heap_profiler->TakeHeapSnapshot(s1_str); 594 heap_profiler->TakeHeapSnapshot(s1_str);
595 CHECK(ValidateSnapshot(snapshot1)); 595 CHECK(ValidateSnapshot(snapshot1));
596 596
597 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); 597 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
598 598
599 const v8::HeapSnapshot* snapshot2 = 599 const v8::HeapSnapshot* snapshot2 =
600 heap_profiler->TakeHeapSnapshot(s2_str); 600 heap_profiler->TakeHeapSnapshot(s2_str);
601 CHECK(ValidateSnapshot(snapshot2)); 601 CHECK(ValidateSnapshot(snapshot2));
602 602
603 CHECK_GT(snapshot1->GetMaxSnapshotJSObjectId(), 7000); 603 CHECK_GT(snapshot1->GetMaxSnapshotJSObjectId(), 7000);
604 CHECK(snapshot1->GetMaxSnapshotJSObjectId() <= 604 CHECK(snapshot1->GetMaxSnapshotJSObjectId() <=
605 snapshot2->GetMaxSnapshotJSObjectId()); 605 snapshot2->GetMaxSnapshotJSObjectId());
606 606
607 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1); 607 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1);
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 894
895 TEST(HeapSnapshotObjectsStats) { 895 TEST(HeapSnapshotObjectsStats) {
896 LocalContext env; 896 LocalContext env;
897 v8::HandleScope scope(env->GetIsolate()); 897 v8::HandleScope scope(env->GetIsolate());
898 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 898 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
899 899
900 heap_profiler->StartTrackingHeapObjects(); 900 heap_profiler->StartTrackingHeapObjects();
901 // We have to call GC 6 times. In other case the garbage will be 901 // We have to call GC 6 times. In other case the garbage will be
902 // the reason of flakiness. 902 // the reason of flakiness.
903 for (int i = 0; i < 6; ++i) { 903 for (int i = 0; i < 6; ++i) {
904 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); 904 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
905 } 905 }
906 906
907 v8::SnapshotObjectId initial_id; 907 v8::SnapshotObjectId initial_id;
908 { 908 {
909 // Single chunk of data expected in update. Initial data. 909 // Single chunk of data expected in update. Initial data.
910 TestStatsStream stats_update = GetHeapStatsUpdate(heap_profiler, 910 TestStatsStream stats_update = GetHeapStatsUpdate(heap_profiler,
911 &initial_id); 911 &initial_id);
912 CHECK_EQ(1, stats_update.intervals_count()); 912 CHECK_EQ(1, stats_update.intervals_count());
913 CHECK_EQ(1, stats_update.updates_written()); 913 CHECK_EQ(1, stats_update.updates_written());
914 CHECK_LT(0, stats_update.entries_size()); 914 CHECK_LT(0, stats_update.entries_size());
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
1998 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); 1998 heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
1999 CHECK(ValidateSnapshot(snapshot)); 1999 CHECK(ValidateSnapshot(snapshot));
2000 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 2000 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
2001 const v8::HeapGraphNode* foo_func = 2001 const v8::HeapGraphNode* foo_func =
2002 GetProperty(global, v8::HeapGraphEdge::kProperty, "foo"); 2002 GetProperty(global, v8::HeapGraphEdge::kProperty, "foo");
2003 CHECK_NE(NULL, foo_func); 2003 CHECK_NE(NULL, foo_func);
2004 const v8::HeapGraphNode* code = 2004 const v8::HeapGraphNode* code =
2005 GetProperty(foo_func, v8::HeapGraphEdge::kInternal, "code"); 2005 GetProperty(foo_func, v8::HeapGraphEdge::kInternal, "code");
2006 CHECK_NE(NULL, code); 2006 CHECK_NE(NULL, code);
2007 } 2007 }
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698