comparison graal/GraalCompiler/src/com/sun/c1x/ir/Throw.java @ 2602:0c6564c254af

new node layout: BlockBegin, BlockEnd -Dc1x.dot=regex for pdf output escape dot graph labels (<, >, &)
author Lukas Stadler <lukas.stadler@jku.at>
date Fri, 06 May 2011 10:25:37 +0200
parents 16b9a8b5ad39
children 3558ca7088c0
comparison
equal deleted inserted replaced
2601:224e8b4007bd 2602:0c6564c254af
20 * or visit www.oracle.com if you need additional information or have any 20 * or visit www.oracle.com if you need additional information or have any
21 * questions. 21 * questions.
22 */ 22 */
23 package com.sun.c1x.ir; 23 package com.sun.c1x.ir;
24 24
25 import com.oracle.graal.graph.*;
25 import com.sun.c1x.debug.*; 26 import com.sun.c1x.debug.*;
26 import com.sun.c1x.value.*; 27 import com.sun.c1x.value.*;
27 import com.sun.cri.ci.*; 28 import com.sun.cri.ci.*;
28 29
29 /** 30 /**
30 * The {@code Throw} instruction represents a throw of an exception. 31 * The {@code Throw} instruction represents a throw of an exception.
31 *
32 * @author Ben L. Titzer
33 */ 32 */
34 public final class Throw extends BlockEnd { 33 public final class Throw extends BlockEnd {
35 34
36 Value exception; 35 private static final int INPUT_COUNT = 1;
36 private static final int INPUT_EXCEPTION = 0;
37
38 private static final int SUCCESSOR_COUNT = 0;
39
40 @Override
41 protected int inputCount() {
42 return super.inputCount() + INPUT_COUNT;
43 }
44
45 @Override
46 protected int successorCount() {
47 return super.successorCount() + SUCCESSOR_COUNT;
48 }
49
50 /**
51 * The instruction which produces the exception to throw.
52 */
53 public Value exception() {
54 return (Value) inputs().get(super.inputCount() + INPUT_EXCEPTION);
55 }
56
57 public Value setException(Value n) {
58 return (Value) inputs().set(super.inputCount() + INPUT_EXCEPTION, n);
59 }
37 60
38 FrameState stateBefore; 61 FrameState stateBefore;
39 62
40 /** 63 /**
41 * Creates a new Throw instruction. 64 * Creates a new Throw instruction.
42 * @param exception the instruction that generates the exception to throw 65 * @param exception the instruction that generates the exception to throw
43 * @param stateAfter the state before the exception is thrown but after the exception object has been popped 66 * @param stateAfter the state before the exception is thrown but after the exception object has been popped
44 * @param isSafepoint {@code true} if this instruction is a safepoint instruction 67 * @param isSafepoint {@code true} if this instruction is a safepoint instruction
68 * @param graph
45 */ 69 */
46 public Throw(Value exception, FrameState stateAfter, boolean isSafepoint) { 70 public Throw(Value exception, FrameState stateAfter, boolean isSafepoint, Graph graph) {
47 super(CiKind.Illegal, null, isSafepoint); 71 super(CiKind.Illegal, null, isSafepoint, 0, INPUT_COUNT, SUCCESSOR_COUNT, graph);
48 this.stateBefore = stateAfter; 72 this.stateBefore = stateAfter;
49 this.exception = exception; 73 setException(exception);
50 }
51
52 /**
53 * Gets the instruction which produces the exception to throw.
54 * @return the instruction producing the exception
55 */
56 public Value exception() {
57 return exception;
58 } 74 }
59 75
60 /** 76 /**
61 * Returns the state before this throw would occur. 77 * Returns the state before this throw would occur.
62 * @return the state before the throw 78 * @return the state before the throw
74 public boolean canTrap() { 90 public boolean canTrap() {
75 return true; 91 return true;
76 } 92 }
77 93
78 @Override 94 @Override
79 public void inputValuesDo(ValueClosure closure) {
80 exception = closure.apply(exception);
81 }
82
83 @Override
84 public void accept(ValueVisitor v) { 95 public void accept(ValueVisitor v) {
85 v.visitThrow(this); 96 v.visitThrow(this);
86 } 97 }
87 98
88 @Override 99 @Override