Index: test/cctest/heap/test-incremental-marking.cc |
diff --git a/test/cctest/heap/test-incremental-marking.cc b/test/cctest/heap/test-incremental-marking.cc |
index 7ea35c11308bd5c8ad47f2ae22994b0ee07a28aa..71e20669eb86aa4d2b3dc47532c32218e30df93c 100644 |
--- a/test/cctest/heap/test-incremental-marking.cc |
+++ b/test/cctest/heap/test-incremental-marking.cc |
@@ -31,11 +31,8 @@ namespace internal { |
class MockPlatform : public v8::Platform { |
public: |
explicit MockPlatform(v8::Platform* platform) |
- : platform_(platform), idle_task_(nullptr), delayed_task_(nullptr) {} |
- virtual ~MockPlatform() { |
- delete idle_task_; |
- delete delayed_task_; |
- } |
+ : platform_(platform), task_(nullptr) {} |
+ virtual ~MockPlatform() { delete task_; } |
void CallOnBackgroundThread(Task* task, |
ExpectedRuntime expected_runtime) override { |
@@ -43,15 +40,12 @@ class MockPlatform : public v8::Platform { |
} |
void CallOnForegroundThread(v8::Isolate* isolate, Task* task) override { |
- platform_->CallOnForegroundThread(isolate, task); |
+ task_ = task; |
} |
void CallDelayedOnForegroundThread(v8::Isolate* isolate, Task* task, |
double delay_in_seconds) override { |
- if (delayed_task_ != nullptr) { |
- delete delayed_task_; |
- } |
- delayed_task_ = task; |
+ platform_->CallDelayedOnForegroundThread(isolate, task, delay_in_seconds); |
} |
double MonotonicallyIncreasingTime() override { |
@@ -60,26 +54,16 @@ class MockPlatform : public v8::Platform { |
void CallIdleOnForegroundThread(v8::Isolate* isolate, |
IdleTask* task) override { |
- CHECK(nullptr == idle_task_); |
- idle_task_ = task; |
+ platform_->CallIdleOnForegroundThread(isolate, task); |
} |
bool IdleTasksEnabled(v8::Isolate* isolate) override { return true; } |
- bool PendingIdleTask() { return idle_task_ != nullptr; } |
- |
- void PerformIdleTask(double idle_time_in_seconds) { |
- IdleTask* task = idle_task_; |
- idle_task_ = nullptr; |
- task->Run(MonotonicallyIncreasingTime() + idle_time_in_seconds); |
- delete task; |
- } |
+ bool PendingTask() { return task_ != nullptr; } |
- bool PendingDelayedTask() { return delayed_task_ != nullptr; } |
- |
- void PerformDelayedTask() { |
- Task* task = delayed_task_; |
- delayed_task_ = nullptr; |
+ void PerformTask() { |
+ Task* task = task_; |
+ task_ = nullptr; |
task->Run(); |
delete task; |
} |
@@ -108,12 +92,10 @@ class MockPlatform : public v8::Platform { |
private: |
v8::Platform* platform_; |
- IdleTask* idle_task_; |
- Task* delayed_task_; |
+ Task* task_; |
}; |
- |
-TEST(IncrementalMarkingUsingIdleTasks) { |
+TEST(IncrementalMarkingUsingTasks) { |
if (!i::FLAG_incremental_marking) return; |
CcTest::InitializeVM(); |
v8::Platform* old_platform = i::V8::GetCurrentPlatform(); |
@@ -123,15 +105,9 @@ TEST(IncrementalMarkingUsingIdleTasks) { |
i::IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
marking->Stop(); |
marking->Start(i::GarbageCollectionReason::kTesting); |
- CHECK(platform.PendingIdleTask()); |
- const double kLongIdleTimeInSeconds = 1; |
- const double kShortIdleTimeInSeconds = 0.010; |
- const int kShortStepCount = 10; |
- for (int i = 0; i < kShortStepCount && platform.PendingIdleTask(); i++) { |
- platform.PerformIdleTask(kShortIdleTimeInSeconds); |
- } |
- while (platform.PendingIdleTask()) { |
- platform.PerformIdleTask(kLongIdleTimeInSeconds); |
+ CHECK(platform.PendingTask()); |
+ while (platform.PendingTask()) { |
+ platform.PerformTask(); |
} |
CHECK(marking->IsStopped()); |
i::V8::SetPlatformForTesting(old_platform); |
@@ -141,9 +117,6 @@ TEST(IncrementalMarkingUsingIdleTasks) { |
TEST(IncrementalMarkingUsingIdleTasksAfterGC) { |
if (!i::FLAG_incremental_marking) return; |
- const double kLongIdleTimeInSeconds = 1; |
- const double kShortIdleTimeInSeconds = 0.010; |
- |
CcTest::InitializeVM(); |
v8::Platform* old_platform = i::V8::GetCurrentPlatform(); |
MockPlatform platform(old_platform); |
@@ -151,51 +124,17 @@ TEST(IncrementalMarkingUsingIdleTasksAfterGC) { |
i::heap::SimulateFullSpace(CcTest::heap()->old_space()); |
CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); |
// Perform any pending idle tasks. |
- while (platform.PendingIdleTask()) { |
- platform.PerformIdleTask(kLongIdleTimeInSeconds); |
+ while (platform.PendingTask()) { |
+ platform.PerformTask(); |
} |
- CHECK(!platform.PendingIdleTask()); |
+ CHECK(!platform.PendingTask()); |
i::IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
marking->Stop(); |
marking->Start(i::GarbageCollectionReason::kTesting); |
- CHECK(platform.PendingIdleTask()); |
- const int kShortStepCount = 10; |
- for (int i = 0; i < kShortStepCount && platform.PendingIdleTask(); i++) { |
- platform.PerformIdleTask(kShortIdleTimeInSeconds); |
- } |
- while (platform.PendingIdleTask()) { |
- platform.PerformIdleTask(kLongIdleTimeInSeconds); |
- } |
- CHECK(marking->IsStopped()); |
- i::V8::SetPlatformForTesting(old_platform); |
-} |
- |
- |
-TEST(IncrementalMarkingUsingDelayedTasks) { |
- if (!i::FLAG_incremental_marking) return; |
- CcTest::InitializeVM(); |
- v8::Platform* old_platform = i::V8::GetCurrentPlatform(); |
- MockPlatform platform(old_platform); |
- i::V8::SetPlatformForTesting(&platform); |
- i::heap::SimulateFullSpace(CcTest::heap()->old_space()); |
- i::IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
- marking->Stop(); |
- marking->Start(i::GarbageCollectionReason::kTesting); |
- CHECK(platform.PendingIdleTask()); |
- // The delayed task should be a no-op if the idle task makes progress. |
- const int kIgnoredDelayedTaskStepCount = 1000; |
- for (int i = 0; i < kIgnoredDelayedTaskStepCount; i++) { |
- // Dummy idle task progress. |
- marking->incremental_marking_job()->NotifyIdleTaskProgress(); |
- CHECK(platform.PendingDelayedTask()); |
- platform.PerformDelayedTask(); |
- } |
- // Once we stop notifying idle task progress, the delayed tasks |
- // should finish marking. |
- while (!marking->IsStopped() && platform.PendingDelayedTask()) { |
- platform.PerformDelayedTask(); |
+ CHECK(platform.PendingTask()); |
+ while (platform.PendingTask()) { |
+ platform.PerformTask(); |
} |
- // There could be pending delayed task from memory reducer after GC finishes. |
CHECK(marking->IsStopped()); |
i::V8::SetPlatformForTesting(old_platform); |
} |