changeset 8641:bea614953503

split the ExceptionObjectNode into two nodes during lowering; the original node remains to denote the entry to an exception handler and a new LoadExceptionObjectNode is placed after it to load the exception object
author Doug Simon <doug.simon@oracle.com>
date Fri, 05 Apr 2013 01:53:50 +0200
parents 0235a3230877
children 1093255fd0d4
files graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadExceptionObjectNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java
diffstat 6 files changed, 63 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java	Fri Apr 05 01:51:24 2013 +0200
+++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java	Fri Apr 05 01:53:50 2013 +0200
@@ -458,7 +458,7 @@
     }
 
     @Override
-    public void visitExceptionObject(ExceptionObjectNode i) {
+    public void visitLoadException(LoadExceptionObjectNode i) {
         throw new InternalError("NYI");
     }
 
--- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java	Fri Apr 05 01:51:24 2013 +0200
+++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java	Fri Apr 05 01:53:50 2013 +0200
@@ -346,7 +346,7 @@
     }
 
     @Override
-    public void visitExceptionObject(ExceptionObjectNode i) {
+    public void visitLoadException(LoadExceptionObjectNode i) {
         // SPARC: Auto-generated method stub
 
     }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Fri Apr 05 01:51:24 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Fri Apr 05 01:53:50 2013 +0200
@@ -166,7 +166,7 @@
     }
 
     @Override
-    public void visitExceptionObject(ExceptionObjectNode x) {
+    public void visitLoadException(LoadExceptionObjectNode x) {
         HotSpotVMConfig config = runtime().config;
         RegisterValue thread = runtime().threadRegister().asValue();
         Value exception = emitLoad(Kind.Object, thread, config.threadExceptionOopOffset, Value.ILLEGAL, 0, false);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java	Fri Apr 05 01:51:24 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java	Fri Apr 05 01:53:50 2013 +0200
@@ -29,14 +29,11 @@
 import com.oracle.graal.nodes.type.*;
 
 /**
- * The {@code ExceptionObject} instruction represents the incoming exception object to an exception
- * handler.
+ * The entry to an exception handler with the exception coming from a call (as opposed to a local
+ * throw instruction or implicit exception).
  */
-public class ExceptionObjectNode extends DispatchBeginNode implements Lowerable, LIRLowerable, MemoryCheckpoint {
+public class ExceptionObjectNode extends DispatchBeginNode implements Lowerable, MemoryCheckpoint {
 
-    /**
-     * Constructs a new ExceptionObject instruction.
-     */
     public ExceptionObjectNode(MetaAccessProvider runtime) {
         super(StampFactory.declared(runtime.lookupJavaType(Throwable.class)));
     }
@@ -47,23 +44,25 @@
     }
 
     @Override
-    public void generate(LIRGeneratorTool gen) {
-        gen.visitExceptionObject(this);
-    }
-
-    @Override
-    public void lower(LoweringTool tool) {
-        tool.getRuntime().lower(this, tool);
-    }
-
-    @Override
     public void simplify(SimplifierTool tool) {
         //
     }
 
     @Override
+    public void lower(LoweringTool tool) {
+        StructuredGraph graph = (StructuredGraph) graph();
+        LoadExceptionObjectNode loadException = graph.add(new LoadExceptionObjectNode(stamp()));
+        loadException.setStateAfter(stateAfter());
+        replaceAtUsages(loadException);
+        graph.addAfterFixed(this, loadException);
+        tool.setLastFixedNode(loadException);
+        setStateAfter(null);
+        setStamp(StampFactory.forVoid());
+    }
+
+    @Override
     public boolean verify() {
-        assertTrue(stateAfter() != null, "an exception handler needs a frame state");
+        assertTrue(stateAfter() != null || stamp() == StampFactory.forVoid(), "an exception handler needs a frame state");
         return super.verify();
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadExceptionObjectNode.java	Fri Apr 05 01:53:50 2013 +0200
@@ -0,0 +1,43 @@
+/*
+ * 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.nodes.java;
+
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
+
+/**
+ * Loads an exception object passed by the runtime from a callee to an exception handler in a
+ * caller. The node is only produced when lowering an {@link ExceptionObjectNode}.
+ */
+public class LoadExceptionObjectNode extends AbstractStateSplit implements LIRLowerable {
+
+    public LoadExceptionObjectNode(Stamp stamp) {
+        super(stamp);
+    }
+
+    @Override
+    public void generate(LIRGeneratorTool gen) {
+        gen.visitLoadException(this);
+    }
+}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java	Fri Apr 05 01:51:24 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java	Fri Apr 05 01:53:50 2013 +0200
@@ -123,7 +123,7 @@
     public abstract void visitCompareAndSwap(CompareAndSwapNode i);
 
     // These methods define the contract a runtime specific backend must provide.
-    public abstract void visitExceptionObject(ExceptionObjectNode i);
+    public abstract void visitLoadException(LoadExceptionObjectNode i);
 
     public abstract void visitReturn(ReturnNode i);