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

Side by Side Diff: test/cctest/heap/test-incremental-marking.cc

Issue 1999753002: [heap] Harden heap-related cctests (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix for win Created 4 years, 7 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/heap/test-heap.cc ('k') | test/cctest/heap/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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 6
7 #ifdef __linux__ 7 #ifdef __linux__
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
11 #include <sys/types.h> 11 #include <sys/types.h>
12 #include <unistd.h> 12 #include <unistd.h>
13 #endif 13 #endif
14 14
15 #include <utility> 15 #include <utility>
16 16
17 #include "src/v8.h" 17 #include "src/v8.h"
18 18
19 #include "src/full-codegen/full-codegen.h" 19 #include "src/full-codegen/full-codegen.h"
20 #include "src/global-handles.h" 20 #include "src/global-handles.h"
21 #include "test/cctest/cctest.h" 21 #include "test/cctest/cctest.h"
22 #include "test/cctest/heap/utils-inl.h" 22 #include "test/cctest/heap/heap-utils.h"
23
24 23
25 using v8::IdleTask; 24 using v8::IdleTask;
26 using v8::Task; 25 using v8::Task;
27 using v8::Isolate; 26 using v8::Isolate;
28 27
29 namespace v8 { 28 namespace v8 {
30 namespace internal { 29 namespace internal {
31 30
32 class MockPlatform : public v8::Platform { 31 class MockPlatform : public v8::Platform {
33 public: 32 public:
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 Task* delayed_task_; 112 Task* delayed_task_;
114 }; 113 };
115 114
116 115
117 TEST(IncrementalMarkingUsingIdleTasks) { 116 TEST(IncrementalMarkingUsingIdleTasks) {
118 if (!i::FLAG_incremental_marking) return; 117 if (!i::FLAG_incremental_marking) return;
119 CcTest::InitializeVM(); 118 CcTest::InitializeVM();
120 v8::Platform* old_platform = i::V8::GetCurrentPlatform(); 119 v8::Platform* old_platform = i::V8::GetCurrentPlatform();
121 MockPlatform platform(old_platform); 120 MockPlatform platform(old_platform);
122 i::V8::SetPlatformForTesting(&platform); 121 i::V8::SetPlatformForTesting(&platform);
123 SimulateFullSpace(CcTest::heap()->old_space()); 122 i::heap::SimulateFullSpace(CcTest::heap()->old_space());
124 i::IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 123 i::IncrementalMarking* marking = CcTest::heap()->incremental_marking();
125 marking->Stop(); 124 marking->Stop();
126 marking->Start(); 125 marking->Start();
127 CHECK(platform.PendingIdleTask()); 126 CHECK(platform.PendingIdleTask());
128 const double kLongIdleTimeInSeconds = 1; 127 const double kLongIdleTimeInSeconds = 1;
129 const double kShortIdleTimeInSeconds = 0.010; 128 const double kShortIdleTimeInSeconds = 0.010;
130 const int kShortStepCount = 10; 129 const int kShortStepCount = 10;
131 for (int i = 0; i < kShortStepCount && platform.PendingIdleTask(); i++) { 130 for (int i = 0; i < kShortStepCount && platform.PendingIdleTask(); i++) {
132 platform.PerformIdleTask(kShortIdleTimeInSeconds); 131 platform.PerformIdleTask(kShortIdleTimeInSeconds);
133 } 132 }
134 while (platform.PendingIdleTask()) { 133 while (platform.PendingIdleTask()) {
135 platform.PerformIdleTask(kLongIdleTimeInSeconds); 134 platform.PerformIdleTask(kLongIdleTimeInSeconds);
136 } 135 }
137 CHECK(marking->IsStopped()); 136 CHECK(marking->IsStopped());
138 i::V8::SetPlatformForTesting(old_platform); 137 i::V8::SetPlatformForTesting(old_platform);
139 } 138 }
140 139
141 140
142 TEST(IncrementalMarkingUsingIdleTasksAfterGC) { 141 TEST(IncrementalMarkingUsingIdleTasksAfterGC) {
143 if (!i::FLAG_incremental_marking) return; 142 if (!i::FLAG_incremental_marking) return;
144 CcTest::InitializeVM(); 143 CcTest::InitializeVM();
145 v8::Platform* old_platform = i::V8::GetCurrentPlatform(); 144 v8::Platform* old_platform = i::V8::GetCurrentPlatform();
146 MockPlatform platform(old_platform); 145 MockPlatform platform(old_platform);
147 i::V8::SetPlatformForTesting(&platform); 146 i::V8::SetPlatformForTesting(&platform);
148 SimulateFullSpace(CcTest::heap()->old_space()); 147 i::heap::SimulateFullSpace(CcTest::heap()->old_space());
149 CcTest::heap()->CollectAllGarbage(); 148 CcTest::heap()->CollectAllGarbage();
150 i::IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 149 i::IncrementalMarking* marking = CcTest::heap()->incremental_marking();
151 marking->Stop(); 150 marking->Stop();
152 marking->Start(); 151 marking->Start();
153 CHECK(platform.PendingIdleTask()); 152 CHECK(platform.PendingIdleTask());
154 const double kLongIdleTimeInSeconds = 1; 153 const double kLongIdleTimeInSeconds = 1;
155 const double kShortIdleTimeInSeconds = 0.010; 154 const double kShortIdleTimeInSeconds = 0.010;
156 const int kShortStepCount = 10; 155 const int kShortStepCount = 10;
157 for (int i = 0; i < kShortStepCount && platform.PendingIdleTask(); i++) { 156 for (int i = 0; i < kShortStepCount && platform.PendingIdleTask(); i++) {
158 platform.PerformIdleTask(kShortIdleTimeInSeconds); 157 platform.PerformIdleTask(kShortIdleTimeInSeconds);
159 } 158 }
160 while (platform.PendingIdleTask()) { 159 while (platform.PendingIdleTask()) {
161 platform.PerformIdleTask(kLongIdleTimeInSeconds); 160 platform.PerformIdleTask(kLongIdleTimeInSeconds);
162 } 161 }
163 CHECK(marking->IsStopped()); 162 CHECK(marking->IsStopped());
164 i::V8::SetPlatformForTesting(old_platform); 163 i::V8::SetPlatformForTesting(old_platform);
165 } 164 }
166 165
167 166
168 TEST(IncrementalMarkingUsingDelayedTasks) { 167 TEST(IncrementalMarkingUsingDelayedTasks) {
169 if (!i::FLAG_incremental_marking) return; 168 if (!i::FLAG_incremental_marking) return;
170 CcTest::InitializeVM(); 169 CcTest::InitializeVM();
171 v8::Platform* old_platform = i::V8::GetCurrentPlatform(); 170 v8::Platform* old_platform = i::V8::GetCurrentPlatform();
172 MockPlatform platform(old_platform); 171 MockPlatform platform(old_platform);
173 i::V8::SetPlatformForTesting(&platform); 172 i::V8::SetPlatformForTesting(&platform);
174 SimulateFullSpace(CcTest::heap()->old_space()); 173 i::heap::SimulateFullSpace(CcTest::heap()->old_space());
175 i::IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 174 i::IncrementalMarking* marking = CcTest::heap()->incremental_marking();
176 marking->Stop(); 175 marking->Stop();
177 marking->Start(); 176 marking->Start();
178 CHECK(platform.PendingIdleTask()); 177 CHECK(platform.PendingIdleTask());
179 // The delayed task should be a no-op if the idle task makes progress. 178 // The delayed task should be a no-op if the idle task makes progress.
180 const int kIgnoredDelayedTaskStepCount = 1000; 179 const int kIgnoredDelayedTaskStepCount = 1000;
181 for (int i = 0; i < kIgnoredDelayedTaskStepCount; i++) { 180 for (int i = 0; i < kIgnoredDelayedTaskStepCount; i++) {
182 // Dummy idle task progress. 181 // Dummy idle task progress.
183 marking->incremental_marking_job()->NotifyIdleTaskProgress(); 182 marking->incremental_marking_job()->NotifyIdleTaskProgress();
184 CHECK(platform.PendingDelayedTask()); 183 CHECK(platform.PendingDelayedTask());
185 platform.PerformDelayedTask(); 184 platform.PerformDelayedTask();
186 } 185 }
187 // Once we stop notifying idle task progress, the delayed tasks 186 // Once we stop notifying idle task progress, the delayed tasks
188 // should finish marking. 187 // should finish marking.
189 while (!marking->IsStopped() && platform.PendingDelayedTask()) { 188 while (!marking->IsStopped() && platform.PendingDelayedTask()) {
190 platform.PerformDelayedTask(); 189 platform.PerformDelayedTask();
191 } 190 }
192 // There could be pending delayed task from memory reducer after GC finishes. 191 // There could be pending delayed task from memory reducer after GC finishes.
193 CHECK(marking->IsStopped()); 192 CHECK(marking->IsStopped());
194 i::V8::SetPlatformForTesting(old_platform); 193 i::V8::SetPlatformForTesting(old_platform);
195 } 194 }
196 195
197 } // namespace internal 196 } // namespace internal
198 } // namespace v8 197 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/heap/test-heap.cc ('k') | test/cctest/heap/test-mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698