cppgc-js: Explicitly initialize a moved-away struct

The struct is reused across various GC cycles and std::move() may leave
the vector in valid but unspecified state.

Change-Id: I3c40795be7397d015b96116d3549953024b98808
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3160197
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76811}
This commit is contained in:
Michael Lippautz 2021-09-14 09:18:57 +02:00 committed by V8 LUCI CQ
parent b2c5afb9d8
commit 1461e09297

View File

@ -254,6 +254,7 @@ void CppHeap::MetricRecorderAdapter::AddMainThreadEvent(
if (incremental_mark_batched_events_.events.size() == kMaxBatchedEvents) {
recorder->AddMainThreadEvent(std::move(incremental_mark_batched_events_),
GetContextId());
incremental_mark_batched_events_ = {};
}
}
@ -272,6 +273,7 @@ void CppHeap::MetricRecorderAdapter::AddMainThreadEvent(
if (incremental_sweep_batched_events_.events.size() == kMaxBatchedEvents) {
recorder->AddMainThreadEvent(std::move(incremental_sweep_batched_events_),
GetContextId());
incremental_sweep_batched_events_ = {};
}
}
@ -282,10 +284,12 @@ void CppHeap::MetricRecorderAdapter::FlushBatchedIncrementalEvents() {
if (!incremental_mark_batched_events_.events.empty()) {
recorder->AddMainThreadEvent(std::move(incremental_mark_batched_events_),
GetContextId());
incremental_mark_batched_events_ = {};
}
if (!incremental_sweep_batched_events_.events.empty()) {
recorder->AddMainThreadEvent(std::move(incremental_sweep_batched_events_),
GetContextId());
incremental_sweep_batched_events_ = {};
}
}