Mercurial > hg > graal-jvmci-8
changeset 22200:ca38f84b17fc
RedundantMoveElimination: use stack offset as index for stackIndices.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Fri, 10 Jul 2015 15:10:51 +0200 |
parents | 5522e8ffa5f5 |
children | 2537256c7f3d |
files | graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java |
diffstat | 1 files changed, 22 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Fri Jul 10 18:06:37 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Fri Jul 10 15:10:51 2015 +0200 @@ -47,8 +47,8 @@ @Override protected <B extends AbstractBlockBase<B>> void run(TargetDescription target, LIRGenerationResult lirGenRes, List<B> codeEmittingOrder, List<B> linearScanOrder, BenchmarkCounterFactory counterFactory) { - Optimization redundantMoveElimination = new Optimization(); - redundantMoveElimination.doOptimize(lirGenRes.getLIR(), lirGenRes.getFrameMap()); + Optimization redundantMoveElimination = new Optimization(lirGenRes.getFrameMap()); + redundantMoveElimination.doOptimize(lirGenRes.getLIR()); } /** @@ -99,28 +99,34 @@ int[] eligibleRegs; /** - * A map from the {@link StackSlot} to an index into the state. StackSlots of different - * kinds that map to the same location will map to the same index. + * A map from the {@link StackSlot} {@link #getOffset offset} to an index into the state. + * StackSlots of different kinds that map to the same location will map to the same index. */ - Map<StackSlot, Integer> stackIndices = CollectionsFactory.newMap(); + Map<Integer, Integer> stackIndices = CollectionsFactory.newMap(); int numRegs; + private final FrameMap frameMap; + /* * Pseudo value for a not yet assigned location. */ static final int INIT_VALUE = 0; + public Optimization(FrameMap frameMap) { + this.frameMap = frameMap; + } + /** * The main method doing the elimination of redundant moves. */ - private void doOptimize(LIR lir, FrameMap frameMap) { + private void doOptimize(LIR lir) { try (Indent indent = Debug.logAndIndent("eliminate redundant moves")) { callerSaveRegs = frameMap.getRegisterConfig().getCallerSaveRegisters(); - initBlockData(lir, frameMap); + initBlockData(lir); // Compute a table of the registers which are eligible for move optimization. // Unallocatable registers should never be optimized. @@ -146,7 +152,7 @@ */ private static final int COMPLEXITY_LIMIT = 30000; - private void initBlockData(LIR lir, FrameMap frameMap) { + private void initBlockData(LIR lir) { List<? extends AbstractBlockBase<?>> blocks = lir.linearScanOrder(); numRegs = 0; @@ -157,7 +163,6 @@ * Search for relevant locations which can be optimized. These are register or stack * slots which occur as destinations of move instructions. */ - Map<Integer, Integer> offsetToIndex = CollectionsFactory.newMap(); for (AbstractBlockBase<?> block : blocks) { List<LIRInstruction> instructions = lir.getLIRforBlock(block); for (LIRInstruction op : instructions) { @@ -170,12 +175,9 @@ } } else if (isStackSlot(dest)) { StackSlot stackSlot = (StackSlot) dest; - if (!stackIndices.containsKey(stackSlot) && offsetToIndex.size() < maxStackLocations) { - Integer offset = stackSlot.getOffset(frameMap.totalFrameSize()); - if (!offsetToIndex.containsKey(offset)) { - offsetToIndex.put(offset, offsetToIndex.size()); - } - stackIndices.put(stackSlot, offsetToIndex.get(offset)); + Integer offset = getOffset(stackSlot); + if (!stackIndices.containsKey(offset) && stackIndices.size() < maxStackLocations) { + stackIndices.put(offset, stackIndices.size()); } } } @@ -193,6 +195,10 @@ } } + private int getOffset(StackSlot stackSlot) { + return stackSlot.getOffset(frameMap.totalFrameSize()); + } + /** * Calculates the entry and exit states for all basic blocks. * @@ -489,7 +495,7 @@ } if (isStackSlot(location)) { StackSlot slot = (StackSlot) location; - Integer index = stackIndices.get(slot); + Integer index = stackIndices.get(getOffset(slot)); if (index != null) { return index.intValue() + numRegs; }