[heap] Add compaction space for shared space

Compacting pages in the shared space during Full GC requires a
corresponding shared space.

Bug: v8:13267
Change-Id: I1952c6b907847220018e2255956cc405fb88d144
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3918271
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83453}
This commit is contained in:
Dominik Inführ 2022-09-27 09:37:05 +02:00 committed by V8 LUCI CQ
parent 9211d5fe34
commit 24a6f3fc4d
3 changed files with 25 additions and 18 deletions

View File

@ -29,6 +29,9 @@ AllocationResult EvacuationAllocator::Allocate(AllocationSpace space,
case CODE_SPACE:
return compaction_spaces_.Get(CODE_SPACE)
->AllocateRaw(object_size, alignment, origin);
case SHARED_SPACE:
return compaction_spaces_.Get(SHARED_SPACE)
->AllocateRaw(object_size, alignment, origin);
default:
UNREACHABLE();
}
@ -42,10 +45,13 @@ void EvacuationAllocator::FreeLast(AllocationSpace space, HeapObject object,
FreeLastInNewSpace(object, object_size);
return;
case OLD_SPACE:
FreeLastInOldSpace(object, object_size);
FreeLastInCompactionSpace(OLD_SPACE, object, object_size);
return;
case MAP_SPACE:
FreeLastInMapSpace(object, object_size);
FreeLastInCompactionSpace(MAP_SPACE, object, object_size);
return;
case SHARED_SPACE:
FreeLastInCompactionSpace(SHARED_SPACE, object, object_size);
return;
default:
// Only new and old space supported.
@ -61,18 +67,10 @@ void EvacuationAllocator::FreeLastInNewSpace(HeapObject object,
}
}
void EvacuationAllocator::FreeLastInOldSpace(HeapObject object,
void EvacuationAllocator::FreeLastInCompactionSpace(AllocationSpace space,
HeapObject object,
int object_size) {
if (!compaction_spaces_.Get(OLD_SPACE)->TryFreeLast(object.address(),
object_size)) {
// We couldn't free the last object so we have to write a proper filler.
heap_->CreateFillerObjectAt(object.address(), object_size);
}
}
void EvacuationAllocator::FreeLastInMapSpace(HeapObject object,
int object_size) {
if (!compaction_spaces_.Get(MAP_SPACE)->TryFreeLast(object.address(),
if (!compaction_spaces_.Get(space)->TryFreeLast(object.address(),
object_size)) {
// We couldn't free the last object so we have to write a proper filler.
heap_->CreateFillerObjectAt(object.address(), object_size);

View File

@ -39,6 +39,10 @@ class EvacuationAllocator {
heap_->map_space()->MergeCompactionSpace(
compaction_spaces_.Get(MAP_SPACE));
}
if (heap_->shared_space()) {
heap_->shared_space()->MergeCompactionSpace(
compaction_spaces_.Get(SHARED_SPACE));
}
// Give back remaining LAB space if this EvacuationAllocator's new space LAB
// sits right next to new space allocation top.
@ -60,8 +64,8 @@ class EvacuationAllocator {
inline AllocationResult AllocateInLAB(int object_size,
AllocationAlignment alignment);
inline void FreeLastInNewSpace(HeapObject object, int object_size);
inline void FreeLastInOldSpace(HeapObject object, int object_size);
inline void FreeLastInMapSpace(HeapObject object, int object_size);
inline void FreeLastInCompactionSpace(AllocationSpace space,
HeapObject object, int object_size);
Heap* const heap_;
NewSpace* const new_space_;

View File

@ -483,6 +483,8 @@ class CompactionSpaceCollection : public Malloced {
map_space_(heap, MAP_SPACE, Executability::NOT_EXECUTABLE,
compaction_space_kind),
code_space_(heap, CODE_SPACE, Executability::EXECUTABLE,
compaction_space_kind),
shared_space_(heap, SHARED_SPACE, Executability::NOT_EXECUTABLE,
compaction_space_kind) {}
CompactionSpace* Get(AllocationSpace space) {
@ -493,6 +495,8 @@ class CompactionSpaceCollection : public Malloced {
return &map_space_;
case CODE_SPACE:
return &code_space_;
case SHARED_SPACE:
return &shared_space_;
default:
UNREACHABLE();
}
@ -503,6 +507,7 @@ class CompactionSpaceCollection : public Malloced {
CompactionSpace old_space_;
CompactionSpace map_space_;
CompactionSpace code_space_;
CompactionSpace shared_space_;
};
// -----------------------------------------------------------------------------