changeset 2828:d6f3dbb4e3b5

merge
author Lukas Stadler <lukas.stadler@jku.at>
date Mon, 30 May 2011 18:47:33 +0200
parents bd17ac598c6e (current diff) d54ea877a302 (diff)
children 27c00b180416
files graal/GraalCompiler/src/com/sun/c1x/C1XCompilation.java graal/GraalCompiler/src/com/sun/c1x/ir/Anchor.java graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java graal/GraalCompiler/src/com/sun/c1x/ir/Merge.java
diffstat 12 files changed, 59 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/oracle/max/graal/schedule/Schedule.java	Mon May 30 18:46:57 2011 +0200
+++ b/graal/GraalCompiler/src/com/oracle/max/graal/schedule/Schedule.java	Mon May 30 18:47:33 2011 +0200
@@ -81,10 +81,14 @@
         return b;
     }
 
-    private boolean isCFG(Node n) {
+    private static boolean isCFG(Node n) {
         return n != null && ((n instanceof Instruction) || n == n.graph().start());
     }
 
+    public static boolean isBlockEnd(Node n) {
+        return trueSuccessorCount(n) > 1 || n instanceof Anchor || n instanceof Return || n instanceof Throw;
+    }
+
     private void identifyBlocks() {
         // Identify blocks.
         final ArrayList<Node> blockBeginNodes = new ArrayList<Node>();
@@ -122,27 +126,7 @@
                     blockBeginNodes.add(n);
                 } else {
                     // We have a single predecessor => check its successor count.
-                    int successorCount = 0;
-                    for (Node succ : singlePred.successors()) {
-                        if (isCFG(succ)) {
-                            successorCount++;
-                            if (successorCount > 1) {
-                                // Our predecessor is a split => we need a new block.
-                                if (singlePred instanceof ExceptionEdgeInstruction) {
-                                    ExceptionEdgeInstruction e = (ExceptionEdgeInstruction) singlePred;
-                                    if (e.exceptionEdge() != n) {
-                                        break;
-                                    }
-                                }
-                                Block b = assignBlock(n);
-                                b.setExceptionEntry(singlePred instanceof ExceptionEdgeInstruction);
-                                blockBeginNodes.add(n);
-                                return true;
-                            }
-                        }
-                    }
-
-                    if (singlePred instanceof BlockEnd) {
+                    if (isBlockEnd(singlePred)) {
                         Block b = assignBlock(n);
                         b.setExceptionEntry(singlePred instanceof Throw);
                         blockBeginNodes.add(n);
@@ -450,4 +434,14 @@
             }
         }*/
     }
+
+    public static int trueSuccessorCount(Node n) {
+        int i = 0;
+        for (Node s : n.successors()) {
+            if (isCFG(s)) {
+                i++;
+            }
+        }
+        return i;
+    }
 }
--- a/graal/GraalCompiler/src/com/sun/c1x/C1XCompilation.java	Mon May 30 18:46:57 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/C1XCompilation.java	Mon May 30 18:47:33 2011 +0200
@@ -29,6 +29,7 @@
 import com.oracle.max.asm.*;
 import com.sun.c1x.alloc.*;
 import com.sun.c1x.asm.*;
+import com.sun.c1x.debug.*;
 import com.sun.c1x.gen.*;
 import com.sun.c1x.gen.LIRGenerator.*;
 import com.sun.c1x.graph.*;
@@ -253,6 +254,10 @@
                 C1XTimers.LIR_CREATE.stop();
             }
 
+            if (C1XOptions.PrintLIR && !TTY.isSuppressed()) {
+                LIRList.printLIR(hir.linearScanOrder());
+            }
+
             new LinearScan(this, hir, lirGenerator, frameMap()).allocate();
         }
     }
--- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java	Mon May 30 18:46:57 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java	Mon May 30 18:47:33 2011 +0200
@@ -34,7 +34,7 @@
 import com.oracle.max.asm.*;
 import com.sun.c1x.*;
 import com.sun.c1x.alloc.*;
