Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeInvoke.java @ 1913:3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
Summary: Allow CONSTANT_InvokeDynamic nodes to have any number of extra operands.
Reviewed-by: twisti
author | jrose |
---|---|
date | Sat, 30 Oct 2010 13:08:23 -0700 |
parents | 136b78722a08 |
children | 0a8e0d4345b3 |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
2 * Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.interpreter; | |
26 | |
27 import sun.jvm.hotspot.oops.*; | |
28 import sun.jvm.hotspot.runtime.*; | |
29 import sun.jvm.hotspot.utilities.*; | |
30 | |
31 public class BytecodeInvoke extends BytecodeWithCPIndex { | |
32 BytecodeInvoke(Method method, int bci) { | |
33 super(method, bci); | |
34 } | |
35 | |
36 public static BytecodeInvoke at(Method method, int bci) { | |
37 BytecodeInvoke b = new BytecodeInvoke(method, bci); | |
38 if (Assert.ASSERTS_ENABLED) { | |
39 b.verify(); | |
40 } | |
41 return b; | |
42 } | |
43 | |
44 /** Like at, but returns null if the BCI is not at an invoke */ | |
45 public static BytecodeInvoke atCheck(Method method, int bci) { | |
46 BytecodeInvoke b = new BytecodeInvoke(method, bci); | |
47 return (b.isValid() ? b : null); | |
48 } | |
49 | |
50 public static BytecodeInvoke at(BytecodeStream bcs) { | |
51 return new BytecodeInvoke(bcs.method(), bcs.bci()); | |
52 } | |
53 | |
54 // returns the name of the invoked method | |
55 public Symbol name() { | |
56 ConstantPool cp = method().getConstants(); | |
1602 | 57 if (isInvokedynamic()) { |
58 int[] nt = cp.getNameAndTypeAt(indexForFieldOrMethod()); | |
59 return cp.getSymbolAt(nt[0]); | |
60 } | |
0 | 61 return cp.getNameRefAt(index()); |
62 } | |
63 | |
64 // returns the signature of the invoked method | |
65 public Symbol signature() { | |
66 ConstantPool cp = method().getConstants(); | |
1602 | 67 if (isInvokedynamic()) { |
68 int[] nt = cp.getNameAndTypeAt(indexForFieldOrMethod()); | |
69 return cp.getSymbolAt(nt[1]); | |
70 } | |
0 | 71 return cp.getSignatureRefAt(index()); |
72 } | |
73 | |
1602 | 74 public int getSecondaryIndex() { |
75 if (isInvokedynamic()) { | |
76 // change byte-ordering of 4-byte integer | |
77 return VM.getVM().getBytes().swapInt(javaSignedWordAt(1)); | |
78 } | |
79 return super.getSecondaryIndex(); // throw an error | |
80 } | |
81 | |
0 | 82 public Method getInvokedMethod() { |
83 return method().getConstants().getMethodRefAt(index()); | |
84 } | |
85 | |
86 // returns the result type (see BasicType.java) of the invoke | |
87 public int resultType() { | |
88 ResultTypeFinder rts = new ResultTypeFinder(signature()); | |
89 rts.iterate(); | |
90 return rts.type(); | |
91 } | |
92 | |
93 public int adjustedInvokeCode() { | |
94 return javaCode(); | |
95 } | |
96 | |
97 // "specified" method (from constant pool) | |
98 // FIXME: elided for now | |
99 // public Method staticTarget(); | |
100 | |
101 // Testers | |
102 public boolean isInvokeinterface() { return adjustedInvokeCode() == Bytecodes._invokeinterface; } | |
103 public boolean isInvokevirtual() { return adjustedInvokeCode() == Bytecodes._invokevirtual; } | |
104 public boolean isInvokestatic() { return adjustedInvokeCode() == Bytecodes._invokestatic; } | |
105 public boolean isInvokespecial() { return adjustedInvokeCode() == Bytecodes._invokespecial; } | |
1602 | 106 public boolean isInvokedynamic() { return adjustedInvokeCode() == Bytecodes._invokedynamic; } |
0 | 107 |
108 public boolean isValid() { return isInvokeinterface() || | |
109 isInvokevirtual() || | |
110 isInvokestatic() || | |
111 isInvokespecial(); } | |
112 public void verify() { | |
113 if (Assert.ASSERTS_ENABLED) { | |
114 Assert.that(isValid(), "check invoke"); | |
115 } | |
116 } | |
117 | |
118 public String toString() { | |
119 StringBuffer buf = new StringBuffer(); | |
120 buf.append(getJavaBytecodeName()); | |
121 buf.append(spaces); | |
122 buf.append('#'); | |
123 buf.append(Integer.toString(indexForFieldOrMethod())); | |
1602 | 124 if (isInvokedynamic()) { |
125 buf.append('('); | |
126 buf.append(Integer.toString(getSecondaryIndex())); | |
127 buf.append(')'); | |
128 } | |
0 | 129 buf.append(" [Method "); |
130 StringBuffer sigBuf = new StringBuffer(); | |
131 new SignatureConverter(signature(), sigBuf).iterateReturntype(); | |
132 buf.append(sigBuf.toString().replace('/', '.')); | |
133 buf.append(spaces); | |
134 buf.append(name().asString()); | |
135 buf.append('('); | |
136 sigBuf = new StringBuffer(); | |
137 new SignatureConverter(signature(), sigBuf).iterateParameters(); | |
138 buf.append(sigBuf.toString().replace('/', '.')); | |
139 buf.append(')'); | |
140 buf.append(']'); | |
141 if (code() != javaCode()) { | |
142 buf.append(spaces); | |
143 buf.append('['); | |
144 buf.append(getBytecodeName()); | |
145 buf.append(']'); | |
146 } | |
147 return buf.toString(); | |
148 } | |
149 } |