Commit 2d13cc90 authored by Omer Katz's avatar Omer Katz Committed by Commit Bot

cppgc: Fix compaction cancellation

Bug: chromium:1056170
Change-Id: I6b77c06b8c787a00be00b84490155588608c75da
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2764464Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73448}
parent e7dc7720
......@@ -470,7 +470,6 @@ void Compactor::InitializeIfShouldCompact(
compaction_worklists_ = std::make_unique<CompactionWorklists>();
is_enabled_ = true;
enable_for_next_gc_for_testing_ = false;
}
bool Compactor::CancelIfShouldNotCompact(
......@@ -506,9 +505,15 @@ Compactor::CompactableSpaceHandling Compactor::CompactSpacesIfEnabled() {
CompactSpace(space, movable_references);
}
enable_for_next_gc_for_testing_ = false;
is_enabled_ = false;
return CompactableSpaceHandling::kIgnore;
}
void Compactor::EnableForNextGCForTesting() {
DCHECK_NULL(heap_.heap()->marker());
enable_for_next_gc_for_testing_ = true;
}
} // namespace internal
} // namespace cppgc
......@@ -34,7 +34,7 @@ class V8_EXPORT_PRIVATE Compactor final {
return compaction_worklists_.get();
}
void EnableForNextGCForTesting() { enable_for_next_gc_for_testing_ = true; }
void EnableForNextGCForTesting();
bool IsEnabledForTesting() const { return is_enabled_; }
private:
......
......@@ -76,13 +76,6 @@ class CompactorTest : public testing::TestWithPlatform {
EXPECT_TRUE(compactor().IsEnabledForTesting());
}
void CancelCompaction() {
bool cancelled = compactor().CancelIfShouldNotCompact(
GarbageCollector::Config::MarkingType::kAtomic,
GarbageCollector::Config::StackState::kMayContainHeapPointers);
EXPECT_TRUE(cancelled);
}
void FinishCompaction() { compactor().CompactSpacesIfEnabled(); }
void StartGC() {
......@@ -134,11 +127,6 @@ TEST_F(CompactorTest, NothingToCompact) {
heap()->stats_collector()->NotifySweepingCompleted();
}
TEST_F(CompactorTest, CancelledNothingToCompact) {
StartCompaction();
CancelCompaction();
}
TEST_F(CompactorTest, NonEmptySpaceAllLive) {
static constexpr int kNumObjects = 10;
Persistent<CompactableHolder<kNumObjects>> holder =
......
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