Commit 04c1cbb8 authored by Anton Bikineev's avatar Anton Bikineev Committed by V8 LUCI CQ

cppgc: Support compaction only for uncompressed pointers

Compaction currently considers only backing store pointers as slots and
those are uncompressed. The CL fixes the tests to use raw pointers
instead of Members.

Bug: chromium:1325007
Change-Id: I2ddfffeeab396552bb7cf31b2bd8502ebc2921fb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3695590
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81056}
parent 26999f99
......@@ -255,6 +255,7 @@ class V8_EXPORT Visitor {
* compactable space. Such references maybe be arbitrarily moved by the GC.
*
* \param slot location of reference to object that might be moved by the GC.
* The slot must contain an uncompressed pointer.
*/
template <typename T>
void RegisterMovableReference(const T** slot) {
......
......@@ -31,11 +31,12 @@ struct CompactableGCed : public GarbageCollected<CompactableGCed> {
public:
~CompactableGCed() { ++g_destructor_callcount; }
void Trace(Visitor* visitor) const {
visitor->Trace(other);
visitor->RegisterMovableReference(other.GetSlotForTesting());
visitor->Trace(const_cast<const CompactableGCed*>(other));
visitor->RegisterMovableReference(
const_cast<const CompactableGCed**>(&other));
}
static size_t g_destructor_callcount;
Member<CompactableGCed> other;
CompactableGCed* other = nullptr;
size_t id = 0;
};
// static
......@@ -52,11 +53,12 @@ struct CompactableHolder
void Trace(Visitor* visitor) const {
for (int i = 0; i < kNumObjects; ++i) {
visitor->Trace(objects[i]);
visitor->RegisterMovableReference(objects[i].GetSlotForTesting());
visitor->Trace(const_cast<const CompactableGCed*>(objects[i]));
visitor->RegisterMovableReference(
const_cast<const CompactableGCed**>(&objects[i]));
}
}
Member<CompactableGCed> objects[kNumObjects];
CompactableGCed* objects[kNumObjects]{};
};
class CompactorTest : public testing::TestWithPlatform {
......@@ -195,7 +197,7 @@ TEST_F(CompactorTest, CompactAcrossPages) {
// Last allocated object should be on a new page.
EXPECT_NE(reference, holder->objects[0]);
EXPECT_NE(BasePage::FromInnerAddress(heap(), reference),
BasePage::FromInnerAddress(heap(), holder->objects[0].Get()));
BasePage::FromInnerAddress(heap(), holder->objects[0]));
StartGC();
EndGC();
// Half of object were destroyed.
......
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