C: fix GC

This commit is contained in:
Alexey Andreev 2019-07-09 14:41:53 +03:00
parent 3ed75a97d4
commit 8a359c6434

View File

@ -312,16 +312,16 @@ public final class GC {
if (!object.toAddress().isLessThan(currentRegionEnd)) { if (!object.toAddress().isLessThan(currentRegionEnd)) {
currentRegionIndex = (int) ((object.toAddress().toLong() - heapAddress().toLong()) / regionSize()); currentRegionIndex = (int) ((object.toAddress().toLong() - heapAddress().toLong()) / regionSize());
Region currentRegion = Structure.add(Region.class, regionsAddress(), currentRegionIndex); Region currentRegion = Structure.add(Region.class, regionsAddress(), currentRegionIndex);
if (currentRegion.start == 0) { while (currentRegion.start == 0) {
do {
if (++currentRegionIndex == regionsCount) { if (++currentRegionIndex == regionsCount) {
object = limit.toStructure(); object = limit.toStructure();
break loop; break loop;
} }
currentRegion = Structure.add(Region.class, regionsAddress(), currentRegionIndex); currentRegion = Structure.add(Region.class, regionsAddress(), currentRegionIndex);
} while (currentRegion.start == 0);
} }
currentRegionEnd = currentRegion.toAddress().add(regionSize()); Address newRegionStart = heapAddress().add(currentRegionIndex * regionSize());
object = newRegionStart.add(currentRegion.start - 1).toStructure();
currentRegionEnd = newRegionStart.add(regionSize());
} }
} else { } else {
if (lastFreeSpace != null) { if (lastFreeSpace != null) {