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
|
@ -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.WasmReturn;
|
||||||
import org.teavm.backend.wasm.model.expression.WasmSetGlobal;
|
import org.teavm.backend.wasm.model.expression.WasmSetGlobal;
|
||||||
import org.teavm.backend.wasm.model.expression.WasmSetLocal;
|
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.WasmStructGet;
|
||||||
import org.teavm.backend.wasm.model.expression.WasmStructNewDefault;
|
import org.teavm.backend.wasm.model.expression.WasmStructNewDefault;
|
||||||
import org.teavm.backend.wasm.model.expression.WasmStructSet;
|
import org.teavm.backend.wasm.model.expression.WasmStructSet;
|
||||||
|
@ -558,18 +559,22 @@ public class WasmGCClassGenerator implements WasmGCClassInfoProvider, WasmGCInit
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
primitiveType = boolean.class;
|
primitiveType = boolean.class;
|
||||||
wrapperType = Boolean.class;
|
wrapperType = Boolean.class;
|
||||||
|
result.setSignedType(WasmSignedType.UNSIGNED);
|
||||||
break;
|
break;
|
||||||
case BYTE:
|
case BYTE:
|
||||||
primitiveType = byte.class;
|
primitiveType = byte.class;
|
||||||
wrapperType = Byte.class;
|
wrapperType = Byte.class;
|
||||||
|
result.setSignedType(WasmSignedType.SIGNED);
|
||||||
break;
|
break;
|
||||||
case SHORT:
|
case SHORT:
|
||||||
primitiveType = short.class;
|
primitiveType = short.class;
|
||||||
wrapperType = Short.class;
|
wrapperType = Short.class;
|
||||||
|
result.setSignedType(WasmSignedType.SIGNED);
|
||||||
break;
|
break;
|
||||||
case CHARACTER:
|
case CHARACTER:
|
||||||
primitiveType = char.class;
|
primitiveType = char.class;
|
||||||
wrapperType = Character.class;
|
wrapperType = Character.class;
|
||||||
|
result.setSignedType(WasmSignedType.UNSIGNED);
|
||||||
break;
|
break;
|
||||||
case INTEGER:
|
case INTEGER:
|
||||||
primitiveType = int.class;
|
primitiveType = int.class;
|
||||||
|
|
|
@ -238,9 +238,11 @@ public class WasmGCMethodGenerator implements BaseWasmFunctionRepository {
|
||||||
var variable = method.getProgram().variableAt(i);
|
var variable = method.getProgram().variableAt(i);
|
||||||
var varNodeIndex = variable.getRegister() >= 0 ? originalIndexToIndex[variable.getRegister()] : -1;
|
var varNodeIndex = variable.getRegister() >= 0 ? originalIndexToIndex[variable.getRegister()] : -1;
|
||||||
if (varNodeIndex >= 0 && variableRepresentatives[varNodeIndex] < 0) {
|
if (varNodeIndex >= 0 && variableRepresentatives[varNodeIndex] < 0) {
|
||||||
|
if (typeInference.typeOf(variable) != null) {
|
||||||
variableRepresentatives[varNodeIndex] = variable.getIndex();
|
variableRepresentatives[varNodeIndex] = variable.getIndex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (var i = firstVar; i < ast.getVariables().size(); ++i) {
|
for (var i = firstVar; i < ast.getVariables().size(); ++i) {
|
||||||
var localVar = ast.getVariables().get(i);
|
var localVar = ast.getVariables().get(i);
|
||||||
|
|
|
@ -47,10 +47,12 @@ import org.teavm.model.Program;
|
||||||
import org.teavm.model.ProgramReader;
|
import org.teavm.model.ProgramReader;
|
||||||
import org.teavm.model.TextLocation;
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.TryCatchBlock;
|
import org.teavm.model.TryCatchBlock;
|
||||||
|
import org.teavm.model.ValueType;
|
||||||
import org.teavm.model.VariableReader;
|
import org.teavm.model.VariableReader;
|
||||||
import org.teavm.model.analysis.ClassInference;
|
import org.teavm.model.analysis.ClassInference;
|
||||||
import org.teavm.model.instructions.AbstractInstructionReader;
|
import org.teavm.model.instructions.AbstractInstructionReader;
|
||||||
import org.teavm.model.instructions.AssignInstruction;
|
import org.teavm.model.instructions.AssignInstruction;
|
||||||
|
import org.teavm.model.instructions.CastInstruction;
|
||||||
import org.teavm.model.instructions.ExitInstruction;
|
import org.teavm.model.instructions.ExitInstruction;
|
||||||
import org.teavm.model.instructions.InvocationType;
|
import org.teavm.model.instructions.InvocationType;
|
||||||
import org.teavm.model.instructions.InvokeInstruction;
|
import org.teavm.model.instructions.InvokeInstruction;
|
||||||
|
@ -456,8 +458,20 @@ public class Inlining {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (implementations.size() == 1) {
|
if (implementations.size() == 1) {
|
||||||
|
var implementation = implementations.iterator().next();
|
||||||
invoke.setType(InvocationType.SPECIAL);
|
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