mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-23 23:04:50 -08:00
C/Wasm: trying to fix GC
This commit is contained in:
parent
6790ad0818
commit
84aa50e7eb
|
@ -33,6 +33,10 @@ public final class GC {
|
||||||
private static final byte CARD_GAP = 4;
|
private static final byte CARD_GAP = 4;
|
||||||
private static final byte CARD_RELOCATABLE = 8;
|
private static final byte CARD_RELOCATABLE = 8;
|
||||||
|
|
||||||
|
// Add some value greater than 4 to size of last object in a chunk to avoid 4 bytes chunks
|
||||||
|
// that aren't denotable in heap
|
||||||
|
private static final byte GC_OBJECT_GAP = 5;
|
||||||
|
|
||||||
static Address currentChunkLimit;
|
static Address currentChunkLimit;
|
||||||
static FreeChunk currentChunk;
|
static FreeChunk currentChunk;
|
||||||
static FreeChunkHolder currentChunkPointer;
|
static FreeChunkHolder currentChunkPointer;
|
||||||
|
@ -113,8 +117,8 @@ public final class GC {
|
||||||
if (getNextChunkIfPossible(size)) {
|
if (getNextChunkIfPossible(size)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
collectGarbageImpl(size);
|
collectGarbageImpl(size + GC_OBJECT_GAP);
|
||||||
if (currentChunk.size < size + 5 && !getNextChunkIfPossible(size)) {
|
if (currentChunk.size < size + GC_OBJECT_GAP && !getNextChunkIfPossible(size)) {
|
||||||
ExceptionHandling.printStack();
|
ExceptionHandling.printStack();
|
||||||
outOfMemory();
|
outOfMemory();
|
||||||
}
|
}
|
||||||
|
@ -131,7 +135,7 @@ public final class GC {
|
||||||
}
|
}
|
||||||
currentChunkPointer = Structure.add(FreeChunkHolder.class, currentChunkPointer, 1);
|
currentChunkPointer = Structure.add(FreeChunkHolder.class, currentChunkPointer, 1);
|
||||||
currentChunk = currentChunkPointer.value;
|
currentChunk = currentChunkPointer.value;
|
||||||
if (currentChunk.size >= size + 5) {
|
if (currentChunk.size >= size + GC_OBJECT_GAP) {
|
||||||
currentChunkLimit = currentChunk.toAddress().add(currentChunk.size);
|
currentChunkLimit = currentChunk.toAddress().add(currentChunk.size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -786,7 +790,7 @@ public final class GC {
|
||||||
if (shouldRelocateObject) {
|
if (shouldRelocateObject) {
|
||||||
while (true) {
|
while (true) {
|
||||||
nextRelocationTarget = relocationTarget.add(size);
|
nextRelocationTarget = relocationTarget.add(size);
|
||||||
if (!relocationBlock.end.isLessThan(nextRelocationTarget.add(5))) {
|
if (!relocationBlock.end.isLessThan(nextRelocationTarget.add(GC_OBJECT_GAP))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user