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

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

Issue 1082973003: Force full GC whenever CollectAllGarbage is meant to trigger a full GC. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-mark-compact.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 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 "var a = [];\n" 661 "var a = [];\n"
662 "for (var i = 0; i < 10000; ++i)\n" 662 "for (var i = 0; i < 10000; ++i)\n"
663 " a[i] = new A();\n"); 663 " a[i] = new A();\n");
664 const v8::HeapSnapshot* snapshot1 = heap_profiler->TakeHeapSnapshot(); 664 const v8::HeapSnapshot* snapshot1 = heap_profiler->TakeHeapSnapshot();
665 CHECK(ValidateSnapshot(snapshot1)); 665 CHECK(ValidateSnapshot(snapshot1));
666 v8::SnapshotObjectId maxId1 = snapshot1->GetMaxSnapshotJSObjectId(); 666 v8::SnapshotObjectId maxId1 = snapshot1->GetMaxSnapshotJSObjectId();
667 667
668 CompileRun( 668 CompileRun(
669 "for (var i = 0; i < 10000; ++i)\n" 669 "for (var i = 0; i < 10000; ++i)\n"
670 " a[i] = new A();\n"); 670 " a[i] = new A();\n");
671 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); 671 CcTest::heap()->CollectAllGarbage();
672 672
673 const v8::HeapSnapshot* snapshot2 = heap_profiler->TakeHeapSnapshot(); 673 const v8::HeapSnapshot* snapshot2 = heap_profiler->TakeHeapSnapshot();
674 CHECK(ValidateSnapshot(snapshot2)); 674 CHECK(ValidateSnapshot(snapshot2));
675 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); 675 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2);
676 676
677 const v8::HeapGraphNode* array_node = 677 const v8::HeapGraphNode* array_node =
678 GetProperty(global2, v8::HeapGraphEdge::kProperty, "a"); 678 GetProperty(global2, v8::HeapGraphEdge::kProperty, "a");
679 CHECK(array_node); 679 CHECK(array_node);
680 int wrong_count = 0; 680 int wrong_count = 0;
681 for (int i = 0, count = array_node->GetChildrenCount(); i < count; ++i) { 681 for (int i = 0, count = array_node->GetChildrenCount(); i < count; ++i) {
(...skipping 21 matching lines...) Expand all
703 "var a = new Array();\n" 703 "var a = new Array();\n"
704 "for (var i = 0; i < 10; ++i)\n" 704 "for (var i = 0; i < 10; ++i)\n"
705 " a.push(new AnObject());\n"); 705 " a.push(new AnObject());\n");
706 const v8::HeapSnapshot* snapshot1 = heap_profiler->TakeHeapSnapshot(); 706 const v8::HeapSnapshot* snapshot1 = heap_profiler->TakeHeapSnapshot();
707 CHECK(ValidateSnapshot(snapshot1)); 707 CHECK(ValidateSnapshot(snapshot1));
708 708
709 CompileRun( 709 CompileRun(
710 "for (var i = 0; i < 1; ++i)\n" 710 "for (var i = 0; i < 1; ++i)\n"
711 " a.shift();\n"); 711 " a.shift();\n");
712 712
713 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); 713 CcTest::heap()->CollectAllGarbage();
714 714
715 const v8::HeapSnapshot* snapshot2 = heap_profiler->TakeHeapSnapshot(); 715 const v8::HeapSnapshot* snapshot2 = heap_profiler->TakeHeapSnapshot();
716 CHECK(ValidateSnapshot(snapshot2)); 716 CHECK(ValidateSnapshot(snapshot2));
717 717
718 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1); 718 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1);
719 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); 719 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2);
720 CHECK_NE(0u, global1->GetId()); 720 CHECK_NE(0u, global1->GetId());
721 CHECK_EQ(global1->GetId(), global2->GetId()); 721 CHECK_EQ(global1->GetId(), global2->GetId());
722 722
723 const v8::HeapGraphNode* a1 = 723 const v8::HeapGraphNode* a1 =
(...skipping 20 matching lines...) Expand all
744 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 744 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
745 745
746 CompileRun( 746 CompileRun(
747 "function A() {}\n" 747 "function A() {}\n"
748 "function B(x) { this.x = x; }\n" 748 "function B(x) { this.x = x; }\n"
749 "var a = new A();\n" 749 "var a = new A();\n"
750 "var b = new B(a);"); 750 "var b = new B(a);");
751 const v8::HeapSnapshot* snapshot1 = heap_profiler->TakeHeapSnapshot(); 751 const v8::HeapSnapshot* snapshot1 = heap_profiler->TakeHeapSnapshot();
752 CHECK(ValidateSnapshot(snapshot1)); 752 CHECK(ValidateSnapshot(snapshot1));
753 753
754 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); 754 CcTest::heap()->CollectAllGarbage();
755 755
756 const v8::HeapSnapshot* snapshot2 = heap_profiler->TakeHeapSnapshot(); 756 const v8::HeapSnapshot* snapshot2 = heap_profiler->TakeHeapSnapshot();
757 CHECK(ValidateSnapshot(snapshot2)); 757 CHECK(ValidateSnapshot(snapshot2));
758 758
759 CHECK_GT(snapshot1->GetMaxSnapshotJSObjectId(), 7000u); 759 CHECK_GT(snapshot1->GetMaxSnapshotJSObjectId(), 7000u);
760 CHECK(snapshot1->GetMaxSnapshotJSObjectId() <= 760 CHECK(snapshot1->GetMaxSnapshotJSObjectId() <=
761 snapshot2->GetMaxSnapshotJSObjectId()); 761 snapshot2->GetMaxSnapshotJSObjectId());
762 762
763 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1); 763 const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1);
764 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); 764 const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2);
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 1053
1054 TEST(HeapSnapshotObjectsStats) { 1054 TEST(HeapSnapshotObjectsStats) {
1055 LocalContext env; 1055 LocalContext env;
1056 v8::HandleScope scope(env->GetIsolate()); 1056 v8::HandleScope scope(env->GetIsolate());
1057 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1057 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1058 1058
1059 heap_profiler->StartTrackingHeapObjects(); 1059 heap_profiler->StartTrackingHeapObjects();
1060 // We have to call GC 6 times. In other case the garbage will be 1060 // We have to call GC 6 times. In other case the garbage will be
1061 // the reason of flakiness. 1061 // the reason of flakiness.
1062 for (int i = 0; i < 6; ++i) { 1062 for (int i = 0; i < 6; ++i) {
1063 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); 1063 CcTest::heap()->CollectAllGarbage();
1064 } 1064 }
1065 1065
1066 v8::SnapshotObjectId initial_id; 1066 v8::SnapshotObjectId initial_id;
1067 { 1067 {
1068 // Single chunk of data expected in update. Initial data. 1068 // Single chunk of data expected in update. Initial data.
1069 TestStatsStream stats_update = GetHeapStatsUpdate(heap_profiler, 1069 TestStatsStream stats_update = GetHeapStatsUpdate(heap_profiler,
1070 &initial_id); 1070 &initial_id);
1071 CHECK_EQ(1, stats_update.intervals_count()); 1071 CHECK_EQ(1, stats_update.intervals_count());
1072 CHECK_EQ(1, stats_update.updates_written()); 1072 CHECK_EQ(1, stats_update.updates_written());
1073 CHECK_LT(0u, stats_update.entries_size()); 1073 CHECK_LT(0u, stats_update.entries_size());
(...skipping 1686 matching lines...) Expand 10 before | Expand all | Expand 10 after
2760 map.AddRange(ToAddress(0x180), 0x80, 6U); 2760 map.AddRange(ToAddress(0x180), 0x80, 6U);
2761 map.AddRange(ToAddress(0x180), 0x80, 7U); 2761 map.AddRange(ToAddress(0x180), 0x80, 7U);
2762 CHECK_EQ(7u, map.GetTraceNodeId(ToAddress(0x180))); 2762 CHECK_EQ(7u, map.GetTraceNodeId(ToAddress(0x180)));
2763 CHECK_EQ(5u, map.GetTraceNodeId(ToAddress(0x200))); 2763 CHECK_EQ(5u, map.GetTraceNodeId(ToAddress(0x200)));
2764 CHECK_EQ(3u, map.size()); 2764 CHECK_EQ(3u, map.size());
2765 2765
2766 map.Clear(); 2766 map.Clear();
2767 CHECK_EQ(0u, map.size()); 2767 CHECK_EQ(0u, map.size());
2768 CHECK_EQ(0u, map.GetTraceNodeId(ToAddress(0x400))); 2768 CHECK_EQ(0u, map.GetTraceNodeId(ToAddress(0x400)));
2769 } 2769 }
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698