changeset 2654:616c6e74b69a

Merge.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 11 May 2011 15:11:58 +0200
parents 7c8ad40c1f88 (diff) d456b679b6de (current diff)
children df5de2a207ca
files graal/GraalCompiler/src/com/sun/c1x/C1XOptions.java
diffstat 8 files changed, 55 insertions(+), 144 deletions(-) [+]
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/C1XOptions.java	Wed May 11 14:45:32 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/C1XOptions.java	Wed May 11 15:11:58 2011 +0200
@@ -52,9 +52,6 @@
 
     // debugging settings
     public static boolean VerifyPointerMaps                  = ____;
-    public static boolean PinAllInstructions                 = ____;
-    public static boolean TestPatching                       = ____;
-    public static boolean FatalUnimplemented                 = ____;
     public static int     MethodEndBreakpointGuards          = 0;
     public static boolean ZapStackOnMethodEntry              = ____;
     public static boolean StressLinearScan                   = ____;
--- a/graal/GraalCompiler/src/com/sun/c1x/alloc/ControlFlowOptimizer.java	Wed May 11 14:45:32 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/alloc/ControlFlowOptimizer.java	Wed May 11 15:11:58 2011 +0200
@@ -45,16 +45,6 @@
     public static void optimize(IR ir) {
         ControlFlowOptimizer optimizer = new ControlFlowOptimizer(ir);
         List<BlockBegin> code = ir.linearScanOrder();
-
-        // push the OSR entry block to the end so that we're not jumping over it.
-        BlockBegin osrEntry = ((Base) code.get(0).end()).osrEntry();
-        if (osrEntry != null) {
-            int index = osrEntry.linearScanNumber();
-            assert code.get(index) == osrEntry : "wrong index";
-            code.remove(index);
-            code.add(osrEntry);
-        }
-
         optimizer.reorderShortLoops(code);
         optimizer.deleteEmptyBlocks(code);
         optimizer.deleteUnnecessaryJumps(code);
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Wed May 11 14:45:32 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Wed May 11 15:11:58 2011 +0200
@@ -331,7 +331,7 @@
         if (con instanceof RiType) {
             // this is a load of class constant which might be unresolved
             RiType riType = (RiType) con;
-            if (!riType.isResolved() || C1XOptions.TestPatching) {
+            if (!riType.isResolved()) {
                 ResolveClass rc = new ResolveClass(riType, RiType.Representation.JavaClass, graph, frameState.create(bci()));
                 frameState.push(CiKind.Object, append(rc));
             } else {
@@ -509,59 +509,50 @@
         append(new If(x, cond, y, tsucc, fsucc, isSafepoint ? stateBefore : null, isSafepoint, graph));
     }
 
-    void genIfZero(Condition cond) {
+    private void genIfZero(Condition cond) {
         Value y = appendConstant(CiConstant.INT_0);
         FrameState stateBefore = frameState.create(bci());
         Value x = frameState.ipop();
         ifNode(x, cond, y, stateBefore);
     }
 
-    void genIfNull(Condition cond) {
+    private void genIfNull(Condition cond) {
         FrameState stateBefore = frameState.create(bci());
         Value y = appendConstant(CiConstant.NULL_OBJECT);
         Value x = frameState.apop();
         ifNode(x, cond, y, stateBefore);
     }
 
-    void genIfSame(CiKind kind, Condition cond) {
+    private void genIfSame(CiKind kind, Condition cond) {
         FrameState stateBefore = frameState.create(bci());
         Value y = frameState.pop(kind);
         Value x = frameState.pop(kind);
         ifNode(x, cond, y, stateBefore);
     }
 
-    void genThrow(int bci) {
+    private void genThrow(int bci) {
         FrameState stateBefore = frameState.create(bci);
         Throw t = new Throw(frameState.apop(), !noSafepoints(), graph);
         t.setStateBefore(stateBefore);
         appendWithoutOptimization(t, bci);
     }
 
-    void genCheckCast() {
+    private void genCheckCast() {
         int cpi = stream().readCPI();
         RiType type = constantPool().lookupType(cpi, CHECKCAST);
-        boolean isInitialized = !C1XOptions.TestPatching && type.isResolved() && type.isInitialized();
+        boolean isInitialized = type.isResolved() && type.isInitialized();
         Value typeInstruction = genResolveClass(RiType.Representation.ObjectHub, type, isInitialized, cpi);
         CheckCast c = new CheckCast(type, typeInstruction, frameState.apop(), graph);
         frameState.apush(append(c));
-        checkForDirectCompare(c);
     }
 
-    void genInstanceOf() {
+    private void genInstanceOf() {
         int cpi = stream().readCPI();
         RiType type = constantPool().lookupType(cpi, INSTANCEOF);
-        boolean isInitialized = !C1XOptions.TestPatching && type.isResolved() && type.isInitialized();
+        boolean isInitialized = type.isResolved() && type.isInitialized();
         Value typeInstruction = genResolveClass(RiType.Representation.ObjectHub, type, isInitialized, cpi);
         InstanceOf i = new InstanceOf(type, typeInstruction, frameState.apop(), graph);
         frameState.ipush(append(i));
-        checkForDirectCompare(i);
-    }
-
-    private void checkForDirectCompare(TypeCheck check) {
-        RiType type = check.targetClass();
-        if (!type.isResolved() || type.isArrayClass()) {
-            return;
-        }
     }
 
     void genNewInstance(int cpi) {
@@ -575,14 +566,14 @@
         frameState.apush(append(n));
     }
 
-    void genNewTypeArray(int typeCode) {
+    private void genNewTypeArray(int typeCode) {
         CiKind kind = CiKind.fromArrayTypeCode(typeCode);
         RiType elementType = compilation.runtime.asRiType(kind);
         NewTypeArray nta = new NewTypeArray(frameState.ipop(), elementType, graph);
         frameState.apush(append(nta));
     }
 
-    void genNewObjectArray(int cpi) {
+    private void genNewObjectArray(int cpi) {
         RiType type = constantPool().lookupType(cpi, ANEWARRAY);
         FrameState stateBefore = null;
         if (!type.isResolved()) {
@@ -593,7 +584,7 @@
         n.setStateBefore(stateBefore);
     }
 
-    void genNewMultiArray(int cpi) {
+    private void genNewMultiArray(int cpi) {
         RiType type = constantPool().lookupType(cpi, MULTIANEWARRAY);
         FrameState stateBefore = null;
         if (!type.isResolved()) {
@@ -609,7 +600,7 @@
         n.setStateBefore(stateBefore);
     }
 
-    void genGetField(int cpi, RiField field) {
+    private void genGetField(int cpi, RiField field) {
         // Must copy the state here, because the field holder must still be on the stack.
         FrameState stateBefore = null;
         if (!field.isResolved()) {
@@ -620,7 +611,7 @@
         load.setStateBefore(stateBefore);
     }
 
-    void genPutField(int cpi, RiField field) {
+    private void genPutField(int cpi, RiField field) {
         // Must copy the state here, because the field holder must still be on the stack.
         FrameState stateBefore = null;
         if (!field.isResolved()) {
@@ -632,9 +623,9 @@
         store.setStateBefore(stateBefore);
     }
 
-    void genGetStatic(int cpi, RiField field) {
+    private void genGetStatic(int cpi, RiField field) {
         RiType holder = field.holder();
-        boolean isInitialized = !C1XOptions.TestPatching && field.isResolved();
+        boolean isInitialized = field.isResolved();
         CiConstant constantValue = null;
         FrameState stateBefore = null;
         if (isInitialized) {
@@ -652,7 +643,7 @@
         }
     }
 
-    void genPutStatic(int cpi, RiField field) {
+    private void genPutStatic(int cpi, RiField field) {
         RiType holder = field.holder();
         FrameState stateBefore = null;
         if (!field.isResolved()) {
@@ -686,9 +677,9 @@
         frameState.push(kind.stackKind(), optimized);
     }
 
-    void genInvokeStatic(RiMethod target, int cpi, RiConstantPool constantPool) {
+    private void genInvokeStatic(RiMethod target, int cpi, RiConstantPool constantPool) {
         RiType holder = target.holder();
-        boolean isInitialized = !C1XOptions.TestPatching && target.isResolved() && holder.isInitialized();
+        boolean isInitialized = target.isResolved() && holder.isInitialized();
         if (!isInitialized && C1XOptions.ResolveClassBeforeStaticInvoke) {
             // Re-use the same resolution code as for accessing a static field. Even though
             // the result of resolution is not used by the invocation (only the side effect
@@ -699,19 +690,19 @@
         appendInvoke(INVOKESTATIC, target, args, cpi, constantPool);
     }
 
-    void genInvokeInterface(RiMethod target, int cpi, RiConstantPool constantPool) {
+    private void genInvokeInterface(RiMethod target, int cpi, RiConstantPool constantPool) {
         Value[] args = frameState.popArguments(target.signature().argumentSlots(true));
         genInvokeIndirect(INVOKEINTERFACE, target, args, cpi, constantPool);
 
     }
 
-    void genInvokeVirtual(RiMethod target, int cpi, RiConstantPool constantPool) {
+    private void genInvokeVirtual(RiMethod target, int cpi, RiConstantPool constantPool) {
         Value[] args = frameState.popArguments(target.signature().argumentSlots(true));
         genInvokeIndirect(INVOKEVIRTUAL, target, args, cpi, constantPool);
 
     }
 
-    void genInvokeSpecial(RiMethod target, RiType knownHolder, int cpi, RiConstantPool constantPool) {
+    private void genInvokeSpecial(RiMethod target, RiType knownHolder, int cpi, RiConstantPool constantPool) {
         Value[] args = frameState.popArguments(target.signature().argumentSlots(true));
         invokeDirect(target, args, knownHolder, cpi, constantPool);
 
@@ -966,10 +957,6 @@
         return x;
     }
 
-    private boolean hasUncontrollableSideEffects(Value x) {
-        return x instanceof Invoke || x instanceof ResolveClass;
-    }
-
     private BlockBegin blockAtOrNull(int bci) {
         return blockMap.get(bci);
     }
@@ -980,12 +967,12 @@
         return result;
     }
 
-    private Value synchronizedObject(FrameStateAccess curState2, RiMethod target) {
+    private Value synchronizedObject(FrameStateAccess state, RiMethod target) {
         if (isStatic(target.accessFlags())) {
             Constant classConstant = new Constant(target.holder().getEncoding(Representation.JavaClass), graph);
             return appendWithoutOptimization(classConstant, Instruction.SYNCHRONIZATION_ENTRY_BCI);
         } else {
-            return curState2.localAt(0);
+            return state.localAt(0);
         }
     }
 
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/IR.java	Wed May 11 14:45:32 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/graph/IR.java	Wed May 11 15:11:58 2011 +0200
@@ -49,11 +49,6 @@
      */
     public BlockBegin startBlock;
 
-    /**
-     * The entry block for an OSR compile.
-     */
-    public BlockBegin osrEntryBlock;
-
     private int maxLocks;
 
     /**
@@ -143,20 +138,16 @@
      * @param phase the name of the phase for printing
      */
     public void verifyAndPrint(String phase) {
-        printToTTY(phase);
+        if (C1XOptions.PrintHIR && !TTY.isSuppressed()) {
+            TTY.println(phase);
+            print(false);
+        }
 
         if (compilation.compiler.isObserved()) {
             compilation.compiler.fireCompilationEvent(new CompilationEvent(compilation, phase, startBlock, true, false));
         }
     }
 
-    private void printToTTY(String phase) {
-        if (C1XOptions.PrintHIR && !TTY.isSuppressed()) {
-            TTY.println(phase);
-            print(false);
-        }
-    }
-
     /**
      * Creates and inserts a new block between this block and the specified successor,
      * altering the successor and predecessor lists of involved blocks appropriately.
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Base.java	Wed May 11 14:45:32 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Base.java	Wed May 11 15:11:58 2011 +0200
@@ -53,14 +53,6 @@
         return defaultSuccessor();
     }
 
-    /**
-     * Gets the OSR entrypoint block, if it exists.
-     * @return the OSR entrypoint bock, if it exists; {@code null} otherwise
-     */
-    public BlockBegin osrEntry() {
-        return blockSuccessorCount() < 2 ? null : blockSuccessor(0);
-    }
-
     @Override
     public void accept(ValueVisitor v) {
         v.visitBase(this);
@@ -69,8 +61,5 @@
     @Override
     public void print(LogStream out) {
         out.print("std entry B").print(standardEntry().blockID);
-        if (blockSuccessors().size() > 1) {
-            out.print(" osr entry B").print(osrEntry().blockID);
-        }
     }
 }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/ComputeLinearScanOrder.java	Wed May 11 14:45:32 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ComputeLinearScanOrder.java	Wed May 11 15:11:58 2011 +0200
@@ -52,53 +52,53 @@
     final List<BlockBegin> workList; // temporary list (used in markLoops and computeOrder)
 
     // accessors for visitedBlocks and activeBlocks
-    void initVisited() {
+    private void initVisited() {
         activeBlocks.clearAll();
         visitedBlocks.clearAll();
     }
 
-    boolean isVisited(BlockBegin b) {
+    private boolean isVisited(BlockBegin b) {
         return visitedBlocks.get(b.blockID);
     }
 
-    boolean isActive(BlockBegin b) {
+    private boolean isActive(BlockBegin b) {
         return activeBlocks.get(b.blockID);
     }
 
-    void setVisited(BlockBegin b) {
+    private void setVisited(BlockBegin b) {
         assert !isVisited(b) : "already set";
         visitedBlocks.set(b.blockID);
     }
 
-    void setActive(BlockBegin b) {
+    private void setActive(BlockBegin b) {
         assert !isActive(b) : "already set";
         activeBlocks.set(b.blockID);
     }
 
-    void clearActive(BlockBegin b) {
+    private void clearActive(BlockBegin b) {
         assert isActive(b) : "not already";
         activeBlocks.clear(b.blockID);
     }
 
     // accessors for forwardBranches
-    void incForwardBranches(BlockBegin b) {
+    private void incForwardBranches(BlockBegin b) {
         forwardBranches[b.blockID]++;
     }
 
-    int decForwardBranches(BlockBegin b) {
+    private int decForwardBranches(BlockBegin b) {
         return --forwardBranches[b.blockID];
     }
 
     // accessors for loopMap
-    boolean isBlockInLoop(int loopIdx, BlockBegin b) {
+    private boolean isBlockInLoop(int loopIdx, BlockBegin b) {
         return loopMap.at(loopIdx, b.blockID);
     }
 
-    void setBlockInLoop(int loopIdx, BlockBegin b) {
+    private void setBlockInLoop(int loopIdx, BlockBegin b) {
         loopMap.setBit(loopIdx, b.blockID);
     }
 
-    void clearBlockInLoop(int loopIdx, int blockId) {
+    private void clearBlockInLoop(int loopIdx, int blockId) {
         loopMap.clearBit(loopIdx, blockId);
     }
 
@@ -121,8 +121,6 @@
         loopEndBlocks = new ArrayList<BlockBegin>(8);
         workList = new ArrayList<BlockBegin>(8);
 
-        splitCriticalEdges();
-
         countEdges(startBlock, null);
 
         if (numLoops > 0) {
@@ -138,10 +136,6 @@
         assert verify();
     }
 
-    void splitCriticalEdges() {
-        // TODO: move critical edge splitting from IR to here
-    }
-
     /**
      * Traverses the CFG to analyze block and edge info. The analysis performed is:
      *
@@ -150,7 +144,7 @@
      * 3. Number loop header blocks.
      * 4. Create a list with all loop end blocks.
      */
-    void countEdges(BlockBegin cur, BlockBegin parent) {
+    private void countEdges(BlockBegin cur, BlockBegin parent) {
         if (C1XOptions.TraceLinearScanLevel >= 3) {
             TTY.println("Counting edges for block B%d%s", cur.blockID, parent == null ? "" : " coming from B" + parent.blockID);
         }
@@ -176,7 +170,6 @@
                 iterativeDominators = true;
                 return;
             }
-//            assert parent.numberOfSux() == 1 && parent.suxAt(0) == cur : "loop end blocks must have one successor (critical edges are split)";
 
             loopEndBlocks.add(parent);
             return;
@@ -227,7 +220,7 @@
         }
     }
 
-    void markLoops() {
+    private void markLoops() {
         if (C1XOptions.TraceLinearScanLevel >= 3) {
             TTY.println("----- marking loops");
         }
@@ -243,7 +236,6 @@
                 TTY.println("Processing loop from B%d to B%d (loop %d):", loopStart.blockID, loopEnd.blockID, loopIdx);
             }
             assert loopEnd.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopEnd) : "loop end flag must be set";
-//            assert loopEnd.numberOfSux() == 1 : "incorrect number of successors";
             assert loopStart.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopHeader) : "loop header flag must be set";
             assert loopIdx >= 0 && loopIdx < numLoops : "loop index not set";
             assert workList.isEmpty() : "work list must be empty before processing";
@@ -281,7 +273,7 @@
     // check for non-natural loops (loops where the loop header does not dominate
     // all other loop blocks = loops with multiple entries).
     // such loops are ignored
-    void clearNonNaturalLoops(BlockBegin startBlock) {
+    private void clearNonNaturalLoops(BlockBegin startBlock) {
         for (int i = numLoops - 1; i >= 0; i--) {
             if (isBlockInLoop(i, startBlock)) {
                 // loop i contains the entry block of the method.
@@ -298,7 +290,7 @@
         }
     }
 
-    void assignLoopDepth(BlockBegin startBlock) {
+    private void assignLoopDepth(BlockBegin startBlock) {
         if (C1XOptions.TraceLinearScanLevel >= 3) {
             TTY.println("----- computing loop-depth and weight");
         }
@@ -341,7 +333,7 @@
         } while (!workList.isEmpty());
     }
 
-    BlockBegin commonDominator(BlockBegin a, BlockBegin b) {
+    private BlockBegin commonDominator(BlockBegin a, BlockBegin b) {
         assert a != null && b != null : "must have input blocks";
 
         dominatorBlocks.clearAll();
@@ -359,7 +351,7 @@
         return b;
     }
 
-    void computeDominator(BlockBegin cur, BlockBegin parent) {
+    private void computeDominator(BlockBegin cur, BlockBegin parent) {
         if (cur.dominator() == null) {
             if (C1XOptions.TraceLinearScanLevel >= 4) {
                 TTY.println("DOM: initializing dominator of B%d to B%d", cur.blockID, parent.blockID);
@@ -380,7 +372,7 @@
         }
     }
 
-    int computeWeight(BlockBegin cur) {
+    private int computeWeight(BlockBegin cur) {
         BlockBegin singleSux = null;
         if (cur.numberOfSux() == 1) {
             singleSux = cur.suxAt(0);
@@ -439,7 +431,7 @@
         return weight;
     }
 
-    boolean readyForProcessing(BlockBegin cur) {
+    private boolean readyForProcessing(BlockBegin cur) {
         // Discount the edge just traveled.
         // When the number drops to zero, all forward branches were processed
         if (decForwardBranches(cur) != 0) {
@@ -451,7 +443,7 @@
         return true;
     }
 
-    void sortIntoWorkList(BlockBegin cur) {
+    private void sortIntoWorkList(BlockBegin cur) {
         assert !workList.contains(cur) : "block already in work list";
 
         int curWeight = computeWeight(cur);
@@ -486,7 +478,7 @@
         }
     }
 
-    void appendBlock(BlockBegin cur) {
+    private void appendBlock(BlockBegin cur) {
         if (C1XOptions.TraceLinearScanLevel >= 3) {
             TTY.println("appending block B%d (weight 0x%06x) to linear-scan order", cur.blockID, cur.linearScanNumber());
         }
@@ -499,7 +491,7 @@
         linearScanOrder.add(cur);
     }
 
-    void computeOrder(BlockBegin startBlock) {
+    private void computeOrder(BlockBegin startBlock) {
         if (C1XOptions.TraceLinearScanLevel >= 3) {
             TTY.println("----- computing final block order");
         }
@@ -510,22 +502,7 @@
 
         assert startBlock.end() instanceof Base : "start block must end with Base-instruction";
         BlockBegin stdEntry = ((Base) startBlock.end()).standardEntry();
-        BlockBegin osrEntry = ((Base) startBlock.end()).osrEntry();
 
-        BlockBegin suxOfOsrEntry = null;
-        if (osrEntry != null) {
-            // special handling for osr entry:
-            // ignore the edge between the osr entry and its successor for processing
-            // the osr entry block is added manually below
-            assert osrEntry.numberOfSux() == 1 : "osr entry must have exactly one successor";
-            assert osrEntry.suxAt(0).numberOfPreds() >= 2 : "sucessor of osr entry must have two predecessors (otherwise it is not present in normal control flow)";
-
-            suxOfOsrEntry = osrEntry.suxAt(0);
-            decForwardBranches(suxOfOsrEntry);
-
-            computeDominator(osrEntry, startBlock);
-            iterativeDominators = true;
-        }
         computeDominator(stdEntry, startBlock);
 
         // start processing with standard entry block
@@ -539,13 +516,6 @@
 
         do {
             BlockBegin cur = workList.remove(workList.size() - 1);
-
-            if (cur == suxOfOsrEntry) {
-                // the osr entry block is ignored in normal processing : it is never added to the
-                // work list. Instead : it is added as late as possible manually here.
-                appendBlock(osrEntry);
-                computeDominator(cur, osrEntry);
-            }
             appendBlock(cur);
 
             int i;
@@ -569,7 +539,7 @@
         } while (workList.size() > 0);
     }
 
-    boolean computeDominatorsIter() {
+    private boolean computeDominatorsIter() {
         boolean changed = false;
         int numBlocks = linearScanOrder.size();
 
@@ -604,9 +574,9 @@
         return changed;
     }
 
-    void computeDominators() {
+    private void computeDominators() {
         if (C1XOptions.TraceLinearScanLevel >= 3) {
-            TTY.println("----- computing dominators (iterative computation reqired: %b)", iterativeDominators);
+            TTY.println("----- computing dominators (iterative computation required: %b)", iterativeDominators);
         }
 
         // iterative computation of dominators is only required for methods with non-natural loops
@@ -678,7 +648,7 @@
         }
     }
 
-    boolean verify() {
+    private boolean verify() {
         assert linearScanOrder.size() == numBlocks : "wrong number of blocks in list";
 
         if (C1XOptions.StressLinearScan) {
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/LoadField.java	Wed May 11 14:45:32 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/LoadField.java	Wed May 11 15:11:58 2011 +0200
@@ -104,6 +104,6 @@
 
     @Override
     public boolean needsStateAfter() {
-        return this.isVolatile();
+        return false;
     }
 }
--- a/graal/GraalCompiler/src/com/sun/c1x/util/Util.java	Wed May 11 14:45:32 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/util/Util.java	Wed May 11 15:11:58 2011 +0200
@@ -304,19 +304,6 @@
         return result;
     }
 
-    public static <T> T nonFatalUnimplemented(T val) {
-        if (C1XOptions.FatalUnimplemented) {
-            throw new Error("unimplemented");
-        }
-        return val;
-    }
-
-    public static void nonFatalUnimplemented() {
-        if (C1XOptions.FatalUnimplemented) {
-            throw new Error("unimplemented");
-        }
-    }
-
     public static boolean isShiftCount(int x) {
         return 0 <= x && x < 32;
     }