Commit 848f989e authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[embedder-tracing] Deprecate NumberOfWrappersToTrace

Deprecates EmbedderHeapTracer::NumberOfWrappersToTrace and replaces it
with EmbedderHeapTracer::IsTracingDone.

V8 only really cares about the final state (emptiness) here and
embedders may choose implementations that have a hard time determinining
exact size for their work queues.

Bug: chromium:843903
Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: I1e141c47771ef08aab7dbe204e8175cfee99cf92
Reviewed-on: https://chromium-review.googlesource.com/1127599
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54311}
parent 9942994e
......@@ -7038,6 +7038,12 @@ class V8_EXPORT EmbedderHeapTracer {
virtual bool AdvanceTracing(double deadline_in_ms,
AdvanceTracingActions actions) = 0;
/*
* Returns true if there no more tracing work to be done (see AdvanceTracing)
* and false otherwise.
*/
virtual bool IsTracingDone() { return NumberOfWrappersToTrace() == 0; }
/**
* Called at the end of a GC cycle.
*
......@@ -7062,7 +7068,8 @@ class V8_EXPORT EmbedderHeapTracer {
/**
* Returns the number of wrappers that are still to be traced by the embedder.
*/
virtual size_t NumberOfWrappersToTrace() { return 0; }
V8_DEPRECATE_SOON("Use IsTracingDone",
virtual size_t NumberOfWrappersToTrace() { return 0; });
protected:
virtual ~EmbedderHeapTracer() = default;
......
......@@ -45,11 +45,10 @@ bool LocalEmbedderHeapTracer::Trace(
return remote_tracer_->AdvanceTracing(deadline, actions);
}
size_t LocalEmbedderHeapTracer::NumberOfWrappersToTrace() {
return (InUse())
? cached_wrappers_to_trace_.size() +
remote_tracer_->NumberOfWrappersToTrace()
: 0;
bool LocalEmbedderHeapTracer::IsRemoteTracingDone() {
return (InUse()) ? cached_wrappers_to_trace_.empty() &&
remote_tracer_->IsTracingDone()
: true;
}
void LocalEmbedderHeapTracer::RegisterWrappersWithRemoteTracer() {
......
......@@ -30,8 +30,8 @@ class V8_EXPORT_PRIVATE LocalEmbedderHeapTracer final {
void EnterFinalPause();
bool Trace(double deadline,
EmbedderHeapTracer::AdvanceTracingActions actions);
bool IsRemoteTracingDone();
size_t NumberOfWrappersToTrace();
size_t NumberOfCachedWrappersToTrace() {
return cached_wrappers_to_trace_.size();
}
......@@ -51,7 +51,7 @@ class V8_EXPORT_PRIVATE LocalEmbedderHeapTracer final {
bool ShouldFinalizeIncrementalMarking() {
static const size_t kMaxIncrementalFixpointRounds = 3;
return !FLAG_incremental_marking_wrappers || !InUse() ||
NumberOfWrappersToTrace() == 0 ||
IsRemoteTracingDone() ||
num_v8_marking_worklist_was_empty_ > kMaxIncrementalFixpointRounds;
}
......
......@@ -1504,10 +1504,9 @@ void MarkCompactCollector::ProcessEphemeronsUntilFixpoint() {
CHECK(weak_objects_.current_ephemerons.IsEmpty());
CHECK(weak_objects_.discovered_ephemerons.IsEmpty());
work_to_do =
work_to_do || !marking_worklist()->IsEmpty() ||
work_to_do = work_to_do || !marking_worklist()->IsEmpty() ||
heap()->concurrent_marking()->ephemeron_marked() ||
heap()->local_embedder_heap_tracer()->NumberOfWrappersToTrace() > 0;
!heap()->local_embedder_heap_tracer()->IsRemoteTracingDone();
++iterations;
}
......@@ -1620,9 +1619,8 @@ void MarkCompactCollector::ProcessEphemeronsLinear() {
// for work_to_do are not sufficient for determining if another iteration
// is necessary.
work_to_do =
!marking_worklist()->IsEmpty() ||
heap()->local_embedder_heap_tracer()->NumberOfWrappersToTrace() > 0;
work_to_do = !marking_worklist()->IsEmpty() ||
!heap()->local_embedder_heap_tracer()->IsRemoteTracingDone();
CHECK(weak_objects_.discovered_ephemerons.IsEmpty());
}
......@@ -1692,7 +1690,7 @@ void MarkCompactCollector::ProcessEphemeronMarking() {
ProcessEphemeronsUntilFixpoint();
CHECK(marking_worklist()->IsEmpty());
CHECK_EQ(0, heap()->local_embedder_heap_tracer()->NumberOfWrappersToTrace());
CHECK(heap()->local_embedder_heap_tracer()->IsRemoteTracingDone());
}
void MarkCompactCollector::ProcessTopOptimizedFrame(ObjectVisitor* visitor) {
......
......@@ -30,7 +30,7 @@ class MockEmbedderHeapTracer : public EmbedderHeapTracer {
MOCK_METHOD0(TraceEpilogue, void());
MOCK_METHOD0(AbortTracing, void());
MOCK_METHOD0(EnterFinalPause, void());
MOCK_METHOD0(NumberOfWrappersToTrace, size_t());
MOCK_METHOD0(IsTracingDone, bool());
MOCK_METHOD1(RegisterV8References,
void(const std::vector<std::pair<void*, void*> >&));
MOCK_METHOD2(AdvanceTracing,
......@@ -100,12 +100,12 @@ TEST(LocalEmbedderHeapTracer, EnterFinalPauseForwards) {
local_tracer.EnterFinalPause();
}
TEST(LocalEmbedderHeapTracer, NumberOfWrappersToTraceIncludesRemote) {
TEST(LocalEmbedderHeapTracer, IsRemoteTracingDoneIncludesRemote) {
LocalEmbedderHeapTracer local_tracer;
StrictMock<MockEmbedderHeapTracer> remote_tracer;
local_tracer.SetRemoteTracer(&remote_tracer);
EXPECT_CALL(remote_tracer, NumberOfWrappersToTrace());
local_tracer.NumberOfWrappersToTrace();
EXPECT_CALL(remote_tracer, IsTracingDone());
local_tracer.IsRemoteTracingDone();
}
TEST(LocalEmbedderHeapTracer, NumberOfCachedWrappersToTraceExcludesRemote) {
......@@ -124,8 +124,8 @@ TEST(LocalEmbedderHeapTracer, RegisterWrappersWithRemoteTracer) {
EXPECT_CALL(remote_tracer, RegisterV8References(_));
local_tracer.RegisterWrappersWithRemoteTracer();
EXPECT_EQ(0u, local_tracer.NumberOfCachedWrappersToTrace());
EXPECT_CALL(remote_tracer, NumberOfWrappersToTrace()).WillOnce(Return(1));
EXPECT_EQ(1u, local_tracer.NumberOfWrappersToTrace());
EXPECT_CALL(remote_tracer, IsTracingDone()).WillOnce(Return(false));
EXPECT_FALSE(local_tracer.IsRemoteTracingDone());
}
TEST(LocalEmbedderHeapTracer, TraceFinishes) {
......
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