annotate agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ByteCodeRewriter.java @ 6880:c7957b458bf8

8000818: SA constant pool need to reference to reference map after permgen removal Summary: After permgen removal, constant pool changed to put _ldc and _ldc_w (fast_ldc and fast_ldcw) index to reference map, no longer calculated via constant pool cache. Reviewed-by: coleenp, sspitsyn, dholmes Contributed-by: yumin.qi@oracle.com
author minqi
date Fri, 19 Oct 2012 08:56:57 -0700
parents da91efe96a93
children b8a500a7b9bf 64156d22e49d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 2042
diff changeset
2 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
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: 844
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.tools.jcore;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import sun.jvm.hotspot.interpreter.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.runtime.*;
6880
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
32 import java.security.AccessController;
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
33 import java.security.PrivilegedAction;
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
34 import java.security.AccessControlContext;
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
35 import java.security.PrivilegedExceptionAction;
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
36 import java.security.PrivilegedActionException;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 public class ByteCodeRewriter
a61af66fc99e Initial load
duke
parents:
diff changeset
39 {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 private Method method;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 private ConstantPool cpool;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 private ConstantPoolCache cpCache;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 private byte[] code;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 private Bytes bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 private static final int jintSize = 4;
6880
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
47 public static final boolean DEBUG;
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
48
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
49 static {
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
50 String debug = (String) AccessController.doPrivileged(
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
51 new PrivilegedAction() {
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
52 public Object run() {
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
53 return System.getProperty("sun.jvm.hotspot.tools.jcore.ByteCodeRewriter.DEBUG");
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
54 }
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
55 }
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
56 );
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
57 DEBUG = (debug != null ? debug.equalsIgnoreCase("true") : false);
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
58 }
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
59
0
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 protected void debugMessage(String message) {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 System.out.println(message);
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 public ByteCodeRewriter(Method method, ConstantPool cpool, byte[] code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 this.method = method;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 this.cpool = cpool;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 this.cpCache = cpool.getCache();
a61af66fc99e Initial load
duke
parents:
diff changeset
69 this.code = code;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 this.bytes = VM.getVM().getBytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73
6880
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
74 protected short getConstantPoolIndexFromRefMap(int rawcode, int bci) {
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
75 int refIndex;
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
76 String fmt = Bytecodes.format(rawcode);
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
77 switch (fmt.length()) {
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
78 case 2: refIndex = 0xFF & method.getBytecodeByteArg(bci); break;
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
79 case 3: refIndex = 0xFFFF & bytes.swapShort(method.getBytecodeShortArg(bci)); break;
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
80 default: throw new IllegalArgumentException();
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
81 }
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
82
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
83 return (short)cpool.objectToCPIndex(refIndex);
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
84 }
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
85
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
86 protected short getConstantPoolIndex(int rawcode, int bci) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // get ConstantPool index from ConstantPoolCacheIndex at given bci
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
88 String fmt = Bytecodes.format(rawcode);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
89 int cpCacheIndex;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
90 switch (fmt.length()) {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
91 case 2: cpCacheIndex = method.getBytecodeByteArg(bci); break;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
92 case 3: cpCacheIndex = method.getBytecodeShortArg(bci); break;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
93 case 5:
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
94 if (fmt.indexOf("__") >= 0)
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
95 cpCacheIndex = method.getBytecodeShortArg(bci);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
96 else
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
97 cpCacheIndex = method.getBytecodeIntArg(bci);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
98 break;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
99 default: throw new IllegalArgumentException();
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
100 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
101 if (cpCache == null) {
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
102 return (short) cpCacheIndex;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
103 } else if (fmt.indexOf("JJJJ") >= 0) {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
104 // change byte-ordering and go via secondary cache entry
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 2042
diff changeset
105 throw new InternalError("unimplemented");
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
106 } else if (fmt.indexOf("JJ") >= 0) {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
107 // change byte-ordering and go via cache
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
108 return (short) cpCache.getEntryAt((int) (0xFFFF & bytes.swapShort((short)cpCacheIndex))).getConstantPoolIndex();
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
109 } else if (fmt.indexOf("j") >= 0) {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
110 // go via cache
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
111 return (short) cpCache.getEntryAt((int) (0xFF & cpCacheIndex)).getConstantPoolIndex();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
112 } else {
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
113 return (short) cpCacheIndex;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 static private void writeShort(byte[] buf, int index, short value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 buf[index] = (byte) ((value >> 8) & 0x00FF);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 buf[index + 1] = (byte) (value & 0x00FF);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 public void rewrite() {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 int bytecode = Bytecodes._illegal;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 int hotspotcode = Bytecodes._illegal;
a61af66fc99e Initial load
duke
parents:
diff changeset
125 int len = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
126
6880
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
127 if (DEBUG) {
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
128 String msg = method.getMethodHolder().getName().asString() + "." +
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
129 method.getName().asString() +
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
130 method.getSignature().asString();
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
131 debugMessage(msg);
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
132 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
133 for (int bci = 0; bci < code.length;) {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 hotspotcode = Bytecodes.codeAt(method, bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
135 bytecode = Bytecodes.javaCode(hotspotcode);
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 int code_from_buffer = 0xFF & code[bci];
a61af66fc99e Initial load
duke
parents:
diff changeset
139 Assert.that(code_from_buffer == hotspotcode
a61af66fc99e Initial load
duke
parents:
diff changeset
140 || code_from_buffer == Bytecodes._breakpoint,
a61af66fc99e Initial load
duke
parents:
diff changeset
141 "Unexpected bytecode found in method bytecode buffer!");
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // update the code buffer hotspot specific bytecode with the jvm bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
145 code[bci] = (byte) (0xFF & bytecode);
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 short cpoolIndex = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
148 switch (bytecode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // bytecodes with ConstantPoolCache index
a61af66fc99e Initial load
duke
parents:
diff changeset
150 case Bytecodes._getstatic:
a61af66fc99e Initial load
duke
parents:
diff changeset
151 case Bytecodes._putstatic:
a61af66fc99e Initial load
duke
parents:
diff changeset
152 case Bytecodes._getfield:
a61af66fc99e Initial load
duke
parents:
diff changeset
153 case Bytecodes._putfield:
a61af66fc99e Initial load
duke
parents:
diff changeset
154 case Bytecodes._invokevirtual:
a61af66fc99e Initial load
duke
parents:
diff changeset
155 case Bytecodes._invokespecial:
a61af66fc99e Initial load
duke
parents:
diff changeset
156 case Bytecodes._invokestatic:
a61af66fc99e Initial load
duke
parents:
diff changeset
157 case Bytecodes._invokeinterface: {
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
158 cpoolIndex = getConstantPoolIndex(hotspotcode, bci + 1);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
159 writeShort(code, bci + 1, cpoolIndex);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
161 }
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
162
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
163 case Bytecodes._invokedynamic:
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
164 cpoolIndex = getConstantPoolIndex(hotspotcode, bci + 1);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
165 writeShort(code, bci + 1, cpoolIndex);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
166 writeShort(code, bci + 3, (short)0); // clear out trailing bytes
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
167 break;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
168
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
169 case Bytecodes._ldc_w:
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
170 if (hotspotcode != bytecode) {
6880
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
171 // fast_aldc_w puts constant in reference map
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
172 cpoolIndex = getConstantPoolIndexFromRefMap(hotspotcode, bci + 1);
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
173 writeShort(code, bci + 1, cpoolIndex);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
174 }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
175 break;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
176 case Bytecodes._ldc:
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
177 if (hotspotcode != bytecode) {
6880
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
178 // fast_aldc puts constant in reference map
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
179 cpoolIndex = getConstantPoolIndexFromRefMap(hotspotcode, bci + 1);
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
180 code[bci + 1] = (byte)(cpoolIndex);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
181 }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
182 break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
183 }
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 len = Bytecodes.lengthFor(bytecode);
a61af66fc99e Initial load
duke
parents:
diff changeset
186 if (len <= 0) len = Bytecodes.lengthAt(method, bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
189 String operand = "";
a61af66fc99e Initial load
duke
parents:
diff changeset
190 switch (len) {
a61af66fc99e Initial load
duke
parents:
diff changeset
191 case 2:
a61af66fc99e Initial load
duke
parents:
diff changeset
192 operand += code[bci + 1];
a61af66fc99e Initial load
duke
parents:
diff changeset
193 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
194 case 3:
a61af66fc99e Initial load
duke
parents:
diff changeset
195 operand += (cpoolIndex != 0)? cpoolIndex :
a61af66fc99e Initial load
duke
parents:
diff changeset
196 method.getBytecodeShortArg(bci + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
197 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
198 case 5:
a61af66fc99e Initial load
duke
parents:
diff changeset
199 operand += method.getBytecodeIntArg(bci + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
200 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // the operand following # is not quite like javap output.
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // in particular, for goto & goto_w, the operand is PC relative
a61af66fc99e Initial load
duke
parents:
diff changeset
205 // offset for jump. Javap adds relative offset with current PC
a61af66fc99e Initial load
duke
parents:
diff changeset
206 // to give absolute bci to jump to.
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208 String message = "\t\t" + bci + " " + Bytecodes.name(bytecode);
a61af66fc99e Initial load
duke
parents:
diff changeset
209 if (hotspotcode != bytecode)
a61af66fc99e Initial load
duke
parents:
diff changeset
210 message += " [" + Bytecodes.name(hotspotcode) + "]";
a61af66fc99e Initial load
duke
parents:
diff changeset
211 if (operand != "")
a61af66fc99e Initial load
duke
parents:
diff changeset
212 message += " #" + operand;
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 if (DEBUG) debugMessage(message);
a61af66fc99e Initial load
duke
parents:
diff changeset
215 }
a61af66fc99e Initial load
duke
parents:
diff changeset
216
a61af66fc99e Initial load
duke
parents:
diff changeset
217 bci += len;
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }