mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-10 17:04:09 -08:00
Fix bug in GC
This commit is contained in:
parent
ea5dd80199
commit
7ef639ec8a
|
@ -305,13 +305,27 @@ public final class GC {
|
||||||
int end = upper;
|
int end = upper;
|
||||||
int mid = (lower + upper) / 2;
|
int mid = (lower + upper) / 2;
|
||||||
|
|
||||||
FreeChunk midChunk = getFreeChunk(mid).value;
|
int midSize = getFreeChunk(mid).value.size;
|
||||||
|
int firstSize = getFreeChunk(lower).value.size;
|
||||||
|
int lastSize = getFreeChunk(upper).value.size;
|
||||||
|
if (midSize < firstSize) {
|
||||||
|
int tmp = firstSize;
|
||||||
|
firstSize = midSize;
|
||||||
|
midSize = tmp;
|
||||||
|
}
|
||||||
|
if (lastSize < firstSize) {
|
||||||
|
lastSize = firstSize;
|
||||||
|
}
|
||||||
|
if (midSize > lastSize) {
|
||||||
|
midSize = lastSize;
|
||||||
|
}
|
||||||
|
|
||||||
outer: while (true) {
|
outer: while (true) {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (lower == upper) {
|
if (lower == upper) {
|
||||||
break outer;
|
break outer;
|
||||||
}
|
}
|
||||||
if (getFreeChunk(lower).value.size <= midChunk.size) {
|
if (getFreeChunk(lower).value.size <= midSize) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++lower;
|
++lower;
|
||||||
|
@ -320,7 +334,7 @@ public final class GC {
|
||||||
if (lower == upper) {
|
if (lower == upper) {
|
||||||
break outer;
|
break outer;
|
||||||
}
|
}
|
||||||
if (getFreeChunk(upper).value.size > midChunk.size) {
|
if (getFreeChunk(upper).value.size > midSize) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
--upper;
|
--upper;
|
||||||
|
@ -330,6 +344,9 @@ public final class GC {
|
||||||
getFreeChunk(upper).value = tmp;
|
getFreeChunk(upper).value = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lower == end || upper == start) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (lower - start > 0) {
|
if (lower - start > 0) {
|
||||||
sortFreeChunks(start, lower);
|
sortFreeChunks(start, lower);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user