changeset 5241:e24167877471

conditional support for translating ExceptionObjectNode without XIR
author Doug Simon <doug.simon@oracle.com>
date Fri, 13 Apr 2012 15:31:41 +0200
parents ec177db4a412
children f46d82be6e19
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/HotSpotExceptionObject.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java
diffstat 3 files changed, 73 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/HotSpotExceptionObject.java	Fri Apr 13 15:31:41 2012 +0200
@@ -0,0 +1,53 @@
+/*
+ * 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);
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java	Fri Apr 13 15:28:54 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java	Fri Apr 13 15:31:41 2012 +0200
@@ -59,6 +59,8 @@
     private final HotSpotRegisterConfig globalStubRegConfig;
     private final Compiler compiler;
 
+    private static final boolean ExceptionObjectWithoutXIR = Boolean.getBoolean("ExceptionObjectWithoutXIR");
+
     public HotSpotRuntime(HotSpotVMConfig config, Compiler compiler) {
         this.config = config;
         this.compiler = compiler;
@@ -162,6 +164,8 @@
                     append(e.pcOffset).append(" -> ").
                     append(e.handlerPos).
                     append(nl);
+                hcf.addComment(e.pcOffset, "[exception -> " + e.handlerPos + "]");
+                hcf.addComment(e.handlerPos, "[exception handler for " + e.pcOffset + "]");
             }
             hcf.addComment(0, buf.toString());
         }
@@ -387,6 +391,14 @@
             ReadNode memoryRead = graph.add(new ReadNode(objectClassNode.object(), location, StampFactory.objectNonNull()));
             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) {
+                ExceptionObjectNode exceptionObjectNode = (ExceptionObjectNode) n;
+                HotSpotExceptionObject exceptionObject = graph.add(new HotSpotExceptionObject(config.threadExceptionOopOffset, config.threadExceptionPcOffset));
+                graph.replaceFixedWithFixed(exceptionObjectNode, exceptionObject);
+            }
+        } else {
+            assert false : "Node implementing Lowerable not handled: " + n;
         }
     }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java	Fri Apr 13 15:28:54 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java	Fri Apr 13 15:31:41 2012 +0200
@@ -22,16 +22,17 @@
  */
 package com.oracle.graal.nodes.java;
 
-import com.oracle.max.cri.ci.*;
+import com.oracle.graal.cri.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
+import com.oracle.max.cri.ci.*;
 
 /**
  * The {@code ExceptionObject} instruction represents the incoming exception object to an exception handler.
  */
-public final class ExceptionObjectNode extends AbstractStateSplit implements LIRLowerable, MemoryCheckpoint {
+public class ExceptionObjectNode extends AbstractStateSplit implements Lowerable, LIRLowerable, MemoryCheckpoint {
 
     /**
      * Constructs a new ExceptionObject instruction.
@@ -41,6 +42,11 @@
     }
 
     @Override
+    public void lower(CiLoweringTool tool) {
+        tool.getRuntime().lower(this, tool);
+    }
+
+    @Override
     public void generate(LIRGeneratorTool gen) {
         gen.visitExceptionObject(this);
     }