mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-10 08:54:11 -08:00
When unexpected exception occurs during optimization, dump IR to stderr.
This commit is contained in:
parent
a30ac3cd83
commit
3dbca7959b
|
@ -354,11 +354,7 @@ public class PhiUpdater {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Variable, TryCatchJoint> joints = jointMap.get(tryCatch);
|
Map<Variable, TryCatchJoint> joints = jointMap.computeIfAbsent(tryCatch, k -> new HashMap<>());
|
||||||
if (joints == null) {
|
|
||||||
joints = new HashMap<>();
|
|
||||||
jointMap.put(tryCatch, joints);
|
|
||||||
}
|
|
||||||
TryCatchJoint joint = joints.get(original);
|
TryCatchJoint joint = joints.get(original);
|
||||||
if (joint == null) {
|
if (joint == null) {
|
||||||
joint = new TryCatchJoint();
|
joint = new TryCatchJoint();
|
||||||
|
@ -398,7 +394,7 @@ public class PhiUpdater {
|
||||||
private Variable use(Variable var) {
|
private Variable use(Variable var) {
|
||||||
Variable mappedVar = variableMap[var.getIndex()];
|
Variable mappedVar = variableMap[var.getIndex()];
|
||||||
if (mappedVar == null) {
|
if (mappedVar == null) {
|
||||||
throw new AssertionError();
|
throw new AssertionError("Variable used before definition: " + var.getIndex());
|
||||||
}
|
}
|
||||||
return mappedVar;
|
return mappedVar;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ import org.teavm.model.optimization.MethodOptimization;
|
||||||
import org.teavm.model.optimization.RedundantJumpElimination;
|
import org.teavm.model.optimization.RedundantJumpElimination;
|
||||||
import org.teavm.model.optimization.UnreachableBasicBlockElimination;
|
import org.teavm.model.optimization.UnreachableBasicBlockElimination;
|
||||||
import org.teavm.model.optimization.UnusedVariableElimination;
|
import org.teavm.model.optimization.UnusedVariableElimination;
|
||||||
|
import org.teavm.model.util.ListingBuilder;
|
||||||
import org.teavm.model.util.MissingItemsProcessor;
|
import org.teavm.model.util.MissingItemsProcessor;
|
||||||
import org.teavm.model.util.ModelUtils;
|
import org.teavm.model.util.ModelUtils;
|
||||||
import org.teavm.model.util.ProgramUtils;
|
import org.teavm.model.util.ProgramUtils;
|
||||||
|
@ -478,7 +479,15 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
|
||||||
do {
|
do {
|
||||||
changed = false;
|
changed = false;
|
||||||
for (MethodOptimization optimization : getOptimizations()) {
|
for (MethodOptimization optimization : getOptimizations()) {
|
||||||
|
try {
|
||||||
changed |= optimization.optimize(method, optimizedProgram);
|
changed |= optimization.optimize(method, optimizedProgram);
|
||||||
|
} catch (Exception e) {
|
||||||
|
ListingBuilder listingBuilder = new ListingBuilder();
|
||||||
|
String listing = listingBuilder.buildListing(optimizedProgram, "");
|
||||||
|
System.err.println("Error optimizing program for method" + method.getReference()
|
||||||
|
+ ":\n" + listing);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} while (changed);
|
} while (changed);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user