Mercurial > hg > graal-compiler
comparison graal/GraalCompiler/src/com/sun/c1x/ir/ExceptionDispatch.java @ 2707:7ed72769d51a
exception handling related changes:
* changed blockPredecessors to list of Instructions, instead of Blocks
* removed explicit predecessor management in BlockBegin, now using predecessors from Graph structure
* replaced generated LIR exception entries with exception dispatch chains in IR
* added Unwind and ExceptionDispatch instructions
* removed ExceptionEntry flag in BlockBegin and all code depending on it
* removed exceptionHandler list from Instruction, replaced by exception Edge on Invoke and Throw
* replaced list of ExceptionHandlers with single exception edge in debug info
misc:
* changed GraphvizPrinter layout (smaller ports on large nodes)
* removed defunct run config
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Wed, 18 May 2011 18:09:20 +0200 |
parents | |
children | a0dd2b907806 |
comparison
equal
deleted
inserted
replaced
2677:0ea5f12e873a | 2707:7ed72769d51a |
---|---|
1 /* | |
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.sun.c1x.ir; | |
24 | |
25 import com.oracle.graal.graph.*; | |
26 import com.sun.c1x.debug.*; | |
27 import com.sun.c1x.value.*; | |
28 import com.sun.cri.ci.*; | |
29 | |
30 /** | |
31 * This instruction takes an exception object and has two successors: | |
32 * The catchSuccessor is called whenever the exception matches the given type, otherwise otherSuccessor is called. | |
33 */ | |
34 public final class ExceptionDispatch extends BlockEnd { | |
35 | |
36 private static final int INPUT_COUNT = 1; | |
37 private static final int INPUT_EXCEPTION = 0; | |
38 | |
39 private static final int SUCCESSOR_COUNT = 0; | |
40 | |
41 @Override | |
42 protected int inputCount() { | |
43 return super.inputCount() + INPUT_COUNT; | |
44 } | |
45 | |
46 @Override | |
47 protected int successorCount() { | |
48 return super.successorCount() + SUCCESSOR_COUNT; | |
49 } | |
50 | |
51 /** | |
52 * The instruction producing the exception object. | |
53 */ | |
54 public Value exception() { | |
55 return (Value) inputs().get(super.inputCount() + INPUT_EXCEPTION); | |
56 } | |
57 | |
58 public Value setException(Value n) { | |
59 return (Value) inputs().set(super.inputCount() + INPUT_EXCEPTION, n); | |
60 } | |
61 | |
62 private final ExceptionHandler handler; | |
63 | |
64 /** | |
65 * Constructs a new ExceptionDispatch instruction. | |
66 */ | |
67 public ExceptionDispatch(Value exception, BlockBegin catchSuccessor, BlockBegin otherSuccessor, ExceptionHandler handler, FrameState stateAfter, boolean isSafepoint, Graph graph) { | |
68 super(CiKind.Int, stateAfter, isSafepoint, 2, INPUT_COUNT, SUCCESSOR_COUNT, graph); | |
69 setException(exception); | |
70 setBlockSuccessor(0, otherSuccessor); | |
71 setBlockSuccessor(1, catchSuccessor); | |
72 this.handler = handler; | |
73 } | |
74 | |
75 public ExceptionHandler handler() { | |
76 return handler; | |
77 } | |
78 | |
79 /** | |
80 * Gets the block corresponding to the catch block. | |
81 * @return the true successor | |
82 */ | |
83 public BlockBegin catchSuccessor() { | |
84 return blockSuccessor(1); | |
85 } | |
86 | |
87 /** | |
88 * Gets the block corresponding to the rest of the dispatch chain. | |
89 * @return the false successor | |
90 */ | |
91 public BlockBegin otherSuccessor() { | |
92 return blockSuccessor(0); | |
93 } | |
94 | |
95 /** | |
96 * Gets the block corresponding to the specified outcome of the branch. | |
97 * @param istrue {@code true} if the true successor is requested, {@code false} otherwise | |
98 * @return the corresponding successor | |
99 */ | |
100 public BlockBegin successor(boolean istrue) { | |
101 return blockSuccessor(istrue ? 1 : 0); | |
102 } | |
103 | |
104 /** | |
105 * Swaps the successor blocks to this if and negates the condition (e.g. == goes to !=) | |
106 * @see Condition#negate() | |
107 */ | |
108 public void swapSuccessors() { | |
109 BlockBegin t = blockSuccessor(0); | |
110 BlockBegin f = blockSuccessor(1); | |
111 setBlockSuccessor(0, f); | |
112 setBlockSuccessor(1, t); | |
113 } | |
114 | |
115 @Override | |
116 public void accept(ValueVisitor v) { | |
117 v.visitExceptionDispatch(this); | |
118 } | |
119 | |
120 @Override | |
121 public void print(LogStream out) { | |
122 out.print("exception_dispatch "). | |
123 print(exception()). | |
124 print(' '). | |
125 print("instanceof"). | |
126 print(' '). | |
127 print(handler.handler.catchType().name()). | |
128 print(" then B"). | |
129 print(blockSuccessors().get(1).blockID). | |
130 print(" else B"). | |
131 print(blockSuccessors().get(0).blockID); | |
132 if (isSafepoint()) { | |
133 out.print(" (safepoint)"); | |
134 } | |
135 } | |
136 | |
137 @Override | |
138 public String shortName() { | |
139 return "Dispatch " + handler.handler.catchType().name(); | |
140 } | |
141 | |
142 | |
143 } |