mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Improve compilation performance of low-level backends
This commit is contained in:
parent
7551cd1ec6
commit
83d041d55b
|
@ -100,6 +100,7 @@ public class PhiUpdater {
|
|||
private List<Phi> synthesizedPhis = new ArrayList<>();
|
||||
private Sigma[][] sigmas;
|
||||
private Predicate<Instruction> sigmaPredicate = instruction -> false;
|
||||
private int[][][] frontierVariableCache;
|
||||
|
||||
public int getSourceVariable(int var) {
|
||||
if (var >= variableToSourceMap.size()) {
|
||||
|
@ -133,6 +134,7 @@ public class PhiUpdater {
|
|||
if (program.basicBlockCount() == 0) {
|
||||
return;
|
||||
}
|
||||
frontierVariableCache = new int[program.basicBlockCount()][][];
|
||||
this.program = program;
|
||||
phisByReceiver.clear();
|
||||
cfg = ProgramUtils.buildControlFlowGraph(program);
|
||||
|
@ -473,15 +475,49 @@ public class PhiUpdater {
|
|||
}
|
||||
}
|
||||
|
||||
private int[][] getIncomingVariablesForFrontier(int frontier) {
|
||||
int[][] result = frontierVariableCache[frontier];
|
||||
if (result == null) {
|
||||
List<List<Variable>> builder = new ArrayList<>(Collections.nCopies(program.basicBlockCount(), null));
|
||||
for (Phi phi : program.basicBlockAt(frontier).getPhis()) {
|
||||
for (Incoming incoming : phi.getIncomings()) {
|
||||
List<Variable> variables = builder.get(incoming.getSource().getIndex());
|
||||
if (variables == null) {
|
||||
variables = new ArrayList<>();
|
||||
builder.set(incoming.getSource().getIndex(), variables);
|
||||
}
|
||||
variables.add(incoming.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
result = new int[program.basicBlockCount()][];
|
||||
for (int i = 0; i < result.length; ++i) {
|
||||
List<Variable> builderVariables = builder.get(i);
|
||||
if (builderVariables == null) {
|
||||
continue;
|
||||
}
|
||||
int[] resultVariables = new int[builderVariables.size()];
|
||||
for (int j = 0; j < resultVariables.length; ++j) {
|
||||
resultVariables[j] = builderVariables.get(j).getIndex();
|
||||
}
|
||||
result[i] = resultVariables;
|
||||
}
|
||||
|
||||
frontierVariableCache[frontier] = result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void placePhi(int frontier, Variable var, BasicBlock block, Deque<BasicBlock> worklist) {
|
||||
BasicBlock frontierBlock = program.basicBlockAt(frontier);
|
||||
if (frontierBlock.getExceptionVariable() == var) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Phi phi : frontierBlock.getPhis()) {
|
||||
for (Incoming incoming : phi.getIncomings()) {
|
||||
if (incoming.getSource() == block && incoming.getValue() == var) {
|
||||
int[] frontierIncomingVariables = getIncomingVariablesForFrontier(frontier)[block.getIndex()];
|
||||
if (frontierIncomingVariables != null) {
|
||||
for (int incoming : frontierIncomingVariables) {
|
||||
if (incoming == var.getIndex()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -634,7 +634,13 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
|
|||
for (int i = 0; i < methodReferences.size(); i++) {
|
||||
MethodReference methodReference = methodReferences.get(i);
|
||||
ClassHolder cls = classes.get(methodReference.getClassName());
|
||||
if (cls == null) {
|
||||
continue;
|
||||
}
|
||||
MethodHolder method = cls.getMethod(methodReference.getDescriptor());
|
||||
if (method == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (method.getProgram() != null) {
|
||||
if (!inlining.hasUsages(methodReference)) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user