changeset 2715:3ac3dd97d8df

Added ExceptionEdgeInstruction interface.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Thu, 19 May 2011 13:21:31 +0200
parents e235eb9e7b54
children c1a9bf38da28
files graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinter.java graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java graal/GraalCompiler/src/com/sun/c1x/ir/ExceptionEdgeInstruction.java graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java graal/GraalCompiler/src/com/sun/c1x/ir/Throw.java
diffstat 8 files changed, 37 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- 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<BlockBegin> successors = block.end() != null ? block.end().blockSuccessors() : new ArrayList<BlockBegin>(0);
-                printBlock(block, successors, block.exceptionEdge(), printHIR, printLIR);
+                printBlock(block, successors, null, printHIR, printLIR);
             }
         });
         end("cfg");
--- 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<CiValue> visitInvokeArguments(CiCallingConvention cc, Invoke x, List<CiValue> pointerSlots) {
--- 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);
         }
--- 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<BlockBegin> excBlocks = new ArrayList<BlockBegin>();
             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());
             }
         }
     }
--- /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();
+}
--- 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;
-    }
 }
--- 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;
 
--- 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;