df212a095b
Provide a way to trigger a write barrier when updating the embedder fields. In future, such a mechanism should be encapsulated into V8. Bug: chromium:1056170 Change-Id: I4e43362993c3e58d5bebdd58a7d46a39c0aa4f06 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2640419 Reviewed-by: Omer Katz <omerkatz@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/master@{#72227}
45 lines
1.5 KiB
C++
45 lines
1.5 KiB
C++
// Copyright 2020 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 "test/unittests/heap/heap-utils.h"
|
|
|
|
#include "src/heap/incremental-marking.h"
|
|
#include "src/heap/mark-compact.h"
|
|
#include "src/heap/safepoint.h"
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
|
|
void HeapInternalsBase::SimulateIncrementalMarking(Heap* heap,
|
|
bool force_completion) {
|
|
constexpr double kStepSizeInMs = 100;
|
|
CHECK(FLAG_incremental_marking);
|
|
i::IncrementalMarking* marking = heap->incremental_marking();
|
|
i::MarkCompactCollector* collector = heap->mark_compact_collector();
|
|
if (collector->sweeping_in_progress()) {
|
|
SafepointScope scope(heap);
|
|
collector->EnsureSweepingCompleted();
|
|
}
|
|
CHECK(marking->IsMarking() || marking->IsStopped() || marking->IsComplete());
|
|
if (marking->IsStopped()) {
|
|
heap->StartIncrementalMarking(i::Heap::kNoGCFlags,
|
|
i::GarbageCollectionReason::kTesting);
|
|
}
|
|
CHECK(marking->IsMarking() || marking->IsComplete());
|
|
if (!force_completion) return;
|
|
|
|
while (!marking->IsComplete()) {
|
|
marking->Step(kStepSizeInMs, i::IncrementalMarking::NO_GC_VIA_STACK_GUARD,
|
|
i::StepOrigin::kV8);
|
|
if (marking->IsReadyToOverApproximateWeakClosure()) {
|
|
SafepointScope scope(heap);
|
|
marking->FinalizeIncrementally();
|
|
}
|
|
}
|
|
CHECK(marking->IsComplete());
|
|
}
|
|
|
|
} // namespace internal
|
|
} // namespace v8
|