changeset 5242:f46d82be6e19

ExceptionObjectNode is now lowered without XIR
author Doug Simon <doug.simon@oracle.com>
date Fri, 13 Apr 2012 23:28:20 +0200
parents e24167877471
children e954395cc873
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoweringPhase.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/HotSpotExceptionObject.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/HotSpotExceptionObjectNode.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotXirGenerator.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/RiXirGenerator.java
diffstat 8 files changed, 73 insertions(+), 82 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Fri Apr 13 15:31:41 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Fri Apr 13 23:28:20 2012 +0200
@@ -586,9 +586,7 @@
 
     @Override
     public void visitExceptionObject(ExceptionObjectNode x) {
-        XirSnippet snippet = xir.genExceptionObject(site(x));
-        LIRDebugInfo info = state();
-        emitXir(snippet, x, info, true);
+        throw new GraalInternalError("Runtime must provide lowering for " + x);
     }
 
     @Override
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoweringPhase.java	Fri Apr 13 15:31:41 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoweringPhase.java	Fri Apr 13 23:28:20 2012 +0200
@@ -27,6 +27,7 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.cfg.*;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.max.cri.ri.*;
 
@@ -67,7 +68,8 @@
         };
         for (Node node : processed) {
             if (node instanceof Lowerable) {
-                assert !(node instanceof FixedNode) || node.predecessor() == null;
+                // TODO (dnsimon) is it safe to replace ExceptionObjectNode with HotSpotExceptionObjectNode?
+                assert !(node instanceof FixedNode) || node instanceof ExceptionObjectNode || node.predecessor() == null;
                 ((Lowerable) node).lower(loweringTool);
             }
         }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/HotSpotExceptionObject.java	Fri Apr 13 15:31:41 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2009, 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.oracle.graal.hotspot.nodes;