-import com.sun.c1x.alloc.OperandPool.*;
+import com.sun.c1x.alloc.OperandPool.VariableFlag;
 import com.sun.c1x.debug.*;
 import com.sun.c1x.globalstub.*;
 import com.sun.c1x.graph.*;
@@ -43,10 +43,16 @@
 import com.sun.c1x.util.*;
 import com.sun.c1x.value.*;
 import com.sun.cri.bytecode.*;
+import com.sun.cri.bytecode.Bytecodes.MemoryBarriers;
 import com.sun.cri.ci.*;
 import com.sun.cri.ri.*;
+import com.sun.cri.xir.CiXirAssembler.XirConstant;
+import com.sun.cri.xir.CiXirAssembler.XirInstruction;
+import com.sun.cri.xir.CiXirAssembler.XirOperand;
+import com.sun.cri.xir.CiXirAssembler.XirParameter;
+import com.sun.cri.xir.CiXirAssembler.XirRegister;
+import com.sun.cri.xir.CiXirAssembler.XirTemp;
 import com.sun.cri.xir.*;
-import com.sun.cri.xir.CiXirAssembler.*;
 
 /**
  * This class traverses the HIR instructions and generates LIR instructions from them.
@@ -258,7 +264,7 @@
                 }
             }
         }
-        if (block.blockSuccessors().size() == 1 && (block.getInstructions().size() == 0  || !(block.getInstructions().get(block.getInstructions().size() - 1) instanceof BlockEnd))) {
+        if (block.blockSuccessors().size() >= 1 && (block.getInstructions().size() == 0  || !jumpsToNextBlock(block.getInstructions().get(block.getInstructions().size() - 1)))) {
             moveToPhi();
             block.lir().jump(block.blockSuccessors().get(0));
         }
@@ -272,6 +278,10 @@
         blockDoEpilog();
     }
 
+    private static boolean jumpsToNextBlock(Node node) {
+        return node instanceof BlockEnd;
+    }
+
     @Override
     public void visitArrayLength(ArrayLength x) {
         emitArrayLength(x);
@@ -405,7 +415,7 @@
     }
 
     @Override
-    public void visitGoto(Anchor x) {
+    public void visitAnchor(Anchor x) {
         setNoResult(x);
 
         // emit phi-instruction moves after safepoint since this simplifies
@@ -454,11 +464,12 @@
     }
 
     private int getBeforeInvokeBci(Invoke invoke) {
-        int length = 3;
+        /*int length = 3;
         if (invoke.opcode() == Bytecodes.INVOKEINTERFACE) {
             length += 2;
         }
-        return invoke.stateAfter().bci - length;
+        return invoke.stateAfter().bci - length;*/
+        return invoke.bci;
     }
 
     @Override
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Mon May 30 18:46:57 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Mon May 30 18:47:33 2011 +0200
@@ -29,6 +29,7 @@
 import java.util.*;
 
 import com.oracle.graal.graph.*;
+import com.oracle.max.graal.schedule.Schedule;
 import com.sun.c1x.*;
 import com.sun.c1x.debug.*;
 import com.sun.c1x.graph.BlockMap.*;
@@ -392,7 +393,7 @@
             FrameState stateWithException = entryState.duplicateModified(bci, CiKind.Void, exception);
 
             Instruction successor = createTarget(dispatchBlock, stateWithException);
