mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Add unused variable elimination to standard optimization levels
This commit is contained in:
parent
6c6e7c0d4d
commit
89f835540b
|
@ -34,69 +34,13 @@ public final class VariableEscapeAnalyzer {
|
|||
return escaping;
|
||||
}
|
||||
|
||||
private static class InstructionAnalyzer implements InstructionVisitor {
|
||||
private static class InstructionAnalyzer extends AbstractInstructionVisitor {
|
||||
private boolean[] escaping;
|
||||
|
||||
public InstructionAnalyzer(boolean[] escaping) {
|
||||
InstructionAnalyzer(boolean[] escaping) {
|
||||
this.escaping = escaping;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(EmptyInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ClassConstantInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(NullConstantInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(IntegerConstantInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(LongConstantInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(FloatConstantInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DoubleConstantInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(StringConstantInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(BinaryInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(NegateInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(AssignInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(CastInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(CastNumberInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(CastIntegerInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(BranchingInstruction insn) {
|
||||
escaping[insn.getOperand().getIndex()] = true;
|
||||
|
@ -108,10 +52,6 @@ public final class VariableEscapeAnalyzer {
|
|||
escaping[insn.getSecondOperand().getIndex()] = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(JumpInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(SwitchInstruction insn) {
|
||||
escaping[insn.getCondition().getIndex()] = true;
|
||||
|
@ -129,22 +69,6 @@ public final class VariableEscapeAnalyzer {
|
|||
escaping[insn.getException().getIndex()] = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ConstructArrayInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ConstructInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ConstructMultiArrayInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(GetFieldInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(PutFieldInstruction insn) {
|
||||
if (insn.getInstance() != null) {
|
||||
|
@ -153,22 +77,6 @@ public final class VariableEscapeAnalyzer {
|
|||
escaping[insn.getValue().getIndex()] = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ArrayLengthInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(CloneArrayInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(UnwrapArrayInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(GetElementInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(PutElementInstruction insn) {
|
||||
escaping[insn.getArray().getIndex()] = true;
|
||||
|
@ -196,18 +104,6 @@ public final class VariableEscapeAnalyzer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(IsInstanceInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(InitClassInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(NullCheckInstruction insn) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(MonitorEnterInstruction insn) {
|
||||
escaping[insn.getObjectRef().getIndex()] = true;
|
||||
|
|
|
@ -564,6 +564,7 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
|
|||
}
|
||||
optimizations.add(new ClassInitElimination());
|
||||
optimizations.add(new UnreachableBasicBlockElimination());
|
||||
optimizations.add(new UnusedVariableElimination());
|
||||
return optimizations;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user