-
-import static com.oracle.max.asm.target.amd64.AMD64.*;
-
-import com.oracle.graal.nodes.java.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.max.cri.ci.*;
-
-public final class HotSpotExceptionObject extends ExceptionObjectNode {
-
-    private final int threadExceptionOopOffset;
-    private final int threadExceptionPcOffset;
-
-    public HotSpotExceptionObject(int threadExceptionOopOffset, int threadExceptionPcOffset) {
-        this.threadExceptionOopOffset = threadExceptionOopOffset;
-        this.threadExceptionPcOffset = threadExceptionPcOffset;
-    }
-
-    @Override
-    public void generate(LIRGeneratorTool gen) {
-        CiRegisterValue thread = r15.asValue();
-        CiAddress exceptionAddress = new CiAddress(CiKind.Object, thread, threadExceptionOopOffset);
-        CiAddress pcAddress = new CiAddress(CiKind.Long, thread, threadExceptionPcOffset);
-        CiValue exception = gen.emitLoad(exceptionAddress, false);
-        CiRegisterValue raxException = rax.asValue(CiKind.Object);
-        gen.emitMove(exception, raxException);
-        gen.emitStore(exceptionAddress, CiConstant.NULL_OBJECT, false);
-        gen.emitStore(pcAddress, CiConstant.LONG_0, false);
-        gen.setResult(this, raxException);
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/HotSpotExceptionObjectNode.java	Fri Apr 13 23:28:20 2012 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2009, 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.oracle.graal.hotspot.nodes;
+
+import static com.oracle.max.asm.target.amd64.AMD64.*;
+
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.nodes.java.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.max.cri.ci.*;
+
+public final class HotSpotExceptionObjectNode extends ExceptionObjectNode {
+
+    @Override
+    public void generate(LIRGeneratorTool gen) {
+        HotSpotVMConfig config = CompilerImpl.getInstance().getConfig();
+        CiRegisterValue thread = r15.asValue();
+        CiAddress exceptionAddress = new CiAddress(CiKind.Object, thread, config.threadExceptionOopOffset);
+        CiAddress pcAddress = new CiAddress(CiKind.Long, thread, config.threadExceptionPcOffset);
+        CiValue exception = gen.emitLoad(exceptionAddress, false);
+        gen.emitStore(exceptionAddress, CiConstant.NULL_OBJECT, false);
+        gen.emitStore(pcAddress, CiConstant.LONG_0, false);
+        gen.setResult(this, exception);
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java	Fri Apr 13 15:31:41 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java	Fri Apr 13 23:28:20 2012 +0200
@@ -28,6 +28,7 @@
 import java.util.*;
 
 import com.oracle.graal.compiler.*;
+import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.compiler.phases.*;
 import com.oracle.graal.compiler.phases.PhasePlan.PhasePosition;
 import com.oracle.graal.compiler.target.*;
@@ -59,7 +60,15 @@
     private final HotSpotRegisterConfig globalStubRegConfig;
     private final Compiler compiler;
 
-    private static final boolean ExceptionObjectWithoutXIR = Boolean.getBoolean("ExceptionObjectWithoutXIR");
+    /**
+     * System-property defined constant to select mechanism for specific lowering of an ExceptionObjectNode.
+     * By default, the override of {@link LIRGenerator#visitExceptionObject} in {@link HotSpotAMD64Backend}
+     * is used. This seems to work. The alternative is to replace ExceptionObjecNode with
+     * {@link HotSpotExceptionObjectNode} in {@link LoweringPhase}. This does not seem work - it crashes
+     * the Eclipse DaCapo benchmark. Once it is understood why the latter happens, a permanent choice
+     * can be made as to which lowering mechanism to use.
+     */
+    private static final boolean UseHotSpotExceptionObjectNode = Boolean.getBoolean("UseHotSpotExceptionObjectNode");
 
     public HotSpotRuntime(HotSpotVMConfig config, Compiler compiler) {
         this.config = config;
@@ -392,9 +401,9 @@
             memoryRead.setGuard((GuardNode) tool.createGuard(graph.unique(new NullCheckNode(objectClassNode.object(), false)), RiDeoptReason.NullCheckException, RiDeoptAction.InvalidateReprofile, StructuredGraph.INVALID_GRAPH_ID));
             graph.replaceFixed(objectClassNode, memoryRead);
         } else if (n instanceof ExceptionObjectNode) {
-            if (ExceptionObjectWithoutXIR) {
+            if (UseHotSpotExceptionObjectNode) {
                 ExceptionObjectNode exceptionObjectNode = (ExceptionObjectNode) n;
-                HotSpotExceptionObject exceptionObject = graph.add(new HotSpotExceptionObject(config.threadExceptionOopOffset, config.threadExceptionPcOffset));
+                HotSpotExceptionObjectNode exceptionObject = graph.add(new HotSpotExceptionObjectNode());
                 graph.replaceFixedWithFixed(exceptionObjectNode, exceptionObject);
             }
         } else {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotXirGenerator.java	Fri Apr 13 15:31:41 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotXirGenerator.java	Fri Apr 13 23:28:20 2012 +0200
@@ -102,21 +102,6 @@
         }
     }
 
-    private SimpleTemplates exceptionObjectTemplates = new SimpleTemplates() {
-
-        @Override
-        protected XirTemplate create(CiXirAssembler asm, long flags) {
-            XirOperand result = asm.restart(CiKind.Object);
-            XirOperand thread = asm.createRegisterTemp("thread", target.wordKind, AMD64.r15);
-
-            asm.pload(CiKind.Object, result, thread, asm.i(config.threadExceptionOopOffset), false);
-            asm.pstore(CiKind.Object, thread, asm.i(config.threadExceptionOopOffset), asm.o(null), false);
-            asm.pstore(CiKind.Long, thread, asm.i(config.threadExceptionPcOffset), asm.l(0), false);
-
-            return asm.finishTemplate("exception object");
-        }
-    };
-
     private SimpleTemplates invokeInterfaceTemplates = new SimpleTemplates(NULL_CHECK) {
 
         @Override
@@ -843,11 +828,6 @@
     };
 
     @Override
-    public XirSnippet genExceptionObject(XirSite site) {
-        return new XirSnippet(exceptionObjectTemplates.get(site));
-    }
-
-    @Override
     public XirSnippet genInvokeInterface(XirSite site, XirArgument receiver, RiMethod method) {
         return new XirSnippet(invokeInterfaceTemplates.get(site), receiver, wordArg(0));
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java	Fri Apr 13 15:31:41 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java	Fri Apr 13 23:28:20 2012 +0200
@@ -40,6 +40,7 @@
 import com.oracle.graal.lir.amd64.*;
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.java.*;
 import com.oracle.max.asm.*;
 import com.oracle.max.asm.target.amd64.*;
 import com.oracle.max.asm.target.amd64.AMD64Assembler.ConditionFlag;
@@ -67,6 +68,17 @@
                     }
                 }
             }
+            @Override
+            public void visitExceptionObject(ExceptionObjectNode x) {
+                HotSpotVMConfig config = ((HotSpotRuntime) runtime).config;
+                CiRegisterValue thread = r15.asValue();
+                CiAddress exceptionAddress = new CiAddress(CiKind.Object, thread, config.threadExceptionOopOffset);
+                CiAddress pcAddress = new CiAddress(CiKind.Long, thread, config.threadExceptionPcOffset);
+                CiValue exception = emitLoad(exceptionAddress, false);
+                emitStore(exceptionAddress, CiConstant.NULL_OBJECT, false);
+                emitStore(pcAddress, CiConstant.LONG_0, false);
+                setResult(x, exception);
+            }
         };
     }
 
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/RiXirGenerator.java	Fri Apr 13 15:31:41 2012 +0200
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/RiXirGenerator.java	Fri Apr 13 23:28:20 2012 +0200
@@ -31,8 +31,6 @@
  */
 public interface RiXirGenerator {
 
-    XirSnippet genExceptionObject(XirSite site);
-
     XirSnippet genInvokeInterface(XirSite site, XirArgument receiver, RiMethod method);
 
     XirSnippet genInvokeVirtual(XirSite site, XirArgument receiver, RiMethod method, boolean megamorph);