mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
wasm: fix bugs in GC and runtime
This commit is contained in:
parent
5caa400eb7
commit
f2668b867d
|
@ -919,9 +919,9 @@ class WasmGenerationVisitor implements StatementVisitor, ExprVisitor {
|
|||
}
|
||||
|
||||
slotExpr.acceptVisitor(this);
|
||||
WasmExpression slot = result;
|
||||
WasmExpression slotOffset = getSlotOffset(result);
|
||||
WasmExpression address = new WasmGetLocal(stackVariable);
|
||||
address = new WasmIntBinary(WasmIntType.INT32, WasmIntBinaryOperation.ADD, address, slot);
|
||||
address = new WasmIntBinary(WasmIntType.INT32, WasmIntBinaryOperation.ADD, address, slotOffset);
|
||||
|
||||
gcRootExpr.acceptVisitor(this);
|
||||
WasmExpression gcRoot = result;
|
||||
|
@ -936,13 +936,22 @@ class WasmGenerationVisitor implements StatementVisitor, ExprVisitor {
|
|||
}
|
||||
|
||||
slotExpr.acceptVisitor(this);
|
||||
WasmExpression slot = result;
|
||||
WasmExpression slotOffset = getSlotOffset(result);
|
||||
WasmExpression address = new WasmGetLocal(stackVariable);
|
||||
address = new WasmIntBinary(WasmIntType.INT32, WasmIntBinaryOperation.ADD, address, slot);
|
||||
address = new WasmIntBinary(WasmIntType.INT32, WasmIntBinaryOperation.ADD, address, slotOffset);
|
||||
|
||||
result = new WasmStoreInt32(4, address, new WasmInt32Constant(0), WasmInt32Subtype.INT32);
|
||||
}
|
||||
|
||||
private WasmExpression getSlotOffset(WasmExpression slot) {
|
||||
if (slot instanceof WasmInt32Constant) {
|
||||
int slotConstant = ((WasmInt32Constant) slot).getValue();
|
||||
return new WasmInt32Constant(slotConstant << 2);
|
||||
} else {
|
||||
return new WasmIntBinary(WasmIntType.INT32, WasmIntBinaryOperation.SHL, slot, new WasmInt32Constant(2));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(BlockStatement statement) {
|
||||
WasmBlock block = new WasmBlock(false);
|
||||
|
|
|
@ -157,7 +157,7 @@ public class AddressIntrinsic implements WasmIntrinsic {
|
|||
WasmCall call = new WasmCall(WasmMangling.mangleMethod(delegate));
|
||||
call.getArguments().addAll(invocation.getArguments().stream()
|
||||
.map(arg -> manager.generate(arg))
|
||||
.collect(Collectors.toSet()));
|
||||
.collect(Collectors.toList()));
|
||||
return call;
|
||||
}
|
||||
case "isLessThan": {
|
||||
|
|
|
@ -169,8 +169,6 @@ public class GcRootMaintainingTransformer {
|
|||
registerInvocation.getArguments().add(slotVar);
|
||||
registerInvocation.getArguments().add(program.variableAt(liveVar));
|
||||
instructionsToAdd.add(registerInvocation);
|
||||
|
||||
++slot;
|
||||
}
|
||||
|
||||
while (slot < maxDepth) {
|
||||
|
|
|
@ -317,6 +317,7 @@ public final class GC {
|
|||
Address address = Address.fromInt(Structure.sizeOf(RuntimeArray.class));
|
||||
address = Address.align(address, itemSize);
|
||||
address = address.add(itemSize * array.size);
|
||||
address = Address.align(address, 4);
|
||||
return address.toInt();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user