Commit 637f04f6 authored by Anton Bikineev's avatar Anton Bikineev Committed by Commit Bot

cppgc: Clean up some tests

Bug: chromium:1029379
Change-Id: I9b030cd8d130793ba5b79303b71e3d60be981218
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2246567
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68359}
parent 3a929dfa
......@@ -22,11 +22,11 @@ class GCHeapTest : public testing::TestWithHeap {
public:
void ConservativeGC() {
internal::Heap::From(GetHeap())->CollectGarbage(
{Heap::StackState::kMayContainHeapPointers});
Heap::Config::ConservativeAtomicConfig());
}
void PreciseGC() {
internal::Heap::From(GetHeap())->CollectGarbage(
{Heap::StackState::kNoHeapPointers});
Heap::Config::PreciseAtomicConfig());
}
};
......@@ -67,7 +67,7 @@ namespace {
const void* ConservativeGCReturningObject(cppgc::Heap* heap,
const void* volatile object) {
internal::Heap::From(heap)->CollectGarbage(
{Heap::StackState::kMayContainHeapPointers});
Heap::Config::ConservativeAtomicConfig());
return object;
}
......
......@@ -6,6 +6,7 @@
#include "include/cppgc/allocation.h"
#include "include/cppgc/garbage-collected.h"
#include "include/cppgc/persistent.h"
#include "src/heap/cppgc/heap-object-header-inl.h"
#include "src/heap/cppgc/heap.h"
#include "test/unittests/heap/cppgc/tests.h"
......@@ -44,11 +45,12 @@ TEST_F(PrefinalizerTest, PrefinalizerCalledOnDeadObject) {
TEST_F(PrefinalizerTest, PrefinalizerNotCalledOnLiveObject) {
GCed::prefinalizer_callcount = 0;
auto* object = MakeGarbageCollected<GCed>(GetAllocationHandle());
HeapObjectHeader::FromPayload(object).TryMarkAtomic();
EXPECT_EQ(0u, GCed::prefinalizer_callcount);
PreciseGC();
EXPECT_EQ(0u, GCed::prefinalizer_callcount);
{
Persistent<GCed> object = MakeGarbageCollected<GCed>(GetAllocationHandle());
EXPECT_EQ(0u, GCed::prefinalizer_callcount);
PreciseGC();
EXPECT_EQ(0u, GCed::prefinalizer_callcount);
}
PreciseGC();
EXPECT_EQ(1u, GCed::prefinalizer_callcount);
}
......@@ -84,11 +86,13 @@ TEST_F(PrefinalizerTest, PrefinalizerCalledOnDeadMixinObject) {
TEST_F(PrefinalizerTest, PrefinalizerNotCalledOnLiveMixinObject) {
Mixin::prefinalizer_callcount = 0;
auto* object = MakeGarbageCollected<GCedWithMixin>(GetAllocationHandle());
HeapObjectHeader::FromPayload(object).TryMarkAtomic();
EXPECT_EQ(0u, Mixin::prefinalizer_callcount);
PreciseGC();
EXPECT_EQ(0u, Mixin::prefinalizer_callcount);
{
Persistent<GCedWithMixin> object =
MakeGarbageCollected<GCedWithMixin>(GetAllocationHandle());
EXPECT_EQ(0u, Mixin::prefinalizer_callcount);
PreciseGC();
EXPECT_EQ(0u, Mixin::prefinalizer_callcount);
}
PreciseGC();
EXPECT_EQ(1u, Mixin::prefinalizer_callcount);
}
......
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