Mercurial > hg > graal-compiler
comparison graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.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/Invoke.java@9ec15d6914ca |
children | e1ba5a93e997 |
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.util.*; | |
27 import com.sun.c1x.value.*; | |
28 import com.sun.cri.ci.*; | |
29 import com.sun.cri.ri.*; | |
30 | |
31 /** | |
32 * The {@code Invoke} instruction represents all kinds of method calls. | |
33 * | |
34 * @author Ben L. Titzer | |
35 */ | |
36 public final class Invoke extends StateSplit { | |
37 | |
38 public final int opcode; | |
39 public final Value[] arguments; | |
40 public final RiMethod target; | |
41 public final RiType returnType; | |
42 | |
43 /** | |
44 * Constructs a new Invoke instruction. | |
45 * | |
46 * @param opcode the opcode of the invoke | |
47 * @param result the result type | |
48 * @param args the list of instructions producing arguments to the invocation, including the receiver object | |
49 * @param isStatic {@code true} if this call is static (no receiver object) | |
50 * @param target the target method being called | |
51 * @param stateBefore the state before executing the invocation | |
52 */ | |
53 public Invoke(int opcode, CiKind result, Value[] args, boolean isStatic, RiMethod target, RiType returnType, FrameState stateBefore) { | |
54 super(result, stateBefore); | |
55 this.opcode = opcode; | |
56 this.arguments = args; | |
57 this.target = target; | |
58 this.returnType = returnType; | |
59 if (isStatic) { | |
60 setFlag(Flag.IsStatic); | |
61 eliminateNullCheck(); | |
62 } else if (args[0].isNonNull() || args[0].kind.isWord()) { | |
63 eliminateNullCheck(); | |
64 } | |
65 } | |
66 | |
67 /** | |
68 * Gets the opcode of this invoke instruction. | |
69 * @return the opcode | |
70 */ | |
71 public int opcode() { | |
72 return opcode; | |
73 } | |
74 | |
75 /** | |
76 * Checks whether this is an invocation of a static method. | |
77 * @return {@code true} if the invocation is a static invocation | |
78 */ | |
79 public boolean isStatic() { | |
80 return checkFlag(Flag.IsStatic); | |
81 } | |
82 | |
83 @Override | |
84 public RiType declaredType() { | |
85 return returnType; | |
86 } | |
87 | |
88 /** | |
89 * Gets the instruction that produces the receiver object for this invocation, if any. | |
90 * @return the instruction that produces the receiver object for this invocation if any, {@code null} if this | |
91 * invocation does not take a receiver object | |
92 */ | |
93 public Value receiver() { | |
94 assert !isStatic(); | |
95 return arguments[0]; | |
96 } | |
97 | |
98 /** | |
99 * Gets the target method for this invocation instruction. | |
100 * @return the target method | |
101 */ | |
102 public RiMethod target() { | |
103 return target; | |
104 } | |
105 | |
106 /** | |
107 * Gets the list of instructions that produce input for this instruction. | |
108 * @return the list of instructions that produce input | |
109 */ | |
110 public Value[] arguments() { | |
111 return arguments; | |
112 } | |
113 | |
114 /** | |
115 * Checks whether this instruction can trap. | |
116 * @return {@code true}, conservatively assuming the called method may throw an exception | |
117 */ | |
118 @Override | |
119 public boolean canTrap() { | |
120 return true; | |
121 } | |
122 | |
123 /** | |
124 * Checks whether this invocation has a receiver object. | |
125 * @return {@code true} if this invocation has a receiver object; {@code false} otherwise, if this is a | |
126 * static call | |
127 */ | |
128 public boolean hasReceiver() { | |
129 return !isStatic(); | |
130 } | |
131 | |
132 @Override | |
133 public void inputValuesDo(ValueClosure closure) { | |
134 for (int i = 0; i < arguments.length; i++) { | |
135 Value arg = arguments[i]; | |
136 if (arg != null) { | |
137 arguments[i] = closure.apply(arg); | |
138 assert arguments[i] != null; | |
139 } | |
140 } | |
141 } | |
142 | |
143 @Override | |
144 public void accept(ValueVisitor v) { | |
145 v.visitInvoke(this); | |
146 } | |
147 | |
148 public CiKind[] signature() { | |
149 CiKind receiver = isStatic() ? null : target.holder().kind(); | |
150 return Util.signatureToKinds(target.signature(), receiver); | |
151 } | |
152 | |
153 @Override | |
154 public void print(LogStream out) { | |
155 int argStart = 0; | |
156 if (hasReceiver()) { | |
157 out.print(receiver()).print('.'); | |
158 argStart = 1; | |
159 } | |
160 | |
161 RiMethod target = target(); | |
162 out.print(target.name()).print('('); | |
163 Value[] arguments = arguments(); | |
164 for (int i = argStart; i < arguments.length; i++) { | |
165 if (i > argStart) { | |
166 out.print(", "); | |
167 } | |
168 out.print(arguments[i]); | |
169 } | |
170 out.print(CiUtil.format(") [method: %H.%n(%p):%r]", target, false)); | |
171 } | |
172 } |