b7e6eb9208
When hitting objects that are allocated in the most recent lienar allocation area, the concurrent marker currently has to bail out to the main thread. However, we only have to delay processing those objects until we are at a safepoint, e.g. IM::Step(). With this change we flush those on-hold-objects back to the shared queue upon performing an incremental marking step. Bug: chromium:694255 Change-Id: I25647d0fc581a5c4de0346bc394dc51062f65f70 Reviewed-on: https://chromium-review.googlesource.com/707315 Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Cr-Commit-Position: refs/heads/master@{#48424}
96 lines
3.1 KiB
C++
96 lines
3.1 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/mark-compact.h"
|
|
#include "src/heap/worklist.h"
|
|
#include "test/cctest/cctest.h"
|
|
#include "test/cctest/heap/heap-utils.h"
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
namespace heap {
|
|
|
|
void PublishSegment(ConcurrentMarking::MarkingWorklist* worklist,
|
|
HeapObject* object) {
|
|
for (size_t 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();
|
|
CcTest::CollectAllGarbage();
|
|
if (!heap->incremental_marking()->IsStopped()) return;
|
|
MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector();
|
|
if (collector->sweeping_in_progress()) {
|
|
collector->EnsureSweepingCompleted();
|
|
}
|
|
|
|
ConcurrentMarking::MarkingWorklist shared, bailout, on_hold;
|
|
WeakObjects weak_objects;
|
|
ConcurrentMarking* concurrent_marking =
|
|
new ConcurrentMarking(heap, &shared, &bailout, &on_hold, &weak_objects);
|
|
PublishSegment(&shared, heap->undefined_value());
|
|
concurrent_marking->ScheduleTasks();
|
|
concurrent_marking->WaitForTasks();
|
|
concurrent_marking->EnsureCompleted();
|
|
delete concurrent_marking;
|
|
}
|
|
|
|
TEST(ConcurrentMarkingReschedule) {
|
|
if (!i::FLAG_concurrent_marking) return;
|
|
CcTest::InitializeVM();
|
|
Heap* heap = CcTest::heap();
|
|
CcTest::CollectAllGarbage();
|
|
if (!heap->incremental_marking()->IsStopped()) return;
|
|
MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector();
|
|
if (collector->sweeping_in_progress()) {
|
|
collector->EnsureSweepingCompleted();
|
|
}
|
|
|
|
ConcurrentMarking::MarkingWorklist shared, bailout, on_hold;
|
|
WeakObjects weak_objects;
|
|
ConcurrentMarking* concurrent_marking =
|
|
new ConcurrentMarking(heap, &shared, &bailout, &on_hold, &weak_objects);
|
|
PublishSegment(&shared, heap->undefined_value());
|
|
concurrent_marking->ScheduleTasks();
|
|
concurrent_marking->WaitForTasks();
|
|
concurrent_marking->EnsureCompleted();
|
|
PublishSegment(&shared, heap->undefined_value());
|
|
concurrent_marking->RescheduleTasksIfNeeded();
|
|
concurrent_marking->WaitForTasks();
|
|
concurrent_marking->EnsureCompleted();
|
|
delete concurrent_marking;
|
|
}
|
|
|
|
TEST(ConcurrentMarkingMarkedBytes) {
|
|
if (!i::FLAG_concurrent_marking) return;
|
|
CcTest::InitializeVM();
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
Heap* heap = CcTest::heap();
|
|
HandleScope sc(isolate);
|
|
Handle<FixedArray> root = isolate->factory()->NewFixedArray(1000000);
|
|
CcTest::CollectAllGarbage();
|
|
if (!heap->incremental_marking()->IsStopped()) return;
|
|
heap::SimulateIncrementalMarking(heap, false);
|
|
heap->concurrent_marking()->WaitForTasks();
|
|
heap->concurrent_marking()->EnsureCompleted();
|
|
CHECK_GE(heap->concurrent_marking()->TotalMarkedBytes(), root->Size());
|
|
}
|
|
|
|
} // namespace heap
|
|
} // namespace internal
|
|
} // namespace v8
|