# HG changeset patch # User Thomas Wuerthinger # Date 1424713040 -3600 # Node ID 4d70d150944fdc8ac4b8520916596018f7648158 # Parent 08d94d9f0b0fb6c541f3346ca6030d865db0e731 Remove AbstractBlock interface. diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/alloc/ComputeBlockOrder.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/alloc/ComputeBlockOrder.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/alloc/ComputeBlockOrder.java Mon Feb 23 18:37:20 2015 +0100 @@ -66,7 +66,7 @@ * * @return sorted list of blocks */ - public static > List computeLinearScanOrder(int blockCount, T startBlock) { + public static > List computeLinearScanOrder(int blockCount, T startBlock) { List order = new ArrayList<>(); BitSet visitedBlocks = new BitSet(blockCount); PriorityQueue worklist = initializeWorklist(startBlock, visitedBlocks); @@ -80,7 +80,7 @@ * * @return sorted list of blocks */ - public static > List computeCodeEmittingOrder(int blockCount, T startBlock) { + public static > List computeCodeEmittingOrder(int blockCount, T startBlock) { List order = new ArrayList<>(); BitSet visitedBlocks = new BitSet(blockCount); PriorityQueue worklist = initializeWorklist(startBlock, visitedBlocks); @@ -92,7 +92,7 @@ /** * Iteratively adds paths to the code emission block order. */ - private static > void computeCodeEmittingOrder(List order, PriorityQueue worklist, BitSet visitedBlocks) { + private static > void computeCodeEmittingOrder(List order, PriorityQueue worklist, BitSet visitedBlocks) { while (!worklist.isEmpty()) { T nextImportantPath = worklist.poll(); addPathToCodeEmittingOrder(nextImportantPath, order, worklist, visitedBlocks); @@ -102,7 +102,7 @@ /** * Iteratively adds paths to the linear scan block order. */ - private static > void computeLinearScanOrder(List order, PriorityQueue worklist, BitSet visitedBlocks) { + private static > void computeLinearScanOrder(List order, PriorityQueue worklist, BitSet visitedBlocks) { while (!worklist.isEmpty()) { T nextImportantPath = worklist.poll(); addPathToLinearScanOrder(nextImportantPath, order, worklist, visitedBlocks); @@ -112,7 +112,7 @@ /** * Initializes the priority queue used for the work list of blocks and adds the start block. */ - private static > PriorityQueue initializeWorklist(T startBlock, BitSet visitedBlocks) { + private static > PriorityQueue initializeWorklist(T startBlock, BitSet visitedBlocks) { PriorityQueue result = new PriorityQueue<>(INITIAL_WORKLIST_CAPACITY, new BlockOrderComparator<>()); result.add(startBlock); visitedBlocks.set(startBlock.getId()); @@ -122,7 +122,7 @@ /** * Add a linear path to the linear scan order greedily following the most likely successor. */ - private static > void addPathToLinearScanOrder(T block, List order, PriorityQueue worklist, BitSet visitedBlocks) { + private static > void addPathToLinearScanOrder(T block, List order, PriorityQueue worklist, BitSet visitedBlocks) { block.setLinearScanNumber(order.size()); order.add(block); T mostLikelySuccessor = findAndMarkMostLikelySuccessor(block, visitedBlocks); @@ -151,7 +151,7 @@ /** * Add a linear path to the code emission order greedily following the most likely successor. */ - private static > void addPathToCodeEmittingOrder(T initialBlock, List order, PriorityQueue worklist, BitSet visitedBlocks) { + private static > void addPathToCodeEmittingOrder(T initialBlock, List order, PriorityQueue worklist, BitSet visitedBlocks) { T block = initialBlock; while (block != null) { // Skip loop headers if there is only a single loop end block to @@ -191,7 +191,7 @@ /** * Adds a block to the ordering. */ - private static > void addBlock(T header, List order) { + private static > void addBlock(T header, List order) { assert !order.contains(header) : "Cannot insert block twice"; order.add(header); } @@ -199,7 +199,7 @@ /** * Find the highest likely unvisited successor block of a given block. */ - private static > T findAndMarkMostLikelySuccessor(T block, BitSet visitedBlocks) { + private static > T findAndMarkMostLikelySuccessor(T block, BitSet visitedBlocks) { T result = null; for (T successor : block.getSuccessors()) { assert successor.probability() >= 0.0 : "Probabilities must be positive"; @@ -216,7 +216,7 @@ /** * Add successor blocks into the given work list if they are not already marked as visited. */ - private static > void enqueueSuccessors(T block, PriorityQueue worklist, BitSet visitedBlocks) { + private static > void enqueueSuccessors(T block, PriorityQueue worklist, BitSet visitedBlocks) { for (T successor : block.getSuccessors()) { if (!visitedBlocks.get(successor.getId())) { visitedBlocks.set(successor.getId()); @@ -229,14 +229,14 @@ * Skip the loop header block if the loop consists of more than one block and it has only a * single loop end block. */ - private static > boolean skipLoopHeader(AbstractBlock block) { + private static > boolean skipLoopHeader(AbstractBlockBase block) { return (block.isLoopHeader() && !block.isLoopEnd() && block.getLoop().numBackedges() == 1); } /** * Checks that the ordering contains the expected number of blocks. */ - private static boolean checkOrder(List> order, int expectedBlockCount) { + private static boolean checkOrder(List> order, int expectedBlockCount) { assert order.size() == expectedBlockCount : String.format("Number of blocks in ordering (%d) does not match expected block count (%d)", order.size(), expectedBlockCount); return true; } @@ -244,7 +244,7 @@ /** * Comparator for sorting blocks based on loop depth and probability. */ - private static class BlockOrderComparator> implements Comparator { + private static class BlockOrderComparator> implements Comparator { @Override public int compare(T a, T b) { diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/AbstractBlock.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/AbstractBlock.java Mon Feb 23 18:03:32 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.compiler.common.cfg; - -import java.util.*; - -public interface AbstractBlock> { - - int getId(); - - Loop getLoop(); - - void setLoop(Loop loop); - - int getLoopDepth(); - - boolean isLoopHeader(); - - boolean isLoopEnd(); - - boolean isExceptionEntry(); - - List getPredecessors(); - - int getPredecessorCount(); - - List getSuccessors(); - - int getSuccessorCount(); - - int getLinearScanNumber(); - - void setLinearScanNumber(int linearScanNumber); - - boolean isAligned(); - - void setAlign(boolean align); - - T getDominator(); - - void setDominator(T block); - - List getDominated(); - - void setDominated(List blocks); - - T getPostdominator(); - - double probability(); - -} diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/AbstractBlockBase.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/AbstractBlockBase.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/AbstractBlockBase.java Mon Feb 23 18:37:20 2015 +0100 @@ -24,7 +24,7 @@ import java.util.*; -public abstract class AbstractBlockBase> implements AbstractBlock { +public abstract class AbstractBlockBase> { protected int id; @@ -113,4 +113,18 @@ public void setAlign(boolean align) { this.align = align; } + + public abstract boolean isExceptionEntry(); + + public abstract Loop getLoop(); + + public abstract int getLoopDepth(); + + public abstract boolean isLoopEnd(); + + public abstract boolean isLoopHeader(); + + public abstract T getPostdominator(); + + public abstract double probability(); } diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/AbstractControlFlowGraph.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/AbstractControlFlowGraph.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/AbstractControlFlowGraph.java Mon Feb 23 18:37:20 2015 +0100 @@ -26,7 +26,7 @@ import com.oracle.graal.compiler.common.*; -public interface AbstractControlFlowGraph> { +public interface AbstractControlFlowGraph> { int BLOCK_ID_INITIAL = -1; int BLOCK_ID_VISITED = -2; @@ -48,7 +48,7 @@ /** * Computes the dominators of control flow graph. */ - static > void computeDominators(AbstractControlFlowGraph cfg) { + static > void computeDominators(AbstractControlFlowGraph cfg) { List reversePostOrder = cfg.getBlocks(); assert reversePostOrder.get(0).getPredecessorCount() == 0 : "start block has no predecessor and therefore no dominator"; for (int i = 1; i < reversePostOrder.size(); i++) { @@ -72,9 +72,9 @@ /** * True if block {@code a} is dominated by block {@code b}. */ - static boolean isDominatedBy(AbstractBlock a, AbstractBlock b) { + static boolean isDominatedBy(AbstractBlockBase a, AbstractBlockBase b) { assert a != null; - AbstractBlock dominator = a; + AbstractBlockBase dominator = a; int i = 0; while (dominator != null) { if (i++ == Integer.MAX_VALUE) { // For safety @@ -91,7 +91,7 @@ /** * True if block {@code a} dominates block {@code b}. */ - static boolean dominates(AbstractBlock a, AbstractBlock b) { + static boolean dominates(AbstractBlockBase a, AbstractBlockBase b) { assert a != null; return isDominatedBy(b, a); } @@ -104,15 +104,15 @@ * @see #getBlocks() * @see CFGVerifier */ - static AbstractBlock commonDominator(AbstractBlock a, AbstractBlock b) { + static AbstractBlockBase commonDominator(AbstractBlockBase a, AbstractBlockBase b) { if (a == null) { return b; } if (b == null) { return a; } - AbstractBlock iterA = a; - AbstractBlock iterB = b; + AbstractBlockBase iterA = a; + AbstractBlockBase iterB = b; while (iterA != iterB) { if (iterA.getId() > iterB.getId()) { iterA = iterA.getDominator(); @@ -125,10 +125,10 @@ } /** - * @see AbstractControlFlowGraph#commonDominator(AbstractBlock, AbstractBlock) + * @see AbstractControlFlowGraph#commonDominator(AbstractBlockBase, AbstractBlockBase) */ @SuppressWarnings("unchecked") - static > T commonDominatorTyped(T a, T b) { + static > T commonDominatorTyped(T a, T b) { return (T) commonDominator(a, b); } } diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/BlockMap.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/BlockMap.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/BlockMap.java Mon Feb 23 18:37:20 2015 +0100 @@ -31,11 +31,11 @@ data = (T[]) new Object[cfg.getBlocks().size()]; } - public T get(AbstractBlock block) { + public T get(AbstractBlockBase block) { return data[block.getId()]; } - public void put(AbstractBlock block, T value) { + public void put(AbstractBlockBase block, T value) { data[block.getId()] = value; } } diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/CFGVerifier.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/CFGVerifier.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/CFGVerifier.java Mon Feb 23 18:37:20 2015 +0100 @@ -26,7 +26,7 @@ public class CFGVerifier { - public static , C extends AbstractControlFlowGraph> boolean verify(C cfg) { + public static , C extends AbstractControlFlowGraph> boolean verify(C cfg) { for (T block : cfg.getBlocks()) { assert block.getId() >= 0; assert cfg.getBlocks().get(block.getId()) == block; diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/DominatorOptimizationProblem.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/DominatorOptimizationProblem.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/DominatorOptimizationProblem.java Mon Feb 23 18:37:20 2015 +0100 @@ -36,7 +36,7 @@ */ public abstract class DominatorOptimizationProblem, C> { - private List> blocks; + private List> blocks; private EnumMap flags; private BlockMap costs; @@ -47,9 +47,9 @@ assert verify(blocks); } - private static boolean verify(List> blocks) { + private static boolean verify(List> blocks) { for (int i = 0; i < blocks.size(); i++) { - AbstractBlock block = blocks.get(i); + AbstractBlockBase block = blocks.get(i); if (i != block.getId()) { assert false : String.format("Id index mismatch @ %d vs. %s.getId()==%d", i, block, block.getId()); return false; @@ -58,12 +58,12 @@ return true; } - public final List> getBlocks() { + public final List> getBlocks() { return blocks; } - public final AbstractBlock getBlockForId(int id) { - AbstractBlock block = blocks.get(id); + public final AbstractBlockBase getBlockForId(int id) { + AbstractBlockBase block = blocks.get(id); assert block.getId() == id : "wrong block-to-id mapping"; return block; } @@ -71,7 +71,7 @@ /** * Sets a flag for a block. */ - public final void set(E flag, AbstractBlock block) { + public final void set(E flag, AbstractBlockBase block) { BitSet bitSet = flags.get(flag); if (bitSet == null) { bitSet = new BitSet(blocks.size()); @@ -83,7 +83,7 @@ /** * Checks whether a flag is set for a block. */ - public final boolean get(E flag, AbstractBlock block) { + public final boolean get(E flag, AbstractBlockBase block) { BitSet bitSet = flags.get(flag); return bitSet == null ? false : bitSet.get(block.getId()); } @@ -91,14 +91,14 @@ /** * Returns a {@linkplain Stream} of blocks for which {@code flag} is set. */ - public final Stream> stream(E flag) { + public final Stream> stream(E flag) { return getBlocks().stream().filter(block -> get(flag, block)); } /** * Returns the cost object associated with {@code block}. Might return {@code null} if not set. */ - public final C getCost(AbstractBlock block) { + public final C getCost(AbstractBlockBase block) { C cost = costs.get(block); return cost; } @@ -106,7 +106,7 @@ /** * Sets the cost for a {@code block}. */ - public final void setCost(AbstractBlock block, C cost) { + public final void setCost(AbstractBlockBase block, C cost) { costs.put(block, cost); } @@ -114,13 +114,13 @@ * Sets {@code flag} for all blocks along the dominator path from {@code block} to the root * until a block it finds a block where {@code flag} is already set. */ - public final void setDominatorPath(E flag, AbstractBlock block) { + public final void setDominatorPath(E flag, AbstractBlockBase block) { BitSet bitSet = flags.get(flag); if (bitSet == null) { bitSet = new BitSet(blocks.size()); flags.put(flag, bitSet); } - for (AbstractBlock b = block; b != null && !bitSet.get(b.getId()); b = b.getDominator()) { + for (AbstractBlockBase b = block; b != null && !bitSet.get(b.getId()); b = b.getDominator()) { // mark block bitSet.set(b.getId()); } @@ -129,7 +129,7 @@ /** * Returns a {@link Stream} of flags associated with {@code block}. */ - public final Stream getFlagsForBlock(AbstractBlock block) { + public final Stream getFlagsForBlock(AbstractBlockBase block) { return getFlags().stream().filter(flag -> get(flag, block)); } diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/Loop.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/Loop.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/Loop.java Mon Feb 23 18:37:20 2015 +0100 @@ -25,7 +25,7 @@ import java.util.*; -public abstract class Loop> { +public abstract class Loop> { private final Loop parent; private final List> children; diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/PrintableCFG.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/PrintableCFG.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/PrintableCFG.java Mon Feb 23 18:37:20 2015 +0100 @@ -31,7 +31,7 @@ */ public interface PrintableCFG { - List> getBlocks(); + List> getBlocks(); /** * Applies {@code action} to all extra property pairs (name, value) of {@code block}. @@ -39,7 +39,7 @@ * @param block a block from {@link #getBlocks()}. * @param action a {@link BiConsumer consumer}. */ - default void forEachPropertyPair(AbstractBlock block, BiConsumer action) { + default void forEachPropertyPair(AbstractBlockBase block, BiConsumer action) { // no extra properties per default } } diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/PrintableDominatorOptimizationProblem.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/PrintableDominatorOptimizationProblem.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/PrintableDominatorOptimizationProblem.java Mon Feb 23 18:37:20 2015 +0100 @@ -33,7 +33,7 @@ super(keyType, cfg); } - public void forEachPropertyPair(AbstractBlock block, BiConsumer action) { + public void forEachPropertyPair(AbstractBlockBase block, BiConsumer action) { // for each flag getFlags().forEach(flag -> ((BiConsumer) (name, value) -> action.accept(name, value ? "true" : "false")).accept(getName(flag), get(flag, block))); // for each property diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java Mon Feb 23 18:37:20 2015 +0100 @@ -64,7 +64,7 @@ public RegisterStats(LIR lir) { this.lir = lir; - for (AbstractBlock block : lir.codeEmittingOrder()) { + for (AbstractBlockBase block : lir.codeEmittingOrder()) { for (LIRInstruction instr : lir.getLIRforBlock(block)) { collectStats(instr); } diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Mon Feb 23 18:37:20 2015 +0100 @@ -350,7 +350,7 @@ } } - public static > LIRGenerationResult emitLowLevel(TargetDescription target, List codeEmittingOrder, List linearScanOrder, LIRGenerationResult lirGenRes, + public static > LIRGenerationResult emitLowLevel(TargetDescription target, List codeEmittingOrder, List linearScanOrder, LIRGenerationResult lirGenRes, LIRGeneratorTool lirGen, LIRSuites lirSuites) { PreAllocationOptimizationContext preAllocOptContext = new PreAllocationOptimizationContext(lirGen); lirSuites.getPreAllocationOptimizationStage().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, preAllocOptContext); diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Mon Feb 23 18:37:20 2015 +0100 @@ -273,7 +273,7 @@ } private static void resetDelayedControlTransfers(LIR lir) { - for (AbstractBlock block : lir.codeEmittingOrder()) { + for (AbstractBlockBase block : lir.codeEmittingOrder()) { for (LIRInstruction inst : lir.getLIRforBlock(block)) { if (inst instanceof SPARCDelayedControlTransfer) { ((SPARCDelayedControlTransfer) inst).resetState(); @@ -285,11 +285,11 @@ /** * Fix-up over whole LIR. * - * @see #stuffDelayedControlTransfers(LIR, AbstractBlock) + * @see #stuffDelayedControlTransfers(LIR, AbstractBlockBase) * @param l */ private static void stuffDelayedControlTransfers(LIR l) { - for (AbstractBlock b : l.codeEmittingOrder()) { + for (AbstractBlockBase b : l.codeEmittingOrder()) { stuffDelayedControlTransfers(l, b); } } @@ -299,7 +299,7 @@ * it tries to move the DelayedLIRInstruction to the DelayedControlTransfer instruction, if * possible. */ - private static void stuffDelayedControlTransfers(LIR l, AbstractBlock block) { + private static void stuffDelayedControlTransfers(LIR l, AbstractBlockBase block) { List instructions = l.getLIRforBlock(block); if (instructions.size() >= 2) { LIRDependencyAccumulator acc = new LIRDependencyAccumulator(); diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java Mon Feb 23 18:37:20 2015 +0100 @@ -172,7 +172,7 @@ } } }; - for (AbstractBlock block : lir.codeEmittingOrder()) { + for (AbstractBlockBase block : lir.codeEmittingOrder()) { for (LIRInstruction op : lir.getLIRforBlock(block)) { if (op instanceof LabelOp) { // Don't consider this as a definition diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ControlFlowOptimizer.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ControlFlowOptimizer.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ControlFlowOptimizer.java Mon Feb 23 18:37:20 2015 +0100 @@ -41,12 +41,12 @@ * Performs control flow optimizations on the given LIR graph. */ @Override - protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { + protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { LIR lir = lirGenRes.getLIR(); new Optimizer(lir).deleteEmptyBlocks(codeEmittingOrder); } - private static final class Optimizer> { + private static final class Optimizer> { private final LIR lir; @@ -97,7 +97,7 @@ if (canDeleteBlock(block)) { // adjust successor and predecessor lists B other = block.getSuccessors().iterator().next(); - for (AbstractBlock pred : block.getPredecessors()) { + for (AbstractBlockBase pred : block.getPredecessors()) { Collections.replaceAll(pred.getSuccessors(), block, other); } for (int i = 0; i < other.getPredecessorCount(); i++) { diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/EdgeMoveOptimizer.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/EdgeMoveOptimizer.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/EdgeMoveOptimizer.java Mon Feb 23 18:37:20 2015 +0100 @@ -51,14 +51,14 @@ public final class EdgeMoveOptimizer extends PostAllocationOptimizationPhase { @Override - protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { + protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { LIR ir = lirGenRes.getLIR(); Optimizer optimizer = new Optimizer(ir); - List> blockList = ir.linearScanOrder(); + List> blockList = ir.linearScanOrder(); // ignore the first block in the list (index 0 is not processed) for (int i = blockList.size() - 1; i >= 1; i--) { - AbstractBlock block = blockList.get(i); + AbstractBlockBase block = blockList.get(i); if (block.getPredecessorCount() > 1) { optimizer.optimizeMovesAtBlockEnd(block); @@ -106,8 +106,8 @@ * Moves the longest {@linkplain #same common} subsequence at the end all predecessors of * {@code block} to the start of {@code block}. */ - private void optimizeMovesAtBlockEnd(AbstractBlock block) { - for (AbstractBlock pred : block.getPredecessors()) { + private void optimizeMovesAtBlockEnd(AbstractBlockBase block) { + for (AbstractBlockBase pred : block.getPredecessors()) { if (pred == block) { // currently we can't handle this correctly. return; @@ -121,7 +121,7 @@ assert numPreds > 1 : "do not call otherwise"; // setup a list with the LIR instructions of all predecessors - for (AbstractBlock pred : block.getPredecessors()) { + for (AbstractBlockBase pred : block.getPredecessors()) { assert pred != null; assert ir.getLIRforBlock(pred) != null; List predInstructions = ir.getLIRforBlock(pred); @@ -176,7 +176,7 @@ * {@code block} to the end of {@code block} just prior to the branch instruction ending * {@code block}. */ - private void optimizeMovesAtBlockBegin(AbstractBlock block) { + private void optimizeMovesAtBlockBegin(AbstractBlockBase block) { edgeInstructionSeqences.clear(); int numSux = block.getSuccessorCount(); @@ -206,7 +206,7 @@ int insertIdx = instructions.size() - 1; // setup a list with the lir-instructions of all successors - for (AbstractBlock sux : block.getSuccessors()) { + for (AbstractBlockBase sux : block.getSuccessors()) { List suxInstructions = ir.getLIRforBlock(sux); assert suxInstructions.get(0) instanceof StandardOp.LabelOp : "block must start with label"; diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Mon Feb 23 18:37:20 2015 +0100 @@ -40,12 +40,12 @@ /** * The linear-scan ordered list of blocks. */ - private final List> linearScanOrder; + private final List> linearScanOrder; /** * The order in which the code is emitted. */ - private final List> codeEmittingOrder; + private final List> codeEmittingOrder; private int firstVariableNumber; @@ -65,7 +65,7 @@ /** * Creates a new LIR instance for the specified compilation. */ - public LIR(AbstractControlFlowGraph cfg, List> linearScanOrder, List> codeEmittingOrder) { + public LIR(AbstractControlFlowGraph cfg, List> linearScanOrder, List> codeEmittingOrder) { this.cfg = cfg; this.codeEmittingOrder = codeEmittingOrder; this.linearScanOrder = linearScanOrder; @@ -80,7 +80,7 @@ * Determines if any instruction in the LIR has debug info associated with it. */ public boolean hasDebugInfo() { - for (AbstractBlock b : linearScanOrder()) { + for (AbstractBlockBase b : linearScanOrder()) { for (LIRInstruction op : getLIRforBlock(b)) { if (op.hasState()) { return true; @@ -94,11 +94,11 @@ return spillMoveFactory; } - public List getLIRforBlock(AbstractBlock block) { + public List getLIRforBlock(AbstractBlockBase block) { return lirInstructions.get(block); } - public void setLIRforBlock(AbstractBlock block, List list) { + public void setLIRforBlock(AbstractBlockBase block, List list) { assert getLIRforBlock(block) == null : "lir instruction list should only be initialized once"; lirInstructions.put(block, list); } @@ -108,11 +108,11 @@ * * @return the blocks in linear scan order */ - public List> linearScanOrder() { + public List> linearScanOrder() { return linearScanOrder; } - public List> codeEmittingOrder() { + public List> codeEmittingOrder() { return codeEmittingOrder; } @@ -166,7 +166,7 @@ */ public static final int MAX_EXCEPTION_EDGE_OP_DISTANCE_FROM_END = 3; - public static boolean verifyBlock(LIR lir, AbstractBlock block) { + public static boolean verifyBlock(LIR lir, AbstractBlockBase block) { List ops = lir.getLIRforBlock(block); if (ops.size() == 0) { return false; @@ -190,12 +190,12 @@ return true; } - public static boolean verifyBlocks(LIR lir, List> blocks) { - for (AbstractBlock block : blocks) { - for (AbstractBlock sux : block.getSuccessors()) { + public static boolean verifyBlocks(LIR lir, List> blocks) { + for (AbstractBlockBase block : blocks) { + for (AbstractBlockBase sux : block.getSuccessors()) { assert blocks.contains(sux) : "missing successor from: " + block + "to: " + sux; } - for (AbstractBlock pred : block.getPredecessors()) { + for (AbstractBlockBase pred : block.getPredecessors()) { assert blocks.contains(pred) : "missing predecessor from: " + block + "to: " + pred; } if (!verifyBlock(lir, block)) { @@ -211,7 +211,7 @@ public void resetLabels() { - for (AbstractBlock block : codeEmittingOrder()) { + for (AbstractBlockBase block : codeEmittingOrder()) { for (LIRInstruction inst : lirInstructions.get(block)) { if (inst instanceof LabelOp) { ((LabelOp) inst).getLabel().reset(); diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java Mon Feb 23 18:37:20 2015 +0100 @@ -46,11 +46,11 @@ private final BitSet[] blockLiveOut; private final Object[] variableDefinitions; - private BitSet liveOutFor(AbstractBlock block) { + private BitSet liveOutFor(AbstractBlockBase block) { return blockLiveOut[block.getId()]; } - private void setLiveOutFor(AbstractBlock block, BitSet liveOut) { + private void setLiveOutFor(AbstractBlockBase block, BitSet liveOut) { blockLiveOut[block.getId()] = liveOut; } @@ -91,7 +91,7 @@ private BitSet curVariablesLive; private Value[] curRegistersLive; - private AbstractBlock curBlock; + private AbstractBlockBase curBlock; private Object curInstruction; private BitSet curRegistersDefined; @@ -113,7 +113,7 @@ int maxRegisterNum = maxRegisterNum(); curRegistersDefined = new BitSet(); - for (AbstractBlock block : lir.linearScanOrder()) { + for (AbstractBlockBase block : lir.linearScanOrder()) { curBlock = block; curVariablesLive = new BitSet(); curRegistersLive = new Value[maxRegisterNum]; diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LabelRef.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LabelRef.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LabelRef.java Mon Feb 23 18:37:20 2015 +0100 @@ -29,7 +29,7 @@ /** * LIR instructions such as {@link JumpOp} and {@link BranchOp} need to reference their target - * {@link AbstractBlock}. However, direct references are not possible since the control flow graph + * {@link AbstractBlockBase}. However, direct references are not possible since the control flow graph * (and therefore successors lists) can be changed by optimizations - and fixing the instructions is * error prone. Therefore, we represent an edge to block B from block A via the tuple {@code (A, * successor-index-of-B)}. That is, indirectly by storing the index into the successor list of A. @@ -38,7 +38,7 @@ public final class LabelRef { private final LIR lir; - private final AbstractBlock block; + private final AbstractBlockBase block; private final int suxIndex; /** @@ -48,7 +48,7 @@ * @param suxIndex The index of the successor. * @return The newly created label reference. */ - public static LabelRef forSuccessor(final LIR lir, final AbstractBlock block, final int suxIndex) { + public static LabelRef forSuccessor(final LIR lir, final AbstractBlockBase block, final int suxIndex) { return new LabelRef(lir, block, suxIndex); } @@ -58,17 +58,17 @@ * @param block The base block that contains the successor list. * @param suxIndex The index of the successor. */ - private LabelRef(final LIR lir, final AbstractBlock block, final int suxIndex) { + private LabelRef(final LIR lir, final AbstractBlockBase block, final int suxIndex) { this.lir = lir; this.block = block; this.suxIndex = suxIndex; } - public AbstractBlock getSourceBlock() { + public AbstractBlockBase getSourceBlock() { return block; } - public AbstractBlock getTargetBlock() { + public AbstractBlockBase getTargetBlock() { return block.getSuccessors().get(suxIndex); } diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/NullCheckOptimizer.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/NullCheckOptimizer.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/NullCheckOptimizer.java Mon Feb 23 18:37:20 2015 +0100 @@ -34,14 +34,14 @@ public final class NullCheckOptimizer extends PostAllocationOptimizationPhase { @Override - protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { + protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { LIR ir = lirGenRes.getLIR(); - List> blocks = ir.codeEmittingOrder(); + List> blocks = ir.codeEmittingOrder(); NullCheckOptimizer.foldNullChecks(ir, blocks, target.implicitNullCheckLimit); } - private static void foldNullChecks(LIR ir, List> blocks, int implicitNullCheckLimit) { - for (AbstractBlock block : blocks) { + private static void foldNullChecks(LIR ir, List> blocks, int implicitNullCheckLimit) { + for (AbstractBlockBase block : blocks) { List list = ir.getLIRforBlock(block); if (!list.isEmpty()) { diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Mon Feb 23 18:37:20 2015 +0100 @@ -44,7 +44,7 @@ public final class RedundantMoveElimination extends PostAllocationOptimizationPhase { @Override - protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { + protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { Optimization redundantMoveElimination = new Optimization(); redundantMoveElimination.doOptimize(lirGenRes.getLIR(), lirGenRes.getFrameMap()); } @@ -87,7 +87,7 @@ private static final class Optimization { - Map, BlockData> blockData = CollectionsFactory.newMap(); + Map, BlockData> blockData = CollectionsFactory.newMap(); Register[] callerSaveRegs; @@ -142,7 +142,7 @@ private void initBlockData(LIR lir) { - List> blocks = lir.linearScanOrder(); + List> blocks = lir.linearScanOrder(); numRegs = 0; int maxStackLocations = COMPLEXITY_LIMIT / blocks.size(); @@ -151,7 +151,7 @@ * Search for relevant locations which can be optimized. These are register or stack * slots which occur as destinations of move instructions. */ - for (AbstractBlock block : blocks) { + for (AbstractBlockBase block : blocks) { List instructions = lir.getLIRforBlock(block); for (LIRInstruction op : instructions) { if (isEligibleMove(op)) { @@ -176,7 +176,7 @@ */ int numLocations = numRegs + stackIndices.size(); Debug.log("num locations = %d (regs = %d, stack = %d)", numLocations, numRegs, stackIndices.size()); - for (AbstractBlock block : blocks) { + for (AbstractBlockBase block : blocks) { BlockData data = new BlockData(numLocations); blockData.put(block, data); } @@ -191,7 +191,7 @@ try (Indent indent = Debug.logAndIndent("solve data flow")) { - List> blocks = lir.linearScanOrder(); + List> blocks = lir.linearScanOrder(); int numIter = 0; @@ -205,7 +205,7 @@ changed = false; try (Indent indent2 = Debug.logAndIndent("new iteration")) { - for (AbstractBlock block : blocks) { + for (AbstractBlockBase block : blocks) { BlockData data = blockData.get(block); /* @@ -235,7 +235,7 @@ /* * Merge the states of predecessor blocks */ - for (AbstractBlock predecessor : block.getPredecessors()) { + for (AbstractBlockBase predecessor : block.getPredecessors()) { BlockData predData = blockData.get(predecessor); newState |= mergeState(data.entryState, predData.exitState, valueNum); } @@ -291,9 +291,9 @@ try (Indent indent = Debug.logAndIndent("eliminate moves")) { - List> blocks = lir.linearScanOrder(); + List> blocks = lir.linearScanOrder(); - for (AbstractBlock block : blocks) { + for (AbstractBlockBase block : blocks) { try (Indent indent2 = Debug.logAndIndent("eliminate moves in block %d", block.getId())) { diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Mon Feb 23 18:37:20 2015 +0100 @@ -192,14 +192,14 @@ /** * The block in which this instruction is located. */ - final AbstractBlock block; + final AbstractBlockBase block; /** * The block index of this instruction. */ final int index; - public NoOp(AbstractBlock block, int index) { + public NoOp(AbstractBlockBase block, int index) { super(TYPE); this.block = block; this.index = index; diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java Mon Feb 23 18:37:20 2015 +0100 @@ -114,7 +114,7 @@ /** * List of blocks in linear-scan order. This is only correct as long as the CFG does not change. */ - final List> sortedBlocks; + final List> sortedBlocks; /** * Map from {@linkplain #operandNumber(Value) operand numbers} to intervals. @@ -145,11 +145,11 @@ LIRInstruction[] opIdToInstructionMap; /** - * Map from an instruction {@linkplain LIRInstruction#id id} to the {@linkplain AbstractBlock + * Map from an instruction {@linkplain LIRInstruction#id id} to the {@linkplain AbstractBlockBase * block} containing the instruction. Entries should be retrieved with {@link #blockForId(int)} * as the id is not simply an index into this array. */ - AbstractBlock[] opIdToBlockMap; + AbstractBlockBase[] opIdToBlockMap; /** * Bit set for each variable that is contained in each loop. @@ -178,13 +178,13 @@ this.callKillsRegisters = this.frameMapBuilder.getRegisterConfig().areAllAllocatableRegistersCallerSaved(); } - int getFirstLirInstructionId(AbstractBlock block) { + int getFirstLirInstructionId(AbstractBlockBase block) { int result = ir.getLIRforBlock(block).get(0).id(); assert result >= 0; return result; } - int getLastLirInstructionId(AbstractBlock block) { + int getLastLirInstructionId(AbstractBlockBase block) { List instructions = ir.getLIRforBlock(block); int result = instructions.get(instructions.size() - 1).id(); assert result >= 0; @@ -312,7 +312,7 @@ return sortedBlocks.size(); } - AbstractBlock blockAt(int index) { + AbstractBlockBase blockAt(int index) { return sortedBlocks.get(index); } @@ -388,7 +388,7 @@ * @param opId an instruction {@linkplain LIRInstruction#id id} * @return the block containing the instruction denoted by {@code opId} */ - AbstractBlock blockForId(int opId) { + AbstractBlockBase blockForId(int opId) { assert opIdToBlockMap.length > 0 && opId >= 0 && opId <= maxOpId() + 1 : "opId out of range"; return opIdToBlockMap[opIdToIndex(opId)]; } @@ -522,7 +522,7 @@ } LIRInsertionBuffer insertionBuffer = new LIRInsertionBuffer(); - for (AbstractBlock block : sortedBlocks) { + for (AbstractBlockBase block : sortedBlocks) { List instructions = ir.getLIRforBlock(block); int numInst = instructions.size(); @@ -627,17 +627,17 @@ // Assign IDs to LIR nodes and build a mapping, lirOps, from ID to LIRInstruction node. int numInstructions = 0; - for (AbstractBlock block : sortedBlocks) { + for (AbstractBlockBase block : sortedBlocks) { numInstructions += ir.getLIRforBlock(block).size(); } // initialize with correct length opIdToInstructionMap = new LIRInstruction[numInstructions]; - opIdToBlockMap = new AbstractBlock[numInstructions]; + opIdToBlockMap = new AbstractBlockBase[numInstructions]; int opId = 0; int index = 0; - for (AbstractBlock block : sortedBlocks) { + for (AbstractBlockBase block : sortedBlocks) { blockData.put(block, new BlockData()); List instructions = ir.getLIRforBlock(block); @@ -672,7 +672,7 @@ intervalInLoop = new BitMap2D(operandSize(), numLoops()); // iterate all blocks - for (final AbstractBlock block : sortedBlocks) { + for (final AbstractBlockBase block : sortedBlocks) { try (Indent indent = Debug.logAndIndent("compute local live sets for block %d", block.getId())) { final BitSet liveGen = new BitSet(liveSize); @@ -763,7 +763,7 @@ } } - private void verifyInput(AbstractBlock block, BitSet liveKill, Value operand) { + private void verifyInput(AbstractBlockBase block, BitSet liveKill, Value operand) { // fixed intervals are never live at block boundaries, so // they need not be processed in live sets. // this is checked by these assertions to be sure about it. @@ -797,7 +797,7 @@ // iterate all blocks in reverse order for (int i = numBlocks - 1; i >= 0; i--) { - AbstractBlock block = blockAt(i); + AbstractBlockBase block = blockAt(i); BlockData blockSets = blockData.get(block); changeOccurredInBlock = false; @@ -808,7 +808,7 @@ liveOut.clear(); // block has successors if (n > 0) { - for (AbstractBlock successor : block.getSuccessors()) { + for (AbstractBlockBase successor : block.getSuccessors()) { liveOut.or(blockData.get(successor).liveIn); } } @@ -852,7 +852,7 @@ } // check that the liveIn set of the first block is empty - AbstractBlock startBlock = ir.getControlFlowGraph().getStartBlock(); + AbstractBlockBase startBlock = ir.getControlFlowGraph().getStartBlock(); if (blockData.get(startBlock).liveIn.cardinality() != 0) { if (DetailedAsserts.getValue()) { reportFailure(numBlocks); @@ -891,9 +891,9 @@ } try (Indent indent2 = Debug.logAndIndent("---- Detailed information for var %d; operand=%s; node=%s ----", operandNum, operand, valueForOperandFromDebugContext)) { - Deque> definedIn = new ArrayDeque<>(); - HashSet> usedIn = new HashSet<>(); - for (AbstractBlock block : sortedBlocks) { + Deque> definedIn = new ArrayDeque<>(); + HashSet> usedIn = new HashSet<>(); + for (AbstractBlockBase block : sortedBlocks) { if (blockData.get(block).liveGen.get(operandNum)) { usedIn.add(block); try (Indent indent3 = Debug.logAndIndent("used in block B%d", block.getId())) { @@ -920,9 +920,9 @@ int[] hitCount = new int[numBlocks]; while (!definedIn.isEmpty()) { - AbstractBlock block = definedIn.removeFirst(); + AbstractBlockBase block = definedIn.removeFirst(); usedIn.remove(block); - for (AbstractBlock successor : block.getSuccessors()) { + for (AbstractBlockBase successor : block.getSuccessors()) { if (successor.isLoopHeader()) { if (!block.isLoopEnd()) { definedIn.add(successor); @@ -935,7 +935,7 @@ } } try (Indent indent3 = Debug.logAndIndent("**** offending usages are in: ")) { - for (AbstractBlock block : usedIn) { + for (AbstractBlockBase block : usedIn) { Debug.log("B%d", block.getId()); } } @@ -950,7 +950,7 @@ private void verifyLiveness() { // check that fixed intervals are not live at block boundaries // (live set must be empty at fixed intervals) - for (AbstractBlock block : sortedBlocks) { + for (AbstractBlockBase block : sortedBlocks) { for (int j = 0; j <= maxRegisterNumber(); j++) { assert !blockData.get(block).liveIn.get(j) : "liveIn set of fixed register must be empty"; assert !blockData.get(block).liveOut.get(j) : "liveOut set of fixed register must be empty"; @@ -1167,7 +1167,7 @@ // iterate all blocks in reverse order for (int i = blockCount() - 1; i >= 0; i--) { - AbstractBlock block = blockAt(i); + AbstractBlockBase block = blockAt(i); try (Indent indent2 = Debug.logAndIndent("handle block %d", block.getId())) { List instructions = ir.getLIRforBlock(block); @@ -1411,15 +1411,15 @@ throw new BailoutException("LinearScan: interval is null"); } - Interval intervalAtBlockBegin(AbstractBlock block, int operandNumber) { + Interval intervalAtBlockBegin(AbstractBlockBase block, int operandNumber) { return splitChildAtOpId(intervalFor(operandNumber), getFirstLirInstructionId(block), LIRInstruction.OperandMode.DEF); } - Interval intervalAtBlockEnd(AbstractBlock block, int operandNumber) { + Interval intervalAtBlockEnd(AbstractBlockBase block, int operandNumber) { return splitChildAtOpId(intervalFor(operandNumber), getLastLirInstructionId(block) + 1, LIRInstruction.OperandMode.DEF); } - void resolveCollectMappings(AbstractBlock fromBlock, AbstractBlock toBlock, MoveResolver moveResolver) { + void resolveCollectMappings(AbstractBlockBase fromBlock, AbstractBlockBase toBlock, MoveResolver moveResolver) { assert moveResolver.checkEmpty(); int numOperands = operandSize(); @@ -1440,7 +1440,7 @@ } } - void resolveFindInsertPos(AbstractBlock fromBlock, AbstractBlock toBlock, MoveResolver moveResolver) { + void resolveFindInsertPos(AbstractBlockBase fromBlock, AbstractBlockBase toBlock, MoveResolver moveResolver) { if (fromBlock.getSuccessorCount() <= 1) { Debug.log("inserting moves at end of fromBlock B%d", fromBlock.getId()); @@ -1463,7 +1463,7 @@ // successor edges, blocks which are reached by switch statements // may have be more than one predecessor but it will be guaranteed // that all predecessors will be the same. - for (AbstractBlock predecessor : toBlock.getPredecessors()) { + for (AbstractBlockBase predecessor : toBlock.getPredecessors()) { assert fromBlock == predecessor : "all critical edges must be broken"; } } @@ -1484,7 +1484,7 @@ BitSet blockCompleted = new BitSet(numBlocks); BitSet alreadyResolved = new BitSet(numBlocks); - for (AbstractBlock block : sortedBlocks) { + for (AbstractBlockBase block : sortedBlocks) { // check if block has only one predecessor and only one successor if (block.getPredecessorCount() == 1 && block.getSuccessorCount() == 1) { @@ -1494,8 +1494,8 @@ // check if block is empty (only label and branch) if (instructions.size() == 2) { - AbstractBlock pred = block.getPredecessors().iterator().next(); - AbstractBlock sux = block.getSuccessors().iterator().next(); + AbstractBlockBase pred = block.getPredecessors().iterator().next(); + AbstractBlockBase sux = block.getSuccessors().iterator().next(); // prevent optimization of two consecutive blocks if (!blockCompleted.get(pred.getLinearScanNumber()) && !blockCompleted.get(sux.getLinearScanNumber())) { @@ -1516,12 +1516,12 @@ } } - for (AbstractBlock fromBlock : sortedBlocks) { + for (AbstractBlockBase fromBlock : sortedBlocks) { if (!blockCompleted.get(fromBlock.getLinearScanNumber())) { alreadyResolved.clear(); alreadyResolved.or(blockCompleted); - for (AbstractBlock toBlock : fromBlock.getSuccessors()) { + for (AbstractBlockBase toBlock : fromBlock.getSuccessors()) { // check for duplicate edges between the same blocks (can happen with switch // blocks) @@ -1566,7 +1566,7 @@ if (opId != -1) { if (DetailedAsserts.getValue()) { - AbstractBlock block = blockForId(opId); + AbstractBlockBase block = blockForId(opId); if (block.getSuccessorCount() <= 1 && opId == getLastLirInstructionId(block)) { // check if spill moves could have been appended at the end of this block, but // before the branch instruction. So the split child information for this branch @@ -1639,7 +1639,7 @@ } int tempOpId = op.id(); OperandMode mode = OperandMode.USE; - AbstractBlock block = blockForId(tempOpId); + AbstractBlockBase block = blockForId(tempOpId); if (block.getSuccessorCount() == 1 && tempOpId == getLastLirInstructionId(block)) { // generating debug information for the last instruction of a block. // if this instruction is a branch, spill moves are inserted before this branch @@ -1723,7 +1723,7 @@ private void assignLocations() { try (Indent indent = Debug.logAndIndent("assign locations")) { - for (AbstractBlock block : sortedBlocks) { + for (AbstractBlockBase block : sortedBlocks) { try (Indent indent2 = Debug.logAndIndent("assign locations in block B%d", block.getId())) { assignLocations(ir.getLIRforBlock(block)); } @@ -1811,8 +1811,8 @@ LIRInsertionBuffer[] insertionBuffers = new LIRInsertionBuffer[ir.linearScanOrder().size()]; for (Interval interval : intervals) { if (interval != null && interval.isSplitParent() && interval.spillState() == SpillState.SpillInDominator) { - AbstractBlock defBlock = blockForId(interval.spillDefinitionPos()); - AbstractBlock spillBlock = null; + AbstractBlockBase defBlock = blockForId(interval.spillDefinitionPos()); + AbstractBlockBase spillBlock = null; Interval firstSpillChild = null; try (Indent indent = Debug.logAndIndent("interval %s (%s)", interval, defBlock)) { for (Interval splitChild : interval.getSplitChildren()) { @@ -1823,7 +1823,7 @@ assert firstSpillChild.from() < splitChild.from(); } // iterate all blocks where the interval has use positions - for (AbstractBlock splitBlock : blocksForInterval(splitChild)) { + for (AbstractBlockBase splitBlock : blocksForInterval(splitChild)) { if (dominates(defBlock, splitBlock)) { Debug.log("Split interval %s, block %s", splitChild, splitBlock); if (spillBlock == null) { @@ -1851,7 +1851,7 @@ */ assert firstSpillChild != null; if (!defBlock.equals(spillBlock) && spillBlock.equals(blockForId(firstSpillChild.from()))) { - AbstractBlock dom = spillBlock.getDominator(); + AbstractBlockBase dom = spillBlock.getDominator(); Debug.log("Spill block (%s) is the beginning of a spill child -> use dominator (%s)", spillBlock, dom); spillBlock = dom; } @@ -1903,20 +1903,20 @@ } /** - * Iterate over all {@link AbstractBlock blocks} of an interval. + * Iterate over all {@link AbstractBlockBase blocks} of an interval. */ - private class IntervalBlockIterator implements Iterator> { + private class IntervalBlockIterator implements Iterator> { Range range; - AbstractBlock block; + AbstractBlockBase block; public IntervalBlockIterator(Interval interval) { range = interval.first(); block = blockForId(range.from); } - public AbstractBlock next() { - AbstractBlock currentBlock = block; + public AbstractBlockBase next() { + AbstractBlockBase currentBlock = block; int nextBlockIndex = block.getLinearScanNumber() + 1; if (nextBlockIndex < sortedBlocks.size()) { block = sortedBlocks.get(nextBlockIndex); @@ -1939,17 +1939,17 @@ } } - private Iterable> blocksForInterval(Interval interval) { - return new Iterable>() { - public Iterator> iterator() { + private Iterable> blocksForInterval(Interval interval) { + return new Iterable>() { + public Iterator> iterator() { return new IntervalBlockIterator(interval); } }; } - private static AbstractBlock moveSpillOutOfLoop(AbstractBlock defBlock, AbstractBlock spillBlock) { + private static AbstractBlockBase moveSpillOutOfLoop(AbstractBlockBase defBlock, AbstractBlockBase spillBlock) { int defLoopDepth = defBlock.getLoopDepth(); - for (AbstractBlock block = spillBlock.getDominator(); !defBlock.equals(block); block = block.getDominator()) { + for (AbstractBlockBase block = spillBlock.getDominator(); !defBlock.equals(block); block = block.getDominator()) { assert block != null : "spill block not dominated by definition block?"; if (block.getLoopDepth() <= defLoopDepth) { assert block.getLoopDepth() == defLoopDepth : "Cannot spill an interval outside of the loop where it is defined!"; @@ -1970,7 +1970,7 @@ try (Indent indent2 = Debug.logAndIndent("Basic Blocks")) { for (int i = 0; i < blockCount(); i++) { - AbstractBlock block = blockAt(i); + AbstractBlockBase block = blockAt(i); Debug.log("B%d [%d, %d, %s] ", block.getId(), getFirstLirInstructionId(block), getLastLirInstructionId(block), block.getLoop()); } } @@ -2103,7 +2103,7 @@ otherIntervals.addRange(Integer.MAX_VALUE - 2, Integer.MAX_VALUE - 1); IntervalWalker iw = new IntervalWalker(this, fixedIntervals, otherIntervals); - for (AbstractBlock block : sortedBlocks) { + for (AbstractBlockBase block : sortedBlocks) { List instructions = ir.getLIRforBlock(block); for (int j = 0; j < instructions.size(); j++) { diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanPhase.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanPhase.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanPhase.java Mon Feb 23 18:37:20 2015 +0100 @@ -32,7 +32,7 @@ public final class LinearScanPhase extends AllocationPhase { @Override - protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { + protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { new LinearScan(target, lirGenRes).allocate(); } diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanWalker.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanWalker.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanWalker.java Mon Feb 23 18:37:20 2015 +0100 @@ -63,11 +63,11 @@ return allocator.blockCount(); } - AbstractBlock blockAt(int idx) { + AbstractBlockBase blockAt(int idx) { return allocator.blockAt(idx); } - AbstractBlock blockOfOpWithId(int opId) { + AbstractBlockBase blockOfOpWithId(int opId) { return allocator.blockForId(opId); } @@ -239,7 +239,7 @@ // optimized away later in assignRegNums int opId = (operandId + 1) & ~1; - AbstractBlock opBlock = allocator.blockForId(opId); + AbstractBlockBase opBlock = allocator.blockForId(opId); assert opId > 0 && allocator.blockForId(opId - 2) == opBlock : "cannot insert move at block boundary"; // calculate index of instruction inside instruction list of current block @@ -263,7 +263,7 @@ moveResolver.addMapping(srcIt, dstIt); } - int findOptimalSplitPos(AbstractBlock minBlock, AbstractBlock maxBlock, int maxSplitPos) { + int findOptimalSplitPos(AbstractBlockBase minBlock, AbstractBlockBase maxBlock, int maxSplitPos) { int fromBlockNr = minBlock.getLinearScanNumber(); int toBlockNr = maxBlock.getLinearScanNumber(); @@ -280,7 +280,7 @@ int minLoopDepth = maxBlock.getLoopDepth(); for (int i = toBlockNr - 1; i >= fromBlockNr; i--) { - AbstractBlock cur = blockAt(i); + AbstractBlockBase cur = blockAt(i); if (cur.getLoopDepth() < minLoopDepth) { // block with lower loop-depth found . split at the end of this block @@ -308,13 +308,13 @@ // beginning of a block, then minSplitPos is also a possible split position. // Use the block before as minBlock, because then minBlock.lastLirInstructionId() + 2 == // minSplitPos - AbstractBlock minBlock = allocator.blockForId(minSplitPos - 1); + AbstractBlockBase minBlock = allocator.blockForId(minSplitPos - 1); // reason for using maxSplitPos - 1: otherwise there would be an assert on failure // when an interval ends at the end of the last block of the method // (in this case, maxSplitPos == allocator().maxLirOpId() + 2, and there is no // block at this opId) - AbstractBlock maxBlock = allocator.blockForId(maxSplitPos - 1); + AbstractBlockBase maxBlock = allocator.blockForId(maxSplitPos - 1); assert minBlock.getLinearScanNumber() <= maxBlock.getLinearScanNumber() : "invalid order"; if (minBlock == maxBlock) { @@ -352,7 +352,7 @@ // Desired result: uses tagged as shouldHaveRegister inside a loop cause // a reloading // of the interval (normally, only mustHaveRegister causes a reloading) - AbstractBlock loopBlock = allocator.blockForId(loopEndPos); + AbstractBlockBase loopBlock = allocator.blockForId(loopEndPos); Debug.log("interval is used in loop that ends in block B%d, so trying to move maxBlock back from B%d to B%d", loopBlock.getId(), maxBlock.getId(), loopBlock.getId()); assert loopBlock != minBlock : "loopBlock and minBlock must be different because block boundary is needed between"; diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LocationMarker.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LocationMarker.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LocationMarker.java Mon Feb 23 18:37:20 2015 +0100 @@ -52,7 +52,7 @@ } @Override - protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { + protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { new Marker(lirGenRes.getLIR(), lirGenRes.getFrameMap()).build(); } @@ -72,19 +72,19 @@ } private void build() { - Deque> worklist = new ArrayDeque<>(); + Deque> worklist = new ArrayDeque<>(); for (int i = lir.getControlFlowGraph().getBlocks().size() - 1; i >= 0; i--) { worklist.add(lir.getControlFlowGraph().getBlocks().get(i)); } - for (AbstractBlock block : lir.getControlFlowGraph().getBlocks()) { + for (AbstractBlockBase block : lir.getControlFlowGraph().getBlocks()) { liveInMap.put(block, frameMap.initReferenceMap(true)); } while (!worklist.isEmpty()) { - AbstractBlock block = worklist.poll(); + AbstractBlockBase block = worklist.poll(); processBlock(block, worklist); } // finish states - for (AbstractBlock block : lir.getControlFlowGraph().getBlocks()) { + for (AbstractBlockBase block : lir.getControlFlowGraph().getBlocks()) { List instructions = lir.getLIRforBlock(block); for (int i = instructions.size() - 1; i >= 0; i--) { LIRInstruction inst = instructions.get(i); @@ -97,7 +97,7 @@ /** * Merge outSet with in-set of successors. */ - private boolean updateOutBlock(AbstractBlock block) { + private boolean updateOutBlock(AbstractBlockBase block) { ReferenceMap union = frameMap.initReferenceMap(true); block.getSuccessors().forEach(succ -> union.updateUnion(liveInMap.get(succ))); ReferenceMap outSet = liveOutMap.get(block); @@ -109,7 +109,7 @@ return false; } - private void processBlock(AbstractBlock block, Deque> worklist) { + private void processBlock(AbstractBlockBase block, Deque> worklist) { if (updateOutBlock(block)) { try (Indent indent = Debug.logAndIndent("handle block %s", block)) { BlockClosure closure = new BlockClosure(liveOutMap.get(block).clone()); diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/OptimizingLinearScanWalker.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/OptimizingLinearScanWalker.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/OptimizingLinearScanWalker.java Mon Feb 23 18:37:20 2015 +0100 @@ -71,14 +71,14 @@ @Override void walk() { try (Scope s = Debug.scope("OptimizingLinearScanWalker")) { - for (AbstractBlock block : allocator.sortedBlocks) { + for (AbstractBlockBase block : allocator.sortedBlocks) { optimizeBlock(block); } } super.walk(); } - private void optimizeBlock(AbstractBlock block) { + private void optimizeBlock(AbstractBlockBase block) { if (block.getPredecessorCount() == 1) { int nextBlock = allocator.getFirstLirInstructionId(block); try (Scope s1 = Debug.scope("LSRAOptimization")) { @@ -114,7 +114,7 @@ } } - private boolean optimize(int currentPos, AbstractBlock currentBlock, Interval currentInterval, RegisterBinding binding) { + private boolean optimize(int currentPos, AbstractBlockBase currentBlock, Interval currentInterval, RegisterBinding binding) { // BEGIN initialize and sanity checks assert currentBlock != null : "block must not be null"; assert currentInterval != null : "interval must not be null"; @@ -136,7 +136,7 @@ assert currentLocation != null : "active intervals must have a location assigned!"; // get predecessor stuff - AbstractBlock predecessorBlock = currentBlock.getPredecessors().get(0); + AbstractBlockBase predecessorBlock = currentBlock.getPredecessors().get(0); int predEndId = allocator.getLastLirInstructionId(predecessorBlock); Interval predecessorInterval = currentInterval.getIntervalCoveringOpId(predEndId); assert predecessorInterval != null : "variable not live at the end of the only predecessor! " + predecessorBlock + " -> " + currentBlock + " interval: " + currentInterval; diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/RegisterVerifier.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/RegisterVerifier.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/RegisterVerifier.java Mon Feb 23 18:37:20 2015 +0100 @@ -41,7 +41,7 @@ final class RegisterVerifier { LinearScan allocator; - List> workList; // all blocks that must be processed + List> workList; // all blocks that must be processed ArrayMap savedStates; // saved information of previous check // simplified access to methods of LinearScan @@ -55,15 +55,15 @@ } // accessors - Interval[] stateForBlock(AbstractBlock block) { + Interval[] stateForBlock(AbstractBlockBase block) { return savedStates.get(block.getId()); } - void setStateForBlock(AbstractBlock block, Interval[] savedState) { + void setStateForBlock(AbstractBlockBase block, Interval[] savedState) { savedStates.put(block.getId(), savedState); } - void addToWorkList(AbstractBlock block) { + void addToWorkList(AbstractBlockBase block) { if (!workList.contains(block)) { workList.add(block); } @@ -76,7 +76,7 @@ } - void verify(AbstractBlock start) { + void verify(AbstractBlockBase start) { // setup input registers (method arguments) for first block Interval[] inputState = new Interval[stateSize()]; setStateForBlock(start, inputState); @@ -84,14 +84,14 @@ // main loop for verification do { - AbstractBlock block = workList.get(0); + AbstractBlockBase block = workList.get(0); workList.remove(0); processBlock(block); } while (!workList.isEmpty()); } - private void processBlock(AbstractBlock block) { + private void processBlock(AbstractBlockBase block) { try (Indent indent = Debug.logAndIndent("processBlock B%d", block.getId())) { // must copy state because it is modified Interval[] inputState = copy(stateForBlock(block)); @@ -110,13 +110,13 @@ processOperations(allocator.ir.getLIRforBlock(block), inputState); // iterate all successors - for (AbstractBlock succ : block.getSuccessors()) { + for (AbstractBlockBase succ : block.getSuccessors()) { processSuccessor(succ, inputState); } } } - private void processSuccessor(AbstractBlock block, Interval[] inputState) { + private void processSuccessor(AbstractBlockBase block, Interval[] inputState) { Interval[] savedState = stateForBlock(block); if (savedState != null) { diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/CompilationResultBuilder.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/CompilationResultBuilder.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/CompilationResultBuilder.java Mon Feb 23 18:37:20 2015 +0100 @@ -330,7 +330,7 @@ */ public boolean isSuccessorEdge(LabelRef edge) { assert lir != null; - List> order = lir.codeEmittingOrder(); + List> order = lir.codeEmittingOrder(); assert order.get(currentBlockIndex) == edge.getSourceBlock(); return currentBlockIndex < order.size() - 1 && order.get(currentBlockIndex + 1) == edge.getTargetBlock(); } @@ -344,7 +344,7 @@ this.lir = lir; this.currentBlockIndex = 0; frameContext.enter(this); - for (AbstractBlock b : lir.codeEmittingOrder()) { + for (AbstractBlockBase b : lir.codeEmittingOrder()) { emitBlock(b); currentBlockIndex++; } @@ -352,7 +352,7 @@ this.currentBlockIndex = 0; } - private void emitBlock(AbstractBlock block) { + private void emitBlock(AbstractBlockBase block) { if (Debug.isDumpEnabled()) { blockComment(String.format("block B%d %s", block.getId(), block.getLoop())); } diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java Mon Feb 23 18:37:20 2015 +0100 @@ -57,7 +57,7 @@ } @Override - protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LIRGeneratorTool lirGen) { + protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LIRGeneratorTool lirGen) { new Optimization(lirGenRes.getLIR(), lirGen).apply(); } @@ -135,7 +135,7 @@ assert !operand.equals(var) : "constant usage through variable in frame state " + var; } }; - for (AbstractBlock block : lir.getControlFlowGraph().getBlocks()) { + for (AbstractBlockBase block : lir.getControlFlowGraph().getBlocks()) { for (LIRInstruction inst : lir.getLIRforBlock(block)) { // set instruction id to the index in the lir instruction list inst.visitEachState(stateConsumer); @@ -152,7 +152,7 @@ } private void addUsageToBlockMap(UseEntry entry) { - AbstractBlock block = entry.getBlock(); + AbstractBlockBase block = entry.getBlock(); List list = blockMap.get(block); if (list == null) { list = new ArrayList<>(); @@ -164,7 +164,7 @@ /** * Collects def-use information for a {@code block}. */ - private void analyzeBlock(AbstractBlock block) { + private void analyzeBlock(AbstractBlockBase block) { try (Indent indent = Debug.logAndIndent("Block: %s", block)) { InstructionValueConsumer loadConsumer = (instruction, value, mode, flags) -> { @@ -267,17 +267,17 @@ Debug.dump(constTree, "ConstantTree for " + tree.getVariable()); } - private void createLoads(DefUseTree tree, ConstantTree constTree, AbstractBlock startBlock) { - Deque> worklist = new ArrayDeque<>(); + private void createLoads(DefUseTree tree, ConstantTree constTree, AbstractBlockBase startBlock) { + Deque> worklist = new ArrayDeque<>(); worklist.add(startBlock); while (!worklist.isEmpty()) { - AbstractBlock block = worklist.pollLast(); + AbstractBlockBase block = worklist.pollLast(); if (constTree.get(Flags.CANDIDATE, block)) { constTree.set(Flags.MATERIALIZE, block); // create and insert load insertLoad(tree.getConstant(), tree.getVariable().getLIRKind(), block, constTree.getCost(block).getUsages()); } else { - for (AbstractBlock dominated : block.getDominated()) { + for (AbstractBlockBase dominated : block.getDominated()) { if (constTree.isMarked(dominated)) { worklist.addLast(dominated); } @@ -286,7 +286,7 @@ } } - private void insertLoad(JavaConstant constant, LIRKind kind, AbstractBlock block, List usages) { + private void insertLoad(JavaConstant constant, LIRKind kind, AbstractBlockBase block, List usages) { assert usages != null && usages.size() > 0 : String.format("No usages %s %s %s", constant, block, usages); // create variable Variable variable = lirGen.newVariable(kind); @@ -306,7 +306,7 @@ * Inserts the constant loads created in {@link #createConstantTree} and deletes the * original definition. */ - private void rewriteBlock(AbstractBlock block) { + private void rewriteBlock(AbstractBlockBase block) { // insert moves LIRInsertionBuffer buffer = insertionBuffers.get(block); if (buffer != null) { @@ -331,13 +331,13 @@ } private void deleteInstruction(DefUseTree tree) { - AbstractBlock block = tree.getBlock(); + AbstractBlockBase block = tree.getBlock(); LIRInstruction instruction = tree.getInstruction(); Debug.log("deleting instruction %s from block %s", instruction, block); lir.getLIRforBlock(block).set(instruction.id(), null); } - private LIRInsertionBuffer getInsertionBuffer(AbstractBlock block) { + private LIRInsertionBuffer getInsertionBuffer(AbstractBlockBase block) { LIRInsertionBuffer insertionBuffer = insertionBuffers.get(block); if (insertionBuffer == null) { insertionBuffer = new LIRInsertionBuffer(); diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantTree.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantTree.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantTree.java Mon Feb 23 18:37:20 2015 +0100 @@ -99,7 +99,7 @@ tree.forEach(u -> getOrInitList(u.getBlock()).add(u)); } - private List getOrInitList(AbstractBlock block) { + private List getOrInitList(AbstractBlockBase block) { List list = blockMap.get(block); if (list == null) { list = new ArrayList<>(); @@ -108,7 +108,7 @@ return list; } - public List getUsages(AbstractBlock block) { + public List getUsages(AbstractBlockBase block) { List list = blockMap.get(block); if (list == null) { return Collections.emptyList(); @@ -120,7 +120,7 @@ * Returns the cost object associated with {@code block}. If there is none, a new cost object is * created. */ - NodeCost getOrInitCost(AbstractBlock block) { + NodeCost getOrInitCost(AbstractBlockBase block) { NodeCost cost = getCost(block); if (cost == null) { cost = new NodeCost(block.probability(), blockMap.get(block), 1); @@ -145,7 +145,7 @@ } @Override - public void forEachPropertyPair(AbstractBlock block, BiConsumer action) { + public void forEachPropertyPair(AbstractBlockBase block, BiConsumer action) { if (get(Flags.SUBTREE, block) && (block.getDominator() == null || !get(Flags.SUBTREE, block.getDominator()))) { action.accept("hasDefinition", "true"); } @@ -156,7 +156,7 @@ return stream(Flags.SUBTREE).count(); } - public AbstractBlock getStartBlock() { + public AbstractBlockBase getStartBlock() { return stream(Flags.SUBTREE).findFirst().get(); } @@ -164,15 +164,15 @@ stream(Flags.USAGE).forEach(block -> setDominatorPath(Flags.SUBTREE, block)); } - public boolean isMarked(AbstractBlock block) { + public boolean isMarked(AbstractBlockBase block) { return get(Flags.SUBTREE, block); } - public boolean isLeafBlock(AbstractBlock block) { + public boolean isLeafBlock(AbstractBlockBase block) { return block.getDominated().stream().noneMatch(this::isMarked); } - public void setSolution(AbstractBlock block) { + public void setSolution(AbstractBlockBase block) { set(Flags.MATERIALIZE, block); } @@ -180,7 +180,7 @@ return getBlocks().size(); } - public void traverseTreeWhileTrue(AbstractBlock block, Predicate> action) { + public void traverseTreeWhileTrue(AbstractBlockBase block, Predicate> action) { assert block != null : "block must not be null!"; if (action.test(block)) { block.getDominated().stream().filter(this::isMarked).forEach(dominated -> traverseTreeWhileTrue(dominated, action)); diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantTreeAnalyzer.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantTreeAnalyzer.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantTreeAnalyzer.java Mon Feb 23 18:37:20 2015 +0100 @@ -37,7 +37,7 @@ private final ConstantTree tree; private final BitSet visited; - public static NodeCost analyze(ConstantTree tree, AbstractBlock startBlock) { + public static NodeCost analyze(ConstantTree tree, AbstractBlockBase startBlock) { try (Scope s = Debug.scope("ConstantTreeAnalyzer")) { ConstantTreeAnalyzer analyzer = new ConstantTreeAnalyzer(tree); analyzer.analyzeBlocks(startBlock); @@ -60,11 +60,11 @@ * * @param startBlock The start block of the dominator subtree. */ - private void analyzeBlocks(AbstractBlock startBlock) { - Deque> worklist = new ArrayDeque<>(); + private void analyzeBlocks(AbstractBlockBase startBlock) { + Deque> worklist = new ArrayDeque<>(); worklist.offerLast(startBlock); while (!worklist.isEmpty()) { - AbstractBlock block = worklist.pollLast(); + AbstractBlockBase block = worklist.pollLast(); try (Indent i = Debug.logAndIndent(3, "analyze: %s", block)) { assert block != null : "worklist is empty!"; assert isMarked(block) : "Block not part of the dominator tree: " + block; @@ -79,7 +79,7 @@ // if not yet visited (and not a leaf block) process all children first! Debug.log(3, "not marked"); worklist.offerLast(block); - List> children = block.getDominated(); + List> children = block.getDominated(); children.forEach(child -> filteredPush(worklist, child)); visited.set(block.getId()); } else { @@ -97,15 +97,15 @@ * * @param block The block to be processed. */ - private void process(AbstractBlock block) { + private void process(AbstractBlockBase block) { List usages = new ArrayList<>(); double bestCost = 0; int numMat = 0; - List> children = block.getDominated(); + List> children = block.getDominated(); assert children.stream().anyMatch(this::isMarked) : "no children? should have called leafCost(): " + block; // collect children costs - for (AbstractBlock child : children) { + for (AbstractBlockBase child : children) { if (isMarked(child)) { NodeCost childCost = tree.getCost(child); assert childCost != null : "Child with null cost? block: " + child; @@ -151,23 +151,23 @@ return probabilityBlock * Math.pow(0.9, numMat - 1) < probabilityChildren; } - private void filteredPush(Deque> worklist, AbstractBlock block) { + private void filteredPush(Deque> worklist, AbstractBlockBase block) { if (isMarked(block)) { Debug.log(3, "adding %s to the worklist", block); worklist.offerLast(block); } } - private void leafCost(AbstractBlock block) { + private void leafCost(AbstractBlockBase block) { tree.set(Flags.CANDIDATE, block); tree.getOrInitCost(block); } - private boolean isMarked(AbstractBlock block) { + private boolean isMarked(AbstractBlockBase block) { return tree.isMarked(block); } - private boolean isLeafBlock(AbstractBlock block) { + private boolean isLeafBlock(AbstractBlockBase block) { return tree.isLeafBlock(block); } diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/DefUseTree.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/DefUseTree.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/DefUseTree.java Mon Feb 23 18:37:20 2015 +0100 @@ -35,10 +35,10 @@ */ class DefUseTree { private final LIRInstruction instruction; - private final AbstractBlock block; + private final AbstractBlockBase block; private final List uses; - public DefUseTree(LIRInstruction instruction, AbstractBlock block) { + public DefUseTree(LIRInstruction instruction, AbstractBlockBase block) { assert instruction instanceof MoveOp : "Not a MoveOp: " + instruction; this.instruction = instruction; this.block = block; @@ -57,7 +57,7 @@ return instruction; } - public AbstractBlock getBlock() { + public AbstractBlockBase getBlock() { return block; } @@ -66,7 +66,7 @@ return "DefUseTree [" + instruction + "|" + block + "," + uses + "]"; } - public void addUsage(AbstractBlock b, LIRInstruction inst, ValuePosition position) { + public void addUsage(AbstractBlockBase b, LIRInstruction inst, ValuePosition position) { uses.add(new UseEntry(b, inst, position)); } diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/UseEntry.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/UseEntry.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/UseEntry.java Mon Feb 23 18:37:20 2015 +0100 @@ -31,11 +31,11 @@ */ class UseEntry { - private final AbstractBlock block; + private final AbstractBlockBase block; private final LIRInstruction instruction; private final ValuePosition position; - public UseEntry(AbstractBlock block, LIRInstruction instruction, ValuePosition position) { + public UseEntry(AbstractBlockBase block, LIRInstruction instruction, ValuePosition position) { this.block = block; this.instruction = instruction; this.position = position; @@ -45,7 +45,7 @@ return instruction; } - public AbstractBlock getBlock() { + public AbstractBlockBase getBlock() { return block; } diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMapBuilderImpl.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMapBuilderImpl.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMapBuilderImpl.java Mon Feb 23 18:37:20 2015 +0100 @@ -117,7 +117,7 @@ InstructionValueConsumer verifySlots = (LIRInstruction op, Value value, OperandMode mode, EnumSet flags) -> { assert !isVirtualStackSlot(value) : String.format("Instruction %s contains a virtual stack slot %s", op, value); }; - for (AbstractBlock block : lir.getControlFlowGraph().getBlocks()) { + for (AbstractBlockBase block : lir.getControlFlowGraph().getBlocks()) { lir.getLIRforBlock(block).forEach(op -> { op.visitEachInput(verifySlots); op.visitEachAlive(verifySlots); diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java Mon Feb 23 18:37:20 2015 +0100 @@ -60,7 +60,7 @@ private final CodeGenProviders providers; private final CallingConvention cc; - private AbstractBlock currentBlock; + private AbstractBlockBase currentBlock; private LIRGenerationResult res; @@ -186,7 +186,7 @@ res.getLIR().getLIRforBlock(currentBlock).add(op); } - public boolean hasBlockEnd(AbstractBlock block) { + public boolean hasBlockEnd(AbstractBlockBase block) { List ops = getResult().getLIR().getLIRforBlock(block); if (ops.size() == 0) { return false; @@ -194,7 +194,7 @@ return ops.get(ops.size() - 1) instanceof BlockEndOp; } - public final void doBlockStart(AbstractBlock block) { + public final void doBlockStart(AbstractBlockBase block) { if (Options.PrintIRWithLIR.getValue()) { TTY.print(block.toString()); } @@ -212,7 +212,7 @@ } } - public final void doBlockEnd(AbstractBlock block) { + public final void doBlockEnd(AbstractBlockBase block) { if (Options.TraceLIRGeneratorLevel.getValue() >= 1) { TTY.println("END Generating LIR for block B" + block.getId()); @@ -379,11 +379,11 @@ } } - public AbstractBlock getCurrentBlock() { + public AbstractBlockBase getCurrentBlock() { return currentBlock; } - void setCurrentBlock(AbstractBlock block) { + void setCurrentBlock(AbstractBlockBase block) { currentBlock = block; } diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java Mon Feb 23 18:37:20 2015 +0100 @@ -42,15 +42,15 @@ ForeignCallsProvider getForeignCalls(); - AbstractBlock getCurrentBlock(); + AbstractBlockBase getCurrentBlock(); LIRGenerationResult getResult(); - boolean hasBlockEnd(AbstractBlock block); + boolean hasBlockEnd(AbstractBlockBase block); - void doBlockStart(AbstractBlock block); + void doBlockStart(AbstractBlockBase block); - void doBlockEnd(AbstractBlock block); + void doBlockEnd(AbstractBlockBase block); Value emitLoadConstant(LIRKind kind, Constant constant); diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/AllocationPhase.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/AllocationPhase.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/AllocationPhase.java Mon Feb 23 18:37:20 2015 +0100 @@ -34,10 +34,10 @@ } @Override - protected final > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, AllocationContext context) { + protected final > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, AllocationContext context) { run(target, lirGenRes, codeEmittingOrder, linearScanOrder); } - protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder); + protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder); } diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhase.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhase.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhase.java Mon Feb 23 18:37:20 2015 +0100 @@ -73,11 +73,11 @@ memUseTracker = Debug.memUseTracker("LIRPhaseMemUse_%s", getClass()); } - public final > void apply(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context) { + public final > void apply(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context) { apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context, true); } - public final > void apply(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context, boolean dumpLIR) { + public final > void apply(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context, boolean dumpLIR) { try (TimerCloseable a = timer.start(); Scope s = Debug.scope(getName(), this); Closeable c = memUseTracker.start()) { run(target, lirGenRes, codeEmittingOrder, linearScanOrder, context); if (dumpLIR && Debug.isDumpEnabled(PHASE_DUMP_LEVEL)) { @@ -88,7 +88,7 @@ } } - protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context); + protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context); protected CharSequence createName() { String className = LIRPhase.this.getClass().getName(); diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhaseSuite.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhaseSuite.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhaseSuite.java Mon Feb 23 18:37:20 2015 +0100 @@ -69,7 +69,7 @@ } @Override - protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context) { + protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context) { for (LIRPhase phase : phases) { phase.apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context); } diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/PostAllocationOptimizationPhase.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/PostAllocationOptimizationPhase.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/PostAllocationOptimizationPhase.java Mon Feb 23 18:37:20 2015 +0100 @@ -34,11 +34,11 @@ } @Override - protected final > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, + protected final > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, PostAllocationOptimizationContext context) { run(target, lirGenRes, codeEmittingOrder, linearScanOrder); } - protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder); + protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder); } diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/PreAllocationOptimizationPhase.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/PreAllocationOptimizationPhase.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/PreAllocationOptimizationPhase.java Mon Feb 23 18:37:20 2015 +0100 @@ -40,11 +40,11 @@ } @Override - protected final > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, + protected final > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, PreAllocationOptimizationContext context) { run(target, lirGenRes, codeEmittingOrder, linearScanOrder, context.lirGen); } - protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LIRGeneratorTool lirGen); + protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LIRGeneratorTool lirGen); } diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/FixPointIntervalBuilder.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/FixPointIntervalBuilder.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/FixPointIntervalBuilder.java Mon Feb 23 18:37:20 2015 +0100 @@ -65,15 +65,15 @@ * virtual stack slots. */ Set build() { - Deque> worklist = new ArrayDeque<>(); + Deque> worklist = new ArrayDeque<>(); for (int i = lir.getControlFlowGraph().getBlocks().size() - 1; i >= 0; i--) { worklist.add(lir.getControlFlowGraph().getBlocks().get(i)); } - for (AbstractBlock block : lir.getControlFlowGraph().getBlocks()) { + for (AbstractBlockBase block : lir.getControlFlowGraph().getBlocks()) { liveInMap.put(block, new BitSet(stackSlotMap.length)); } while (!worklist.isEmpty()) { - AbstractBlock block = worklist.poll(); + AbstractBlockBase block = worklist.poll(); processBlock(block, worklist); } return usePos; @@ -82,7 +82,7 @@ /** * Merge outSet with in-set of successors. */ - private boolean updateOutBlock(AbstractBlock block) { + private boolean updateOutBlock(AbstractBlockBase block) { BitSet union = new BitSet(stackSlotMap.length); block.getSuccessors().forEach(succ -> union.or(liveInMap.get(succ))); BitSet outSet = liveOutMap.get(block); @@ -94,7 +94,7 @@ return false; } - private void processBlock(AbstractBlock block, Deque> worklist) { + private void processBlock(AbstractBlockBase block, Deque> worklist) { if (updateOutBlock(block)) { try (Indent indent = Debug.logAndIndent("handle block %s", block)) { List instructions = lir.getLIRforBlock(block); diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java Mon Feb 23 18:37:20 2015 +0100 @@ -68,7 +68,7 @@ private static final DebugTimer AssignSlotsTimer = Debug.timer("LSStackSlotAllocator[AssignSlots]"); @Override - protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { + protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { lirGenRes.buildFrameMap(this); } @@ -84,7 +84,7 @@ private final StackInterval[] stackSlotMap; private final PriorityQueue unhandled; private final PriorityQueue active; - private final List> sortedBlocks; + private final List> sortedBlocks; private final int maxOpId; private Allocator(LIR lir, FrameMapBuilderTool frameMapBuilder) { @@ -149,10 +149,10 @@ * * @return The id of the last operation. */ - private static int numberInstructions(LIR lir, List> sortedBlocks) { + private static int numberInstructions(LIR lir, List> sortedBlocks) { int opId = 0; int index = 0; - for (AbstractBlock block : sortedBlocks) { + for (AbstractBlockBase block : sortedBlocks) { List instructions = lir.getLIRforBlock(block); diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/SimpleStackSlotAllocator.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/SimpleStackSlotAllocator.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/SimpleStackSlotAllocator.java Mon Feb 23 18:37:20 2015 +0100 @@ -39,7 +39,7 @@ public class SimpleStackSlotAllocator extends AllocationPhase implements StackSlotAllocator { @Override - protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { + protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { lirGenRes.buildFrameMap(this); } @@ -75,7 +75,7 @@ } return value; }; - for (AbstractBlock block : res.getLIR().getControlFlowGraph().getBlocks()) { + for (AbstractBlockBase block : res.getLIR().getControlFlowGraph().getBlocks()) { try (Indent indent0 = Debug.logAndIndent("block: %s", block)) { for (LIRInstruction inst : res.getLIR().getLIRforBlock(block)) { try (Indent indent1 = Debug.logAndIndent("Inst: %d: %s", inst.id(), inst)) { diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java Mon Feb 23 18:37:20 2015 +0100 @@ -51,6 +51,7 @@ return endNode; } + @Override public Loop getLoop() { return loop; } @@ -59,18 +60,22 @@ this.loop = loop; } + @Override public int getLoopDepth() { return loop == null ? 0 : loop.getDepth(); } + @Override public boolean isLoopHeader() { return getBeginNode() instanceof LoopBeginNode; } + @Override public boolean isLoopEnd() { return getEndNode() instanceof LoopEndNode; } + @Override public boolean isExceptionEntry() { Node predecessor = getBeginNode().predecessor(); return predecessor != null && predecessor instanceof InvokeWithExceptionNode && getBeginNode() == ((InvokeWithExceptionNode) predecessor).exceptionEdge(); @@ -97,6 +102,7 @@ return b; } + @Override public Block getPostdominator() { return postdominator; } @@ -159,6 +165,7 @@ return "B" + id; } + @Override public double probability() { return probability; } diff -r 08d94d9f0b0f -r 4d70d150944f graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java Mon Feb 23 18:03:32 2015 +0100 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java Mon Feb 23 18:37:20 2015 +0100 @@ -33,7 +33,6 @@ import com.oracle.graal.compiler.gen.*; import com.oracle.graal.graph.*; import com.oracle.graal.java.*; -import com.oracle.graal.java.BciBlockMapping.BciBlock; import com.oracle.graal.lir.*; import com.oracle.graal.lir.alloc.lsra.*; import com.oracle.graal.lir.alloc.lsra.Interval.*; @@ -131,10 +130,10 @@ * @param label A label describing the compilation phase that produced the control flow graph. * @param blocks The list of blocks to be printed. */ - public void printCFG(String label, List> blocks, boolean printNodes) { + public void printCFG(String label, List> blocks, boolean printNodes) { if (lir == null) { latestScheduling = new NodeMap<>(cfg.getNodeToBlock()); - for (AbstractBlock abstractBlock : blocks) { + for (AbstractBlockBase abstractBlock : blocks) { Block block = (Block) abstractBlock; Node cur = block.getBeginNode(); while (true) { @@ -152,7 +151,7 @@ begin("cfg"); out.print("name \"").print(label).println('"'); - for (AbstractBlock block : blocks) { + for (AbstractBlockBase block : blocks) { printBlock(block, printNodes); } end("cfg"); @@ -194,7 +193,7 @@ } } - private void printBlock(AbstractBlock block, boolean printNodes) { + private void printBlock(AbstractBlockBase block, boolean printNodes) { printBlockProlog(block); if (printNodes) { assert block instanceof Block; @@ -203,31 +202,24 @@ printBlockEpilog(block); } - private void printBlockEpilog(AbstractBlock block) { + private void printBlockEpilog(AbstractBlockBase block) { printLIR(block); end("block"); } - private void printBlockProlog(AbstractBlock block) { + private void printBlockProlog(AbstractBlockBase block) { begin("block"); out.print("name \"").print(blockToString(block)).println('"'); - if (block instanceof BciBlock) { - out.print("from_bci ").println(((BciBlock) block).startBci); - out.print("to_bci ").println(((BciBlock) block).endBci); - } else { - out.println("from_bci -1"); - out.println("to_bci -1"); - } out.print("predecessors "); - for (AbstractBlock pred : block.getPredecessors()) { + for (AbstractBlockBase pred : block.getPredecessors()) { out.print("\"").print(blockToString(pred)).print("\" "); } out.println(); out.print("successors "); - for (AbstractBlock succ : block.getSuccessors()) { + for (AbstractBlockBase succ : block.getSuccessors()) { if (!succ.isExceptionEntry()) { out.print("\"").print(blockToString(succ)).print("\" "); } @@ -235,7 +227,7 @@ out.println(); out.print("xhandlers"); - for (AbstractBlock succ : block.getSuccessors()) { + for (AbstractBlockBase succ : block.getSuccessors()) { if (succ.isExceptionEntry()) { out.print("\"").print(blockToString(succ)).print("\" "); } @@ -437,7 +429,7 @@ * * @param block the block to print */ - private void printLIR(AbstractBlock block) { + private void printLIR(AbstractBlockBase block) { if (lir == null) { return; } @@ -500,7 +492,7 @@ return prefix + node.toString(Verbosity.Id); } - private String blockToString(AbstractBlock block) { + private String blockToString(AbstractBlockBase block) { if (lir == null && schedule == null && block instanceof Block) { // During all the front-end phases, the block schedule is built only for the debug // output.