Commit c586450c authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

heap: Add callback for incremental marking start

The callback is useful to embedders to trigger various actions such as
recomputing live set.

Bug: chromium:1056170
Change-Id: I7d80b9b768a728e23303f945e416df97fd9b7805
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2173358
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67532}
parent 0b8d4bda
......@@ -3510,23 +3510,7 @@ void Heap::FinalizeIncrementalMarkingAtomically(
CollectAllGarbage(current_gc_flags_, gc_reason, current_gc_callback_flags_);
}
void Heap::FinalizeIncrementalMarkingIncrementally(
GarbageCollectionReason gc_reason) {
if (FLAG_trace_incremental_marking) {
isolate()->PrintWithTimestamp(
"[IncrementalMarking] (%s).\n",
Heap::GarbageCollectionReasonToString(gc_reason));
}
DevToolsTraceEventScope devtools_trace_event_scope(
this, "MajorGC", "incremental finalization step");
HistogramTimerScope incremental_marking_scope(
isolate()->counters()->gc_incremental_marking_finalize());
TRACE_EVENT0("v8", "V8.GCIncrementalMarkingFinalize");
TRACE_GC(tracer(), GCTracer::Scope::MC_INCREMENTAL_FINALIZE);
{
void Heap::InvokeIncrementalMarkingPrologueCallbacks() {
GCCallbacksScope scope(this);
if (scope.CheckReenter()) {
AllowHeapAllocation allow_allocation;
......@@ -3535,9 +3519,9 @@ void Heap::FinalizeIncrementalMarkingIncrementally(
HandleScope handle_scope(isolate_);
CallGCPrologueCallbacks(kGCTypeIncrementalMarking, kNoGCCallbackFlags);
}
}
incremental_marking()->FinalizeIncrementally();
{
}
void Heap::InvokeIncrementalMarkingEpilogueCallbacks() {
GCCallbacksScope scope(this);
if (scope.CheckReenter()) {
AllowHeapAllocation allow_allocation;
......@@ -3546,7 +3530,27 @@ void Heap::FinalizeIncrementalMarkingIncrementally(
HandleScope handle_scope(isolate_);
CallGCEpilogueCallbacks(kGCTypeIncrementalMarking, kNoGCCallbackFlags);
}
}
void Heap::FinalizeIncrementalMarkingIncrementally(
GarbageCollectionReason gc_reason) {
if (FLAG_trace_incremental_marking) {
isolate()->PrintWithTimestamp(
"[IncrementalMarking] (%s).\n",
Heap::GarbageCollectionReasonToString(gc_reason));
}
DevToolsTraceEventScope devtools_trace_event_scope(
this, "MajorGC", "incremental finalization step");
HistogramTimerScope incremental_marking_scope(
isolate()->counters()->gc_incremental_marking_finalize());
TRACE_EVENT0("v8", "V8.GCIncrementalMarkingFinalize");
TRACE_GC(tracer(), GCTracer::Scope::MC_INCREMENTAL_FINALIZE);
InvokeIncrementalMarkingPrologueCallbacks();
incremental_marking()->FinalizeIncrementally();
InvokeIncrementalMarkingEpilogueCallbacks();
}
void Heap::RegisterDeserializedObjectsForBlackAllocation(
......
......@@ -1731,6 +1731,9 @@ class Heap {
void FinalizeIncrementalMarkingIncrementally(
GarbageCollectionReason gc_reason);
void InvokeIncrementalMarkingPrologueCallbacks();
void InvokeIncrementalMarkingEpilogueCallbacks();
// Returns the timer used for a given GC type.
// - GCScavenger: young generation GC
// - GCCompactor: full GC
......
......@@ -322,6 +322,9 @@ void IncrementalMarking::StartMarking() {
heap()->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Start marking\n");
}
heap_->InvokeIncrementalMarkingPrologueCallbacks();
is_compacting_ = !FLAG_never_compact && collector_->StartCompaction();
collector_->StartMarking();
......@@ -352,6 +355,8 @@ void IncrementalMarking::StartMarking() {
heap_->local_embedder_heap_tracer()->TracePrologue(
heap_->flags_for_embedder_tracer());
}
heap_->InvokeIncrementalMarkingEpilogueCallbacks();
}
void IncrementalMarking::StartBlackAllocation() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment