Commit 7bf42ad6 authored by Omer Katz's avatar Omer Katz Committed by V8 LUCI CQ

cppgc: std::move of base::optional doesn't reset

Chromium builds indicate that moving an optional doesn't reset the
source, and the source still indicates it has a value.
That may be a bug in base::optional, but we should fix it here first to
resolve current crashes.

Bug: chromium:1154636
Cq-Include-Trybots: luci.v8.try:v8_linux_blink_rel
Change-Id: Ibfb53b6d06d5f0310e68b200cc27ca318a5a57e5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3366235Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78475}
parent cd36ed85
......@@ -304,12 +304,16 @@ bool CppHeap::MetricRecorderAdapter::MetricsReportPending() const {
const base::Optional<cppgc::internal::MetricRecorder::FullCycle>
CppHeap::MetricRecorderAdapter::ExtractLastFullGcEvent() {
return std::move(last_full_gc_event_);
auto res = std::move(last_full_gc_event_);
last_full_gc_event_.reset();
return res;
}
const base::Optional<cppgc::internal::MetricRecorder::MainThreadIncrementalMark>
CppHeap::MetricRecorderAdapter::ExtractLastIncrementalMarkEvent() {
return std::move(last_incremental_mark_event_);
auto res = std::move(last_incremental_mark_event_);
last_incremental_mark_event_.reset();
return res;
}
void CppHeap::MetricRecorderAdapter::ClearCachedEvents() {
......@@ -427,6 +431,10 @@ bool ShouldReduceMemory(CppHeap::GarbageCollectionFlags flags) {
void CppHeap::InitializeTracing(GarbageCollectionFlags gc_flags) {
CHECK(!sweeper_.IsSweepingInProgress());
// Check that previous cycle metrics have been reported.
DCHECK_IMPLIES(GetMetricRecorder(),
!GetMetricRecorder()->MetricsReportPending());
#if defined(CPPGC_YOUNG_GENERATION)
cppgc::internal::SequentialUnmarker unmarker(raw_heap());
#endif // defined(CPPGC_YOUNG_GENERATION)
......
......@@ -1403,6 +1403,7 @@ void GCTracer::ReportFullCycleToRecorder() {
optional_cppgc_event =
cpp_heap->GetMetricRecorder()->ExtractLastFullGcEvent();
DCHECK(optional_cppgc_event.has_value());
DCHECK(!cpp_heap->GetMetricRecorder()->MetricsReportPending());
const cppgc::internal::MetricRecorder::FullCycle& cppgc_event =
optional_cppgc_event.value();
CopyTimeMetrics(event.total_cpp, cppgc_event.total);
......
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