v8/test/cctest/heap/test-concurrent-marking.cc
Ulan Degenbaev 20d5048a6f [heap] Keep concurrent marking tasks running until marking is completed.
BUG=chromium:694255

Change-Id: Id874d7427b52f5c2d1d7ae72d321cad8277f8082
Reviewed-on: https://chromium-review.googlesource.com/570035
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46639}
2017-07-13 13:33:54 +00:00

61 lines
1.8 KiB
C++

// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <stdlib.h>
#include "src/v8.h"
#include "src/heap/concurrent-marking.h"
#include "src/heap/heap-inl.h"
#include "src/heap/heap.h"
#include "src/heap/worklist.h"
#include "test/cctest/cctest.h"
#include "test/cctest/heap/heap-utils.h"
namespace v8 {
namespace internal {
void PublishSegment(ConcurrentMarking::MarkingWorklist* worklist,
HeapObject* object) {
for (int i = 0; i <= ConcurrentMarking::MarkingWorklist::kSegmentCapacity;
i++) {
worklist->Push(0, object);
}
CHECK(worklist->Pop(0, &object));
}
TEST(ConcurrentMarking) {
if (!i::FLAG_concurrent_marking) return;
CcTest::InitializeVM();
Heap* heap = CcTest::heap();
ConcurrentMarking::MarkingWorklist shared, bailout;
ConcurrentMarking* concurrent_marking =
new ConcurrentMarking(heap, &shared, &bailout);
PublishSegment(&shared, heap->undefined_value());
concurrent_marking->Start();
concurrent_marking->EnsureCompleted();
delete concurrent_marking;
}
TEST(ConcurrentMarkingWaiting) {
if (!i::FLAG_concurrent_marking) return;
CcTest::InitializeVM();
Heap* heap = CcTest::heap();
ConcurrentMarking::MarkingWorklist shared, bailout;
ConcurrentMarking* concurrent_marking =
new ConcurrentMarking(heap, &shared, &bailout);
PublishSegment(&shared, heap->undefined_value());
concurrent_marking->Start();
while (!concurrent_marking->AllTasksWaitingForTesting()) {
// Busy wait.
}
PublishSegment(&shared, heap->undefined_value());
concurrent_marking->NotifyWaitingTasks();
concurrent_marking->EnsureCompleted();
delete concurrent_marking;
}
} // namespace internal
} // namespace v8