Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,9 @@ public boolean visitChunk(AlignedHeapChunk.AlignedHeader chunk) {
ObjectMoveInfo.setObjectSeqSize(objSeq, objSeqSize);
}

if (sweeping) {
/*
* Continue allocating for compaction after the swept memory. Note that this forfeits
* unused memory in the chunks before, but the order of objects must stay the same
* across all chunks. If chunks end up completely empty however, they will be released
* after compaction.
*
* GR-54021: it should be possible to avoid this limitation by sweeping chunks without
* ObjectMoveInfo and brick tables and potentially even do the sweeping right here.
*/
this.allocChunk = chunk;
this.allocPointer = HeapChunk.getTopPointer(chunk);
if (sweeping && chunk.equal(allocChunk)) {
/* Continue allocating for compaction after the swept memory. */
allocPointer = HeapChunk.getTopPointer(chunk);
}

/* Set remaining brick table entries at chunk end. */
Expand All @@ -176,14 +167,17 @@ public boolean visitChunk(AlignedHeapChunk.AlignedHeader chunk) {
}

private Pointer allocate(UnsignedWord size) {
assert size.belowOrEqual(AlignedHeapChunk.getUsableSizeForObjects());
Pointer p = allocPointer;
allocPointer = allocPointer.add(size);
if (allocPointer.aboveThan(AlignedHeapChunk.getObjectsEnd(allocChunk))) {
allocPointer = p.add(size);
while (allocPointer.aboveThan(AlignedHeapChunk.getObjectsEnd(allocChunk))) {
allocChunk = HeapChunk.getNext(allocChunk);
assert allocChunk.isNonNull();
assert !allocChunk.getShouldSweepInsteadOfCompact();

p = AlignedHeapChunk.getObjectsStart(allocChunk);
if (allocChunk.getShouldSweepInsteadOfCompact()) {
p = HeapChunk.getTopPointer(allocChunk); // use any free memory at the end
} else {
p = AlignedHeapChunk.getObjectsStart(allocChunk);
}
allocPointer = p.add(size);
}
return p;
Expand Down