-            BlockEnd end = new Anchor(successor, graph);
+            Anchor end = new Anchor(successor, graph);
             exception.setNext(end);
             if (x instanceof Invoke) {
                 ((Invoke) x).setExceptionEdge(entry);
@@ -828,7 +829,7 @@
 
     private void appendInvoke(int opcode, RiMethod target, Value[] args, int cpi, RiConstantPool constantPool) {
         CiKind resultType = returnKind(target);
-        Invoke invoke = new Invoke(opcode, resultType.stackKind(), args, target, target.signature().returnType(compilation.method.holder()), graph);
+        Invoke invoke = new Invoke(opcode, resultType.stackKind(), args, target, target.signature().returnType(compilation.method.holder()), graph, bci());
         Value result = appendWithBCI(invoke);
         handleException(invoke, bci());
         frameState.pushReturn(resultType, result);
@@ -1194,7 +1195,7 @@
             traceInstruction(bci, opcode, blockStart);
             processBytecode(bci, opcode);
 
-            if (lastInstr instanceof BlockEnd || lastInstr.next() != null) {
+            if (Schedule.isBlockEnd(lastInstr) || lastInstr.next() != null) {
                 break;
             }
 
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Anchor.java	Mon May 30 18:46:57 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Anchor.java	Mon May 30 18:47:33 2011 +0200
@@ -47,12 +47,12 @@
 
     @Override
     public void accept(ValueVisitor v) {
-        v.visitGoto(this);
+        v.visitAnchor(this);
     }
 
     @Override
     public void print(LogStream out) {
-        out.print("goto ").print(defaultSuccessor());
+        out.print("anchor ").print(defaultSuccessor());
     }
 
     @Override
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java	Mon May 30 18:46:57 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java	Mon May 30 18:47:33 2011 +0200
@@ -81,6 +81,7 @@
     public final int opcode;
     public final RiMethod target;
     public final RiType returnType;
+    public final int bci; // XXX needed because we can not compute the bci from the sateBefore bci of this Invoke was optimized from INVOKEINTERFACE to INVOKESPECIAL
 
     /**
      * Constructs a new Invoke instruction.
@@ -92,11 +93,12 @@
      * @param target the target method being called
      * @param stateBefore the state before executing the invocation
      */
-    public Invoke(int opcode, CiKind result, Value[] args, RiMethod target, RiType returnType, Graph graph) {
+    public Invoke(int opcode, CiKind result, Value[] args, RiMethod target, RiType returnType, Graph graph, int bci) {
         super(result, args.length, SUCCESSOR_COUNT, graph);
         this.opcode = opcode;
         this.target = target;
         this.returnType = returnType;
+        this.bci = bci;
 
         this.argumentCount = args.length;
         for (int i = 0; i < args.length; i++) {
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Merge.java	Mon May 30 18:46:57 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Merge.java	Mon May 30 18:47:33 2011 +0200
@@ -256,6 +256,11 @@
     }
 
     @Override
+    public String shortName() {
+        return "Merge #" + id();
+    }
+
+    @Override
     public Node copy(Graph into) {
         assert getClass() == Merge.class : "copy of " + getClass();
         Merge x = new Merge(into);
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/NewArray.java	Mon May 30 18:46:57 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/NewArray.java	Mon May 30 18:47:33 2011 +0200
@@ -28,7 +28,7 @@
 /**
  * The {@code NewArray} class is the base of all instructions that allocate arrays.
  */
-public abstract class NewArray extends Value {
+public abstract class NewArray extends Instruction {
 
     private static final int INPUT_COUNT = 1;
     private static final int INPUT_LENGTH = 0;
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/ValueVisitor.java	Mon May 30 18:46:57 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ValueVisitor.java	Mon May 30 18:47:33 2011 +0200
@@ -40,7 +40,7 @@
     public abstract void visitConvert(Convert i);
     public abstract void visitExceptionObject(ExceptionObject i);
     public abstract void visitFrameState(FrameState i);
-    public abstract void visitGoto(Anchor i);
+    public abstract void visitAnchor(Anchor i);
     public abstract void visitIf(If i);
     public abstract void visitIfOp(IfOp i);
     public abstract void visitInstanceOf(InstanceOf i);
--- a/graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRAssembler.java	Mon May 30 18:46:57 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRAssembler.java	Mon May 30 18:47:33 2011 +0200
@@ -529,9 +529,10 @@
         if (op.cond() == Condition.TRUE) {
             if (op.info != null) {
                 int codePos = codePos();
-                if (codePos > tasm.lastSafepointPos()) {
-                    tasm.recordImplicitException(codePos, op.info);
+                if (codePos <= tasm.lastSafepointPos()) {
+                    masm.nop();
                 }
+                tasm.recordImplicitException(codePos(), op.info);
             }
             masm.jmp(op.label());
         } else {
--- a/rundacapo.sh	Mon May 30 18:46:57 2011 +0200
+++ b/rundacapo.sh	Mon May 30 18:47:33 2011 +0200
@@ -15,4 +15,4 @@
   echo "DACAPO is not defined. It must point to a Dacapo benchmark directory."
   exit 1;
 fi
-${JDK7}/bin/java -client -d64 -graal -XX:+C1XBailoutIsFatal -XX:+PrintCompilation -C1X:-QuietBailout -Xms1g -Xmx2g -esa -classpath ${DACAPO}/dacapo-9.12-bach.jar Harness $*
+${JDK7}/bin/java -client -d64 -graal -XX:-C1XBailoutIsFatal -XX:+PrintCompilation -C1X:+QuietBailout -Xms1g -Xmx2g -esa -classpath ${DACAPO}/dacapo-9.12-bach.jar Harness --preserve $*
--- a/runtests.sh	Mon May 30 18:46:57 2011 +0200
+++ b/runtests.sh	Mon May 30 18:47:33 2011 +0200
@@ -12,4 +12,4 @@
   exit 1;
 fi
 TESTDIR=${MAXINE}/com.oracle.max.vm/test
-${JDK7}/bin/java -client -d64 -graal -ea -esa -Xcomp -C1X:PrintIdealGraphLevel=0 -C1X:-PrintCFGToFile -C1X:-PrintAssembly -XX:-TraceSignals -XX:-TraceDeoptimization -XX:-TraceExceptions -XX:+PrintCompilation -XX:CompileOnly=jtt -Xbootclasspath/p:"${MAXINE}/com.oracle.max.vm/bin" -Xbootclasspath/p:"${MAXINE}/com.oracle.max.base/bin" $1 test.com.sun.max.vm.compiler.JavaTester -verbose=1 -gen-run-scheme=false -run-scheme-package=all ${TESTDIR}/jtt/bytecode ${TESTDIR}/jtt/except ${TESTDIR}/jtt/hotpath ${TESTDIR}/jtt/jdk ${TESTDIR}/jtt/lang ${TESTDIR}/jtt/loop ${TESTDIR}/jtt/micro ${TESTDIR}/jtt/optimize ${TESTDIR}/jtt/reflect ${TESTDIR}/jtt/threads
+${JDK7}/bin/java -client -d64 -graal -ea -esa -Xcomp -C1X:PrintIdealGraphLevel=4 -C1X:PrintFilter=anewarray -C1X:-PrintCFGToFile -C1X:-PrintAssembly -XX:-TraceSignals -XX:-TraceDeoptimization -XX:-TraceExceptions -XX:+PrintCompilation -XX:CompileOnly=jtt -Xbootclasspath/p:"${MAXINE}/com.oracle.max.vm/bin" -Xbootclasspath/p:"${MAXINE}/com.oracle.max.base/bin" $1 test.com.sun.max.vm.compiler.JavaTester -verbose=1 -gen-run-scheme=false -run-scheme-package=all ${TESTDIR}/jtt/bytecode ${TESTDIR}/jtt/except ${TESTDIR}/jtt/hotpath ${TESTDIR}/jtt/jdk ${TESTDIR}/jtt/lang ${TESTDIR}/jtt/loop ${TESTDIR}/jtt/micro ${TESTDIR}/jtt/optimize ${TESTDIR}/jtt/reflect ${TESTDIR}/jtt/threads