1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-18 19:11:19 +00:00

make StatementInfos map control flow block objects instead of labelRef's (~5% compiler speedup)

This commit is contained in:
Travis Fisher 2019-04-10 22:22:17 -04:00
parent 1f54a91463
commit b81349b3de
3 changed files with 8 additions and 9 deletions

View File

@ -276,9 +276,8 @@ public class LiveRangeVariablesEffective {
* @return All variables effectively alive at the statement on the call-path * @return All variables effectively alive at the statement on the call-path
*/ */
public Collection<VariableRef> getEffectiveAliveAtStmt(CallPath callPath) { public Collection<VariableRef> getEffectiveAliveAtStmt(CallPath callPath) {
LinkedHashSet<VariableRef> effectiveAlive = new LinkedHashSet<>();
// Add alive at call // Add alive at call
effectiveAlive.addAll(callPath.getAlive()); LinkedHashSet<VariableRef> effectiveAlive = new LinkedHashSet<>(callPath.getAlive());
// Clear out any variables referenced in the method // Clear out any variables referenced in the method
effectiveAlive.removeAll(referencedInProcedure); effectiveAlive.removeAll(referencedInProcedure);
// Add alive at statement // Add alive at statement

View File

@ -14,12 +14,12 @@ public class StatementInfos {
private ControlFlowGraph graph; private ControlFlowGraph graph;
/** Maps statement index to block label. */ /** Maps statement index to block label. */
private Map<Integer, LabelRef> stmtBlocks; private Map<Integer, ControlFlowBlock> stmtBlocks;
/** Maps statement index to statement. */ /** Maps statement index to statement. */
private Map<Integer, Statement> stmtIdx; private Map<Integer, Statement> stmtIdx;
public StatementInfos(Program program, Map<Integer, LabelRef> stmtBlocks, Map<Integer, Statement> stmtIdx) { public StatementInfos(Program program, Map<Integer, ControlFlowBlock> stmtBlocks, Map<Integer, Statement> stmtIdx) {
this.graph = program.getGraph(); this.graph = program.getGraph();
this.stmtBlocks = stmtBlocks; this.stmtBlocks = stmtBlocks;
this.stmtIdx = stmtIdx; this.stmtIdx = stmtIdx;
@ -32,7 +32,7 @@ public class StatementInfos {
* @return The block label * @return The block label
*/ */
public LabelRef getBlockRef(Integer stmtIdx) { public LabelRef getBlockRef(Integer stmtIdx) {
return stmtBlocks.get(stmtIdx); return stmtBlocks.get(stmtIdx).getLabel();
} }
/** /**
@ -42,7 +42,7 @@ public class StatementInfos {
* @return The block label * @return The block label
*/ */
public LabelRef getBlockRef(Statement stmt) { public LabelRef getBlockRef(Statement stmt) {
return stmtBlocks.get(stmt.getIndex()); return stmtBlocks.get(stmt.getIndex()).getLabel();
} }
/** /**
@ -52,7 +52,7 @@ public class StatementInfos {
* @return The containing block * @return The containing block
*/ */
public ControlFlowBlock getBlock(Statement stmt) { public ControlFlowBlock getBlock(Statement stmt) {
return graph.getBlock(getBlockRef(stmt)); return stmtBlocks.get(stmt.getIndex());
} }
/** /**

View File

@ -24,11 +24,11 @@ public class PassNStatementInfos extends Pass2SsaOptimization {
*/ */
@Override @Override
public boolean step() { public boolean step() {
LinkedHashMap<Integer, LabelRef> stmtBlocks = new LinkedHashMap<>(); LinkedHashMap<Integer, ControlFlowBlock> stmtBlocks = new LinkedHashMap<>();
LinkedHashMap<Integer, Statement> stmtIdx = new LinkedHashMap<>(); LinkedHashMap<Integer, Statement> stmtIdx = new LinkedHashMap<>();
for(ControlFlowBlock block : getProgram().getGraph().getAllBlocks()) { for(ControlFlowBlock block : getProgram().getGraph().getAllBlocks()) {
for(Statement statement : block.getStatements()) { for(Statement statement : block.getStatements()) {
stmtBlocks.put(statement.getIndex(), block.getLabel()); stmtBlocks.put(statement.getIndex(), block);
stmtIdx.put(statement.getIndex(), statement); stmtIdx.put(statement.getIndex(), statement);
} }
} }