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

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

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