# HG changeset patch # User Doug Simon # Date 1365119630 -7200 # Node ID bea614953503c0d2249aa2fc81dbb9e51b0d28dd # Parent 0235a32308773f6b1810f73ca9a7def0f95f9c4a 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 diff -r 0235a3230877 -r bea614953503 graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java --- 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"); } diff -r 0235a3230877 -r bea614953503 graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java --- 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 } diff -r 0235a3230877 -r bea614953503 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java --- 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); diff -r 0235a3230877 -r bea614953503 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java --- 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(); } } diff -r 0235a3230877 -r bea614953503 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadExceptionObjectNode.java --- /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); + } +} diff -r 0235a3230877 -r bea614953503 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java --- 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);