summaryrefslogtreecommitdiff
path: root/deps/v8/src/heap/cppgc/compactor.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/heap/cppgc/compactor.cc')
-rw-r--r--deps/v8/src/heap/cppgc/compactor.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/deps/v8/src/heap/cppgc/compactor.cc b/deps/v8/src/heap/cppgc/compactor.cc
index 91f30445a3..c300793515 100644
--- a/deps/v8/src/heap/cppgc/compactor.cc
+++ b/deps/v8/src/heap/cppgc/compactor.cc
@@ -474,6 +474,7 @@ void Compactor::InitializeIfShouldCompact(
compaction_worklists_ = std::make_unique<CompactionWorklists>();
is_enabled_ = true;
+ is_cancelled_ = false;
}
bool Compactor::CancelIfShouldNotCompact(
@@ -481,15 +482,16 @@ bool Compactor::CancelIfShouldNotCompact(
GarbageCollector::Config::StackState stack_state) {
if (!is_enabled_ || ShouldCompact(marking_type, stack_state)) return false;
- DCHECK_NOT_NULL(compaction_worklists_);
- compaction_worklists_->movable_slots_worklist()->Clear();
- compaction_worklists_.reset();
-
+ is_cancelled_ = true;
is_enabled_ = false;
return true;
}
Compactor::CompactableSpaceHandling Compactor::CompactSpacesIfEnabled() {
+ if (is_cancelled_ && compaction_worklists_) {
+ compaction_worklists_->movable_slots_worklist()->Clear();
+ compaction_worklists_.reset();
+ }
if (!is_enabled_) return CompactableSpaceHandling::kSweep;
StatsCollector::EnabledScope stats_scope(heap_.heap()->stats_collector(),