changeset 2865:7a4e6e11877f

Subclasses for Shift
author Gilles Duboscq <gilles.duboscq@oracle.com>
date Tue, 07 Jun 2011 19:06:20 +0200
parents 32c3d7b51716
children fc75fd3fa5e4 7d7cf33f8466
files graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java graal/GraalCompiler/src/com/sun/c1x/ir/LeftShift.java graal/GraalCompiler/src/com/sun/c1x/ir/RightShift.java graal/GraalCompiler/src/com/sun/c1x/ir/Shift.java graal/GraalCompiler/src/com/sun/c1x/ir/UnsignedRightShift.java graal/GraalCompiler/src/com/sun/c1x/ir/Xor.java graal/GraalRuntime/src/com/oracle/graal/runtime/VMExitsNative.java src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java
diffstat 8 files changed, 184 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Tue Jun 07 17:05:13 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Tue Jun 07 19:06:20 2011 +0200
@@ -554,7 +554,18 @@
     private void genShiftOp(CiKind kind, int opcode) {
         Value s = frameState.ipop();
         Value x = frameState.pop(kind);
-        frameState.push(kind, append(new Shift(opcode, x, s, graph)));
+        Shift v;
+        switch(opcode){
+            case ISHL:
+            case LSHL: v = new LeftShift(kind, x, s, graph); break;
+            case ISHR:
+            case LSHR: v = new RightShift(kind, x, s, graph); break;
+            case IUSHR:
+            case LUSHR: v = new UnsignedRightShift(kind, x, s, graph); break;
+            default:
+                throw new CiBailout("should not reach");
+        }
+        frameState.push(kind, append(v));
     }
 
     private void genLogicOp(CiKind kind, int opcode) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/LeftShift.java	Tue Jun 07 19:06:20 2011 +0200
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011, 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.sun.c1x.ir;
+
+import com.oracle.graal.graph.*;
+import com.sun.cri.bytecode.*;
+import com.sun.cri.ci.*;
+
+
+public final class LeftShift extends Shift {
+
+    /**
+     * @param opcode
+     * @param kind
+     * @param x
+     * @param y
+     * @param graph
+     */
+    public LeftShift(CiKind kind, Value x, Value y, Graph graph) {
+        super(kind, kind == CiKind.Int ? Bytecodes.ISHL : Bytecodes.LSHL, x, y, graph);
+    }
+
+    @Override
+    public String shortName() {
+        return "<<";
+    }
+
+    @Override
+    public Node copy(Graph into) {
+        LeftShift ls = new LeftShift(kind, null, null, graph());
+        return ls;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/RightShift.java	Tue Jun 07 19:06:20 2011 +0200
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011, 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.sun.c1x.ir;
+
+import com.oracle.graal.graph.*;
+import com.sun.cri.bytecode.*;
+import com.sun.cri.ci.*;
+
+
+public final class RightShift extends Shift {
+
+    /**
+     * @param opcode
+     * @param kind
+     * @param x
+     * @param y
+     * @param graph
+     */
+    public RightShift(CiKind kind, Value x, Value y, Graph graph) {
+        super(kind, kind == CiKind.Int ? Bytecodes.ISHR : Bytecodes.LSHR, x, y, graph);
+    }
+
+    @Override
+    public String shortName() {
+        return ">>";
+    }
+
+    @Override
+    public Node copy(Graph into) {
+        RightShift rs = new RightShift(kind, null, null, graph());
+        return rs;
+    }
+
+}
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Shift.java	Tue Jun 07 17:05:13 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Shift.java	Tue Jun 07 19:06:20 2011 +0200
@@ -24,13 +24,12 @@
 
 import com.oracle.graal.graph.*;
 import com.sun.c1x.debug.*;
-import com.sun.cri.bytecode.*;
 import com.sun.cri.ci.*;
 
 /**
  * The {@code ShiftOp} class represents shift operations.
  */
-public final class Shift extends Binary {
+public abstract class Shift extends Binary {
 
     private static final int INPUT_COUNT = 0;
     private static final int SUCCESSOR_COUNT = 0;
@@ -41,12 +40,8 @@
      * @param x the first input value
      * @param y the second input value
      */
-    public Shift(int opcode, Value x, Value y, Graph graph) {
-        super(x.kind, opcode, x, y, INPUT_COUNT, SUCCESSOR_COUNT, graph);
-    }
-
-    private Shift(CiKind kind, int opcode, Graph graph) {
-        super(kind, opcode, null, null, INPUT_COUNT, SUCCESSOR_COUNT, graph);
+    public Shift(CiKind kind, int opcode, Value x, Value y, Graph graph) {
+        super(kind, opcode, x, y, INPUT_COUNT, SUCCESSOR_COUNT, graph);
     }
 
     @Override
@@ -56,12 +51,9 @@
 
     @Override
     public void print(LogStream out) {
-        out.print(x()).print(' ').print(Bytecodes.operator(opcode)).print(' ').print(y());
+        out.print(x()).print(' ').print(this.shortName()).print(' ').print(y());
     }
 
     @Override
-    public Node copy(Graph into) {
-        Shift x = new Shift(kind, opcode, into);
-        return x;
-    }
+    public abstract String shortName();
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/UnsignedRightShift.java	Tue Jun 07 19:06:20 2011 +0200
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011, 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.sun.c1x.ir;
+
+import com.oracle.graal.graph.*;
+import com.sun.cri.bytecode.*;
+import com.sun.cri.ci.*;
+
+
+public final class UnsignedRightShift extends Shift {
+
+    /**
+     * @param opcode
+     * @param kind
+     * @param x
+     * @param y
+     * @param graph
+     */
+    public UnsignedRightShift(CiKind kind, Value x, Value y, Graph graph) {
+        super(kind, kind == CiKind.Int ? Bytecodes.IUSHR : Bytecodes.LUSHR, x, y, graph);
+    }
+
+    @Override
+    public String shortName() {
+        return ">>>";
+    }
+
+    @Override
+    public Node copy(Graph into) {
+        UnsignedRightShift x = new UnsignedRightShift(kind, null, null, graph());
+        return x;
+    }
+
+}
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Xor.java	Tue Jun 07 17:05:13 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Xor.java	Tue Jun 07 19:06:20 2011 +0200
@@ -94,18 +94,12 @@
             } else if (y.isConstant()) {
                 if (kind == CiKind.Int) {
                     int c = y.asConstant().asInt();
-                    if (c == -1) {
-                        return new Negate(x, graph);
-                    }
                     if (c == 0) {
                         return x;
                     }
                 } else {
                     assert kind == CiKind.Long;
                     long c = y.asConstant().asLong();
-                    if (c == -1) {
-                        return new Negate(x, graph);
-                    }
                     if (c == 0) {
                         return x;
                     }
--- a/graal/GraalRuntime/src/com/oracle/graal/runtime/VMExitsNative.java	Tue Jun 07 17:05:13 2011 +0200
+++ b/graal/GraalRuntime/src/com/oracle/graal/runtime/VMExitsNative.java	Tue Jun 07 19:06:20 2011 +0200
@@ -112,7 +112,7 @@
         } catch (Throwable t) {
             StringWriter out = new StringWriter();
             t.printStackTrace(new PrintWriter(out));
-            TTY.println("Compilation interrupted:\n" + out.toString());
+            TTY.println("Compilation interrupted: (" + name + ")\n" + out.toString());
             throw t;
         }
     }
--- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java	Tue Jun 07 17:05:13 2011 +0200
+++ b/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java	Tue Jun 07 19:06:20 2011 +0200
@@ -542,7 +542,10 @@
 
         for (Node n : nodes) {
             InputNode inputNode = n.inputNode;
-            if (inputNode.getProperties().get("name").equals("Root")) {
+            if(inputNode.getProperties().get("name") == null) {
+                System.out.println("NO name !! " + inputNode);
+            }
+            if (inputNode != null && inputNode.getProperties().get("name") != null && inputNode.getProperties().get("name").equals("Root")) {
                 return n;
             } else if (inputNode.getId() == 0) {
                 // use as fallback in case no root node is found