mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -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;
|
||||
}
|
||||
|
||||
Map<Variable, TryCatchJoint> joints = jointMap.get(tryCatch);
|
||||
if (joints == null) {
|
||||
joints = new HashMap<>();
|
||||
jointMap.put(tryCatch, joints);
|
||||
}
|
||||
Map<Variable, TryCatchJoint> joints = jointMap.computeIfAbsent(tryCatch, k -> new HashMap<>());
|
||||
TryCatchJoint joint = joints.get(original);
|
||||
if (joint == null) {
|
||||
joint = new TryCatchJoint();
|
||||
|
@ -398,7 +394,7 @@ public class PhiUpdater {
|
|||
private Variable use(Variable var) {
|
||||
Variable mappedVar = variableMap[var.getIndex()];
|
||||
if (mappedVar == null) {
|
||||
throw new AssertionError();
|
||||
throw new AssertionError("Variable used before definition: " + var.getIndex());
|
||||
}
|
||||
return mappedVar;
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ import org.teavm.model.optimization.MethodOptimization;
|
|||
import org.teavm.model.optimization.RedundantJumpElimination;
|
||||
import org.teavm.model.optimization.UnreachableBasicBlockElimination;
|
||||
import org.teavm.model.optimization.UnusedVariableElimination;
|
||||
import org.teavm.model.util.ListingBuilder;
|
||||
import org.teavm.model.util.MissingItemsProcessor;
|
||||
import org.teavm.model.util.ModelUtils;
|
||||
import org.teavm.model.util.ProgramUtils;
|
||||
|
@ -478,7 +479,15 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
|
|||
do {
|
||||
changed = false;
|
||||
for (MethodOptimization optimization : getOptimizations()) {
|
||||
changed |= optimization.optimize(method, optimizedProgram);
|
||||
try {
|
||||
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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user