cppgc: Fix compaction cancellation
Bug: chromium:1056170 Change-Id: I6b77c06b8c787a00be00b84490155588608c75da Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2764464 Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Commit-Queue: Omer Katz <omerkatz@chromium.org> Cr-Commit-Position: refs/heads/master@{#73448}
This commit is contained in:
parent
e7dc77203e
commit
2d13cc9076
@ -470,7 +470,6 @@ void Compactor::InitializeIfShouldCompact(
|
|||||||
compaction_worklists_ = std::make_unique<CompactionWorklists>();
|
compaction_worklists_ = std::make_unique<CompactionWorklists>();
|
||||||
|
|
||||||
is_enabled_ = true;
|
is_enabled_ = true;
|
||||||
enable_for_next_gc_for_testing_ = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Compactor::CancelIfShouldNotCompact(
|
bool Compactor::CancelIfShouldNotCompact(
|
||||||
@ -506,9 +505,15 @@ Compactor::CompactableSpaceHandling Compactor::CompactSpacesIfEnabled() {
|
|||||||
CompactSpace(space, movable_references);
|
CompactSpace(space, movable_references);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enable_for_next_gc_for_testing_ = false;
|
||||||
is_enabled_ = false;
|
is_enabled_ = false;
|
||||||
return CompactableSpaceHandling::kIgnore;
|
return CompactableSpaceHandling::kIgnore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Compactor::EnableForNextGCForTesting() {
|
||||||
|
DCHECK_NULL(heap_.heap()->marker());
|
||||||
|
enable_for_next_gc_for_testing_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace cppgc
|
} // namespace cppgc
|
||||||
|
@ -34,7 +34,7 @@ class V8_EXPORT_PRIVATE Compactor final {
|
|||||||
return compaction_worklists_.get();
|
return compaction_worklists_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnableForNextGCForTesting() { enable_for_next_gc_for_testing_ = true; }
|
void EnableForNextGCForTesting();
|
||||||
bool IsEnabledForTesting() const { return is_enabled_; }
|
bool IsEnabledForTesting() const { return is_enabled_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -76,13 +76,6 @@ class CompactorTest : public testing::TestWithPlatform {
|
|||||||
EXPECT_TRUE(compactor().IsEnabledForTesting());
|
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 FinishCompaction() { compactor().CompactSpacesIfEnabled(); }
|
||||||
|
|
||||||
void StartGC() {
|
void StartGC() {
|
||||||
@ -134,11 +127,6 @@ TEST_F(CompactorTest, NothingToCompact) {
|
|||||||
heap()->stats_collector()->NotifySweepingCompleted();
|
heap()->stats_collector()->NotifySweepingCompleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CompactorTest, CancelledNothingToCompact) {
|
|
||||||
StartCompaction();
|
|
||||||
CancelCompaction();
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(CompactorTest, NonEmptySpaceAllLive) {
|
TEST_F(CompactorTest, NonEmptySpaceAllLive) {
|
||||||
static constexpr int kNumObjects = 10;
|
static constexpr int kNumObjects = 10;
|
||||||
Persistent<CompactableHolder<kNumObjects>> holder =
|
Persistent<CompactableHolder<kNumObjects>> holder =
|
||||||
|
Loading…
Reference in New Issue
Block a user