mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
wasm gc: fix issues, make more test passing
This commit is contained in:
parent
1dc7bc653d
commit
019eb4500c
|
@ -122,7 +122,7 @@ public abstract class BaseDisassemblyListener {
|
|||
var refType = (WasmHollowType.CompositeReference) type;
|
||||
writer.write("(ref ");
|
||||
if (refType.isNullable()) {
|
||||
writer.write("null");
|
||||
writer.write("null ");
|
||||
}
|
||||
writeTypeRef(refType.index);
|
||||
writer.write(")");
|
||||
|
|
|
@ -64,6 +64,7 @@ import org.teavm.backend.wasm.model.expression.WasmNullConstant;
|
|||
import org.teavm.backend.wasm.model.expression.WasmReturn;
|
||||
import org.teavm.backend.wasm.model.expression.WasmSetGlobal;
|
||||
import org.teavm.backend.wasm.model.expression.WasmSetLocal;
|
||||
import org.teavm.backend.wasm.model.expression.WasmSignedType;
|
||||
import org.teavm.backend.wasm.model.expression.WasmStructGet;
|
||||
import org.teavm.backend.wasm.model.expression.WasmStructNewDefault;
|
||||
import org.teavm.backend.wasm.model.expression.WasmStructSet;
|
||||
|
@ -558,18 +559,22 @@ public class WasmGCClassGenerator implements WasmGCClassInfoProvider, WasmGCInit
|
|||
case BOOLEAN:
|
||||
primitiveType = boolean.class;
|
||||
wrapperType = Boolean.class;
|
||||
result.setSignedType(WasmSignedType.UNSIGNED);
|
||||
break;
|
||||
case BYTE:
|
||||
primitiveType = byte.class;
|
||||
wrapperType = Byte.class;
|
||||
result.setSignedType(WasmSignedType.SIGNED);
|
||||
break;
|
||||
case SHORT:
|
||||
primitiveType = short.class;
|
||||
wrapperType = Short.class;
|
||||
result.setSignedType(WasmSignedType.SIGNED);
|
||||
break;
|
||||
case CHARACTER:
|
||||
primitiveType = char.class;
|
||||
wrapperType = Character.class;
|
||||
result.setSignedType(WasmSignedType.UNSIGNED);
|
||||
break;
|
||||
case INTEGER:
|
||||
primitiveType = int.class;
|
||||
|
|
|
@ -238,7 +238,9 @@ public class WasmGCMethodGenerator implements BaseWasmFunctionRepository {
|
|||
var variable = method.getProgram().variableAt(i);
|
||||
var varNodeIndex = variable.getRegister() >= 0 ? originalIndexToIndex[variable.getRegister()] : -1;
|
||||
if (varNodeIndex >= 0 && variableRepresentatives[varNodeIndex] < 0) {
|
||||
variableRepresentatives[varNodeIndex] = variable.getIndex();
|
||||
if (typeInference.typeOf(variable) != null) {
|
||||
variableRepresentatives[varNodeIndex] = variable.getIndex();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,10 +47,12 @@ import org.teavm.model.Program;
|
|||
import org.teavm.model.ProgramReader;
|
||||
import org.teavm.model.TextLocation;
|
||||
import org.teavm.model.TryCatchBlock;
|
||||
import org.teavm.model.ValueType;
|
||||
import org.teavm.model.VariableReader;
|
||||
import org.teavm.model.analysis.ClassInference;
|
||||
import org.teavm.model.instructions.AbstractInstructionReader;
|
||||
import org.teavm.model.instructions.AssignInstruction;
|
||||
import org.teavm.model.instructions.CastInstruction;
|
||||
import org.teavm.model.instructions.ExitInstruction;
|
||||
import org.teavm.model.instructions.InvocationType;
|
||||
import org.teavm.model.instructions.InvokeInstruction;
|
||||
|
@ -456,8 +458,20 @@ public class Inlining {
|
|||
}
|
||||
|
||||
if (implementations.size() == 1) {
|
||||
var implementation = implementations.iterator().next();
|
||||
invoke.setType(InvocationType.SPECIAL);
|
||||
invoke.setMethod(implementations.iterator().next());
|
||||
invoke.setMethod(implementation);
|
||||
|
||||
if (!implementation.getName().equals(invoke.getMethod().getClassName())) {
|
||||
var cast = new CastInstruction();
|
||||
cast.setWeak(true);
|
||||
cast.setValue(invoke.getInstance());
|
||||
cast.setReceiver(program.createVariable());
|
||||
cast.setLocation(invoke.getLocation());
|
||||
cast.setTargetType(ValueType.object(implementation.getClassName()));
|
||||
invoke.insertPrevious(cast);
|
||||
invoke.setInstance(cast.getReceiver());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user