mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Avoid creating programs with number of variables less than number of parameters
This commit is contained in:
parent
2e20287f80
commit
86b78b8f5d
|
@ -326,6 +326,11 @@ public class JavaScriptTarget implements TeaVMTarget, TeaVMJavaScriptHost {
|
|||
|
||||
Program program = new Program();
|
||||
method.setProgram(program);
|
||||
|
||||
for (int i = 0; i <= method.parameterCount(); ++i) {
|
||||
program.createVariable();
|
||||
}
|
||||
|
||||
BasicBlock block = program.createBasicBlock();
|
||||
Variable exceptionVar = program.createVariable();
|
||||
ConstructInstruction newExceptionInsn = new ConstructInstruction();
|
||||
|
|
|
@ -29,6 +29,10 @@ public class UnusedVariableElimination implements MethodOptimization {
|
|||
boolean[] escaping = VariableEscapeAnalyzer.findEscapingVariables(program);
|
||||
boolean[] used = new boolean[escaping.length];
|
||||
|
||||
for (int i = 0; i <= method.parameterCount(); ++i) {
|
||||
used[i] = true;
|
||||
}
|
||||
|
||||
int[] stack = new int[graph.size() * 2];
|
||||
int top = 0;
|
||||
for (int i = 0; i < used.length; ++i) {
|
||||
|
|
|
@ -28,7 +28,7 @@ public class TypeInferer {
|
|||
GraphBuilder arrayElemBuilder;
|
||||
|
||||
public void inferTypes(ProgramReader program, MethodReference method) {
|
||||
int sz = Math.max(method.parameterCount(), program.variableCount());
|
||||
int sz = program.variableCount();
|
||||
types = new VariableType[sz];
|
||||
|
||||
types[0] = VariableType.OBJECT;
|
||||
|
|
Loading…
Reference in New Issue
Block a user