| 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 CcTest::InitializeVM(); | 143 CcTest::InitializeVM(); |
| 144 v8::Platform* old_platform = i::V8::GetCurrentPlatform(); | 144 v8::Platform* old_platform = i::V8::GetCurrentPlatform(); |
| 145 MockPlatform platform(old_platform); | 145 MockPlatform platform(old_platform); |
| 146 i::V8::SetPlatformForTesting(&platform); | 146 i::V8::SetPlatformForTesting(&platform); |
| 147 i::heap::SimulateFullSpace(CcTest::heap()->old_space()); | 147 i::heap::SimulateFullSpace(CcTest::heap()->old_space()); |
| 148 CcTest::heap()->CollectAllGarbage(); | 148 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); |
| 149 i::IncrementalMarking* marking = CcTest::heap()->incremental_marking(); | 149 i::IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
| 150 marking->Stop(); | 150 marking->Stop(); |
| 151 marking->Start(); | 151 marking->Start(i::GarbageCollectionReason::kTesting); |
| 152 CHECK(platform.PendingIdleTask()); | 152 CHECK(platform.PendingIdleTask()); |
| 153 const double kLongIdleTimeInSeconds = 1; | 153 const double kLongIdleTimeInSeconds = 1; |
| 154 const double kShortIdleTimeInSeconds = 0.010; | 154 const double kShortIdleTimeInSeconds = 0.010; |
| 155 const int kShortStepCount = 10; | 155 const int kShortStepCount = 10; |
| 156 for (int i = 0; i < kShortStepCount && platform.PendingIdleTask(); i++) { | 156 for (int i = 0; i < kShortStepCount && platform.PendingIdleTask(); i++) { |
| 157 platform.PerformIdleTask(kShortIdleTimeInSeconds); | 157 platform.PerformIdleTask(kShortIdleTimeInSeconds); |
| 158 } | 158 } |
| 159 while (platform.PendingIdleTask()) { | 159 while (platform.PendingIdleTask()) { |
| 160 platform.PerformIdleTask(kLongIdleTimeInSeconds); | 160 platform.PerformIdleTask(kLongIdleTimeInSeconds); |
| 161 } | 161 } |
| 162 CHECK(marking->IsStopped()); | 162 CHECK(marking->IsStopped()); |
| 163 i::V8::SetPlatformForTesting(old_platform); | 163 i::V8::SetPlatformForTesting(old_platform); |
| 164 } | 164 } |
| 165 | 165 |
| 166 | 166 |
| 167 TEST(IncrementalMarkingUsingDelayedTasks) { | 167 TEST(IncrementalMarkingUsingDelayedTasks) { |
| 168 if (!i::FLAG_incremental_marking) return; | 168 if (!i::FLAG_incremental_marking) return; |
| 169 CcTest::InitializeVM(); | 169 CcTest::InitializeVM(); |
| 170 v8::Platform* old_platform = i::V8::GetCurrentPlatform(); | 170 v8::Platform* old_platform = i::V8::GetCurrentPlatform(); |
| 171 MockPlatform platform(old_platform); | 171 MockPlatform platform(old_platform); |
| 172 i::V8::SetPlatformForTesting(&platform); | 172 i::V8::SetPlatformForTesting(&platform); |
| 173 i::heap::SimulateFullSpace(CcTest::heap()->old_space()); | 173 i::heap::SimulateFullSpace(CcTest::heap()->old_space()); |
| 174 i::IncrementalMarking* marking = CcTest::heap()->incremental_marking(); | 174 i::IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
| 175 marking->Stop(); | 175 marking->Stop(); |
| 176 marking->Start(); | 176 marking->Start(i::GarbageCollectionReason::kTesting); |
| 177 CHECK(platform.PendingIdleTask()); | 177 CHECK(platform.PendingIdleTask()); |
| 178 // 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. |
| 179 const int kIgnoredDelayedTaskStepCount = 1000; | 179 const int kIgnoredDelayedTaskStepCount = 1000; |
| 180 for (int i = 0; i < kIgnoredDelayedTaskStepCount; i++) { | 180 for (int i = 0; i < kIgnoredDelayedTaskStepCount; i++) { |
| 181 // Dummy idle task progress. | 181 // Dummy idle task progress. |
| 182 marking->incremental_marking_job()->NotifyIdleTaskProgress(); | 182 marking->incremental_marking_job()->NotifyIdleTaskProgress(); |
| 183 CHECK(platform.PendingDelayedTask()); | 183 CHECK(platform.PendingDelayedTask()); |
| 184 platform.PerformDelayedTask(); | 184 platform.PerformDelayedTask(); |
| 185 } | 185 } |
| 186 // Once we stop notifying idle task progress, the delayed tasks | 186 // Once we stop notifying idle task progress, the delayed tasks |
| 187 // should finish marking. | 187 // should finish marking. |
| 188 while (!marking->IsStopped() && platform.PendingDelayedTask()) { | 188 while (!marking->IsStopped() && platform.PendingDelayedTask()) { |
| 189 platform.PerformDelayedTask(); | 189 platform.PerformDelayedTask(); |
| 190 } | 190 } |
| 191 // 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. |
| 192 CHECK(marking->IsStopped()); | 192 CHECK(marking->IsStopped()); |
| 193 i::V8::SetPlatformForTesting(old_platform); | 193 i::V8::SetPlatformForTesting(old_platform); |
| 194 } | 194 } |
| 195 | 195 |
| 196 } // namespace internal | 196 } // namespace internal |
| 197 } // namespace v8 | 197 } // namespace v8 |
| OLD | NEW |