Mercurial > hg > graal-compiler
comparison graal/GraalCompiler/src/com/sun/c1x/ir/Throw.java @ 2509:16b9a8b5ad39
Renamings Runtime=>GraalRuntime and Compiler=>GraalCompiler
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 27 Apr 2011 11:50:44 +0200 |
parents | graal/Compiler/src/com/sun/c1x/ir/Throw.java@9ec15d6914ca |
children | 0c6564c254af |
comparison
equal
deleted
inserted
replaced
2508:fea94949e0a2 | 2509:16b9a8b5ad39 |
---|---|
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.sun.c1x.debug.*; | |
26 import com.sun.c1x.value.*; | |
27 import com.sun.cri.ci.*; | |
28 | |
29 /** | |
30 * The {@code Throw} instruction represents a throw of an exception. | |
31 * | |
32 * @author Ben L. Titzer | |
33 */ | |
34 public final class Throw extends BlockEnd { | |
35 | |
36 Value exception; | |
37 | |
38 FrameState stateBefore; | |
39 | |
40 /** | |
41 * Creates a new Throw instruction. | |
42 * @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 | |
44 * @param isSafepoint {@code true} if this instruction is a safepoint instruction | |
45 */ | |
46 public Throw(Value exception, FrameState stateAfter, boolean isSafepoint) { | |
47 super(CiKind.Illegal, null, isSafepoint); | |
48 this.stateBefore = stateAfter; | |
49 this.exception = 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 } | |
59 | |
60 /** | |
61 * Returns the state before this throw would occur. | |
62 * @return the state before the throw | |
63 */ | |
64 @Override | |
65 public FrameState stateBefore() { | |
66 return stateBefore; | |
67 } | |
68 | |
69 /** | |
70 * Checks whether this instruction can trap. | |
71 * @return {@code true} because this instruction definitely throws an exception! | |
72 */ | |
73 @Override | |
74 public boolean canTrap() { | |
75 return true; | |
76 } | |
77 | |
78 @Override | |
79 public void inputValuesDo(ValueClosure closure) { | |
80 exception = closure.apply(exception); | |
81 } | |
82 | |
83 @Override | |
84 public void accept(ValueVisitor v) { | |
85 v.visitThrow(this); | |
86 } | |
87 | |
88 @Override | |
89 public void print(LogStream out) { | |
90 out.print("throw ").print(exception()); | |
91 } | |
92 } |