# HG changeset patch # User Thomas Wuerthinger # Date 1305804091 -7200 # Node ID 3ac3dd97d8df385638d6aed85a841552ba770259 # Parent e235eb9e7b54520812659d9b6c4fecd9a6045d3a Added ExceptionEdgeInstruction interface. diff -r e235eb9e7b54 -r 3ac3dd97d8df graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinter.java --- a/graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinter.java Thu May 19 13:14:02 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinter.java Thu May 19 13:21:31 2011 +0200 @@ -569,7 +569,7 @@ startBlock.iteratePreOrder(new BlockClosure() { public void apply(BlockBegin block) { List successors = block.end() != null ? block.end().blockSuccessors() : new ArrayList(0); - printBlock(block, successors, block.exceptionEdge(), printHIR, printLIR); + printBlock(block, successors, null, printHIR, printLIR); } }); end("cfg"); diff -r e235eb9e7b54 -r 3ac3dd97d8df graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java --- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Thu May 19 13:14:02 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Thu May 19 13:21:31 2011 +0200 @@ -1437,7 +1437,7 @@ } assert state != null; - return new LIRDebugInfo(state, x.exceptionEdge()); + return new LIRDebugInfo(state, (x instanceof ExceptionEdgeInstruction) ? ((ExceptionEdgeInstruction) x).exceptionEdge() : null); } List visitInvokeArguments(CiCallingConvention cc, Invoke x, List pointerSlots) { diff -r e235eb9e7b54 -r 3ac3dd97d8df graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Thu May 19 13:14:02 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Thu May 19 13:21:31 2011 +0200 @@ -1066,7 +1066,7 @@ throw new CiBailout("Method and/or inlining is too large"); } - if (x instanceof Invoke || x instanceof Throw) { + if (x instanceof ExceptionEdgeInstruction) { // connect the instruction to any exception handlers handleException(x, bci); } diff -r e235eb9e7b54 -r 3ac3dd97d8df graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java Thu May 19 13:14:02 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java Thu May 19 13:21:31 2011 +0200 @@ -246,10 +246,8 @@ Instruction inst = block; ArrayList excBlocks = new ArrayList(); while (inst != null) { - if (inst instanceof Invoke) { - excBlocks.add(((Invoke) inst).exceptionEdge()); - } else if (inst instanceof Throw) { - excBlocks.add(((Throw) inst).exceptionEdge()); + if (inst instanceof ExceptionEdgeInstruction) { + excBlocks.add(((ExceptionEdgeInstruction) inst).exceptionEdge()); } inst = inst.next(); } @@ -703,10 +701,8 @@ } } for (Instruction x = next(); x != null; x = x.next()) { - if (x instanceof Invoke && ((Invoke) x).exceptionEdge() != null) { - closure.apply(((Invoke) x).exceptionEdge()); - } else if (x instanceof Throw && ((Throw) x).exceptionEdge() != null) { - closure.apply(((Throw) x).exceptionEdge()); + if (x instanceof ExceptionEdgeInstruction && ((ExceptionEdgeInstruction) x).exceptionEdge() != null) { + closure.apply(((ExceptionEdgeInstruction) x).exceptionEdge()); } } } diff -r e235eb9e7b54 -r 3ac3dd97d8df graal/GraalCompiler/src/com/sun/c1x/ir/ExceptionEdgeInstruction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ExceptionEdgeInstruction.java Thu May 19 13:21:31 2011 +0200 @@ -0,0 +1,28 @@ +/* + * 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; + + +public interface ExceptionEdgeInstruction { + BlockBegin exceptionEdge(); +} diff -r e235eb9e7b54 -r 3ac3dd97d8df graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java Thu May 19 13:14:02 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java Thu May 19 13:21:31 2011 +0200 @@ -166,23 +166,6 @@ } /** - * Gets the name of this instruction as a string. - * @return the name of this instruction - */ - public final String name() { - return getClass().getSimpleName(); - } - - /** - * Apply the specified closure to all the values of this instruction, including - * input values, state values, and other values. - * @param closure the closure to apply - */ - public final void allValuesDo(ValueClosure closure) { - inputValuesDo(closure); - } - - /** * Gets the state after the instruction, if it is recorded. Typically only * instances of {@link BlockEnd} have a non-null state after. * @return the state after the instruction @@ -190,8 +173,4 @@ public FrameState stateAfter() { return null; } - - public BlockBegin exceptionEdge() { - return null; - } } diff -r e235eb9e7b54 -r 3ac3dd97d8df graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java Thu May 19 13:14:02 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java Thu May 19 13:21:31 2011 +0200 @@ -32,7 +32,7 @@ /** * The {@code Invoke} instruction represents all kinds of method calls. */ -public final class Invoke extends StateSplit { +public final class Invoke extends StateSplit implements ExceptionEdgeInstruction { private final int argumentCount; diff -r e235eb9e7b54 -r 3ac3dd97d8df graal/GraalCompiler/src/com/sun/c1x/ir/Throw.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Throw.java Thu May 19 13:14:02 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Throw.java Thu May 19 13:21:31 2011 +0200 @@ -30,7 +30,7 @@ /** * The {@code Throw} instruction represents a throw of an exception. */ -public final class Throw extends BlockEnd { +public final class Throw extends BlockEnd implements ExceptionEdgeInstruction { private static final int INPUT_COUNT = 2; private static final int INPUT_EXCEPTION = 0;