OLD | NEW |
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> |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 115 |
116 TEST(IncrementalMarkingUsingIdleTasks) { | 116 TEST(IncrementalMarkingUsingIdleTasks) { |
117 if (!i::FLAG_incremental_marking) return; | 117 if (!i::FLAG_incremental_marking) return; |
118 CcTest::InitializeVM(); | 118 CcTest::InitializeVM(); |
119 v8::Platform* old_platform = i::V8::GetCurrentPlatform(); | 119 v8::Platform* old_platform = i::V8::GetCurrentPlatform(); |
120 MockPlatform platform(old_platform); | 120 MockPlatform platform(old_platform); |
121 i::V8::SetPlatformForTesting(&platform); | 121 i::V8::SetPlatformForTesting(&platform); |
122 i::heap::SimulateFullSpace(CcTest::heap()->old_space()); | 122 i::heap::SimulateFullSpace(CcTest::heap()->old_space()); |
123 i::IncrementalMarking* marking = CcTest::heap()->incremental_marking(); | 123 i::IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
124 marking->Stop(); | 124 marking->Stop(); |
125 marking->Start(); | 125 marking->Start(i::GarbageCollectionReason::kTesting); |
126 CHECK(platform.PendingIdleTask()); | 126 CHECK(platform.PendingIdleTask()); |
127 const double kLongIdleTimeInSeconds = 1; | 127 const double kLongIdleTimeInSeconds = 1; |
128 const double kShortIdleTimeInSeconds = 0.010; | 128 const double kShortIdleTimeInSeconds = 0.010; |
129 const int kShortStepCount = 10; | 129 const int kShortStepCount = 10; |
130 for (int i = 0; i < kShortStepCount && platform.PendingIdleTask(); i++) { | 130 for (int i = 0; i < kShortStepCount && platform.PendingIdleTask(); i++) { |
131 platform.PerformIdleTask(kShortIdleTimeInSeconds); | 131 platform.PerformIdleTask(kShortIdleTimeInSeconds); |
132 } | 132 } |
133 while (platform.PendingIdleTask()) { | 133 while (platform.PendingIdleTask()) { |
134 platform.PerformIdleTask(kLongIdleTimeInSeconds); | 134 platform.PerformIdleTask(kLongIdleTimeInSeconds); |
135 } | 135 } |
136 CHECK(marking->IsStopped()); | 136 CHECK(marking->IsStopped()); |
137 i::V8::SetPlatformForTesting(old_platform); | 137 i::V8::SetPlatformForTesting(old_platform); |
138 } | 138 } |
139 | 139 |
140 | 140 |
141 TEST(IncrementalMarkingUsingIdleTasksAfterGC) { | 141 TEST(IncrementalMarkingUsingIdleTasksAfterGC) { |
142 if (!i::FLAG_incremental_marking) return; | 142 if (!i::FLAG_incremental_marking) return; |
143 | 143 |
144 const double kLongIdleTimeInSeconds = 1; | 144 const double kLongIdleTimeInSeconds = 1; |
145 const double kShortIdleTimeInSeconds = 0.010; | 145 const double kShortIdleTimeInSeconds = 0.010; |
146 | 146 |
147 CcTest::InitializeVM(); | 147 CcTest::InitializeVM(); |
148 v8::Platform* old_platform = i::V8::GetCurrentPlatform(); | 148 v8::Platform* old_platform = i::V8::GetCurrentPlatform(); |
149 MockPlatform platform(old_platform); | 149 MockPlatform platform(old_platform); |
150 i::V8::SetPlatformForTesting(&platform); | 150 i::V8::SetPlatformForTesting(&platform); |
151 i::heap::SimulateFullSpace(CcTest::heap()->old_space()); | 151 i::heap::SimulateFullSpace(CcTest::heap()->old_space()); |
152 CcTest::heap()->CollectAllGarbage(); | 152 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); |
153 // Perform any pending idle tasks. | 153 // Perform any pending idle tasks. |
154 while (platform.PendingIdleTask()) { | 154 while (platform.PendingIdleTask()) { |
155 platform.PerformIdleTask(kLongIdleTimeInSeconds); | 155 platform.PerformIdleTask(kLongIdleTimeInSeconds); |
156 } | 156 } |
157 CHECK(!platform.PendingIdleTask()); | 157 CHECK(!platform.PendingIdleTask()); |
158 i::IncrementalMarking* marking = CcTest::heap()->incremental_marking(); | 158 i::IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
159 marking->Stop(); | 159 marking->Stop(); |
160 marking->Start(); | 160 marking->Start(i::GarbageCollectionReason::kTesting); |
161 CHECK(platform.PendingIdleTask()); | 161 CHECK(platform.PendingIdleTask()); |
162 const int kShortStepCount = 10; | 162 const int kShortStepCount = 10; |
163 for (int i = 0; i < kShortStepCount && platform.PendingIdleTask(); i++) { | 163 for (int i = 0; i < kShortStepCount && platform.PendingIdleTask(); i++) { |
164 platform.PerformIdleTask(kShortIdleTimeInSeconds); | 164 platform.PerformIdleTask(kShortIdleTimeInSeconds); |
165 } | 165 } |
166 while (platform.PendingIdleTask()) { | 166 while (platform.PendingIdleTask()) { |
167 platform.PerformIdleTask(kLongIdleTimeInSeconds); | 167 platform.PerformIdleTask(kLongIdleTimeInSeconds); |
168 } | 168 } |
169 CHECK(marking->IsStopped()); | 169 CHECK(marking->IsStopped()); |
170 i::V8::SetPlatformForTesting(old_platform); | 170 i::V8::SetPlatformForTesting(old_platform); |
171 } | 171 } |
172 | 172 |
173 | 173 |
174 TEST(IncrementalMarkingUsingDelayedTasks) { | 174 TEST(IncrementalMarkingUsingDelayedTasks) { |
175 if (!i::FLAG_incremental_marking) return; | 175 if (!i::FLAG_incremental_marking) return; |
176 CcTest::InitializeVM(); | 176 CcTest::InitializeVM(); |
177 v8::Platform* old_platform = i::V8::GetCurrentPlatform(); | 177 v8::Platform* old_platform = i::V8::GetCurrentPlatform(); |
178 MockPlatform platform(old_platform); | 178 MockPlatform platform(old_platform); |
179 i::V8::SetPlatformForTesting(&platform); | 179 i::V8::SetPlatformForTesting(&platform); |
180 i::heap::SimulateFullSpace(CcTest::heap()->old_space()); | 180 i::heap::SimulateFullSpace(CcTest::heap()->old_space()); |
181 i::IncrementalMarking* marking = CcTest::heap()->incremental_marking(); | 181 i::IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
182 marking->Stop(); | 182 marking->Stop(); |
183 marking->Start(); | 183 marking->Start(i::GarbageCollectionReason::kTesting); |
184 CHECK(platform.PendingIdleTask()); | 184 CHECK(platform.PendingIdleTask()); |
185 // The delayed task should be a no-op if the idle task makes progress. | 185 // The delayed task should be a no-op if the idle task makes progress. |
186 const int kIgnoredDelayedTaskStepCount = 1000; | 186 const int kIgnoredDelayedTaskStepCount = 1000; |
187 for (int i = 0; i < kIgnoredDelayedTaskStepCount; i++) { | 187 for (int i = 0; i < kIgnoredDelayedTaskStepCount; i++) { |
188 // Dummy idle task progress. | 188 // Dummy idle task progress. |
189 marking->incremental_marking_job()->NotifyIdleTaskProgress(); | 189 marking->incremental_marking_job()->NotifyIdleTaskProgress(); |
190 CHECK(platform.PendingDelayedTask()); | 190 CHECK(platform.PendingDelayedTask()); |
191 platform.PerformDelayedTask(); | 191 platform.PerformDelayedTask(); |
192 } | 192 } |
193 // Once we stop notifying idle task progress, the delayed tasks | 193 // Once we stop notifying idle task progress, the delayed tasks |
194 // should finish marking. | 194 // should finish marking. |
195 while (!marking->IsStopped() && platform.PendingDelayedTask()) { | 195 while (!marking->IsStopped() && platform.PendingDelayedTask()) { |
196 platform.PerformDelayedTask(); | 196 platform.PerformDelayedTask(); |
197 } | 197 } |
198 // There could be pending delayed task from memory reducer after GC finishes. | 198 // There could be pending delayed task from memory reducer after GC finishes. |
199 CHECK(marking->IsStopped()); | 199 CHECK(marking->IsStopped()); |
200 i::V8::SetPlatformForTesting(old_platform); | 200 i::V8::SetPlatformForTesting(old_platform); |
201 } | 201 } |
202 | 202 |
203 } // namespace internal | 203 } // namespace internal |
204 } // namespace v8 | 204 } // namespace v8 |
OLD | NEW |