annotate agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ByteCodeRewriter.java @ 20804:7848fc12602b

Merge with jdk8u40-b25
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Tue, 07 Apr 2015 14:58:49 +0200
parents 4ca6dc0799b6 64156d22e49d
children
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 }
20456
64156d22e49d 8032247: SA: Constantpool lookup for invokedynamic is not implemented
dsamersoff
parents: 6880
diff changeset
101
0
a61af66fc99e Initial load
duke
parents:
diff changeset
102 if (cpCache == null) {
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
103 return (short) cpCacheIndex;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
104 } else if (fmt.indexOf("JJJJ") >= 0) {
20456
64156d22e49d 8032247: SA: Constantpool lookup for invokedynamic is not implemented
dsamersoff
parents: 6880
diff changeset
105 // Invokedynamic require special handling
64156d22e49d 8032247: SA: Constantpool lookup for invokedynamic is not implemented
dsamersoff
parents: 6880
diff changeset
106 cpCacheIndex = ~cpCacheIndex;
64156d22e49d 8032247: SA: Constantpool lookup for invokedynamic is not implemented
dsamersoff
parents: 6880
diff changeset
107 cpCacheIndex = bytes.swapInt(cpCacheIndex);
64156d22e49d 8032247: SA: Constantpool lookup for invokedynamic is not implemented
dsamersoff
parents: 6880
diff changeset
108 return (short) cpCache.getEntryAt(cpCacheIndex).getConstantPoolIndex();
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
109 } else if (fmt.indexOf("JJ") >= 0) {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
110 // change byte-ordering and go via cache
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
111 return (short) cpCache.getEntryAt((int) (0xFFFF & bytes.swapShort((short)cpCacheIndex))).getConstantPoolIndex();
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
112 } else if (fmt.indexOf("j") >= 0) {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
113 // go via cache
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
114 return (short) cpCache.getEntryAt((int) (0xFF & cpCacheIndex)).getConstantPoolIndex();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
115 } else {
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
116 return (short) cpCacheIndex;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 static private void writeShort(byte[] buf, int index, short value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 buf[index] = (byte) ((value >> 8) & 0x00FF);
a61af66fc99e Initial load
duke
parents:
diff changeset
122 buf[index + 1] = (byte) (value & 0x00FF);
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 public void rewrite() {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 int bytecode = Bytecodes._illegal;
a61af66fc99e Initial load
duke
parents:
diff changeset
127 int hotspotcode = Bytecodes._illegal;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 int len = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
129
6880
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
130 if (DEBUG) {
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
131 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
132 method.getName().asString() +
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
133 method.getSignature().asString();
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
134 debugMessage(msg);
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
135 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
136 for (int bci = 0; bci < code.length;) {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 hotspotcode = Bytecodes.codeAt(method, bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
138 bytecode = Bytecodes.javaCode(hotspotcode);
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
141 int code_from_buffer = 0xFF & code[bci];
a61af66fc99e Initial load
duke
parents:
diff changeset
142 Assert.that(code_from_buffer == hotspotcode
a61af66fc99e Initial load
duke
parents:
diff changeset
143 || code_from_buffer == Bytecodes._breakpoint,
a61af66fc99e Initial load
duke
parents:
diff changeset
144 "Unexpected bytecode found in method bytecode buffer!");
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // update the code buffer hotspot specific bytecode with the jvm bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
148 code[bci] = (byte) (0xFF & bytecode);
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 short cpoolIndex = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
151 switch (bytecode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // bytecodes with ConstantPoolCache index
a61af66fc99e Initial load
duke
parents:
diff changeset
153 case Bytecodes._getstatic:
a61af66fc99e Initial load
duke
parents:
diff changeset
154 case Bytecodes._putstatic:
a61af66fc99e Initial load
duke
parents:
diff changeset
155 case Bytecodes._getfield:
a61af66fc99e Initial load
duke
parents:
diff changeset
156 case Bytecodes._putfield:
a61af66fc99e Initial load
duke
parents:
diff changeset
157 case Bytecodes._invokevirtual:
a61af66fc99e Initial load
duke
parents:
diff changeset
158 case Bytecodes._invokespecial:
a61af66fc99e Initial load
duke
parents:
diff changeset
159 case Bytecodes._invokestatic:
a61af66fc99e Initial load
duke
parents:
diff changeset
160 case Bytecodes._invokeinterface: {
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
161 cpoolIndex = getConstantPoolIndex(hotspotcode, bci + 1);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
162 writeShort(code, bci + 1, cpoolIndex);
a61af66fc99e Initial load
duke
parents:
diff changeset
163 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
165
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
166 case Bytecodes._invokedynamic:
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
167 cpoolIndex = getConstantPoolIndex(hotspotcode, bci + 1);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
168 writeShort(code, bci + 1, cpoolIndex);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
169 writeShort(code, bci + 3, (short)0); // clear out trailing bytes
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
170 break;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
171
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
172 case Bytecodes._ldc_w:
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
173 if (hotspotcode != bytecode) {
6880
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
174 // 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
175 cpoolIndex = getConstantPoolIndexFromRefMap(hotspotcode, bci + 1);
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
176 writeShort(code, bci + 1, cpoolIndex);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
177 }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
178 break;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
179 case Bytecodes._ldc:
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
180 if (hotspotcode != bytecode) {
6880
c7957b458bf8 8000818: SA constant pool need to reference to reference map after permgen removal
minqi
parents: 6725
diff changeset
181 // 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
182 cpoolIndex = getConstantPoolIndexFromRefMap(hotspotcode, bci + 1);
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
183 code[bci + 1] = (byte)(cpoolIndex);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
184 }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
185 break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 len = Bytecodes.lengthFor(bytecode);
a61af66fc99e Initial load
duke
parents:
diff changeset
189 if (len <= 0) len = Bytecodes.lengthAt(method, bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 String operand = "";
a61af66fc99e Initial load
duke
parents:
diff changeset
193 switch (len) {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 case 2:
a61af66fc99e Initial load
duke
parents:
diff changeset
195 operand += code[bci + 1];
a61af66fc99e Initial load
duke
parents:
diff changeset
196 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
197 case 3:
a61af66fc99e Initial load
duke
parents:
diff changeset
198 operand += (cpoolIndex != 0)? cpoolIndex :
a61af66fc99e Initial load
duke
parents:
diff changeset
199 method.getBytecodeShortArg(bci + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
200 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
201 case 5:
a61af66fc99e Initial load
duke
parents:
diff changeset
202 operand += method.getBytecodeIntArg(bci + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
203 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 // the operand following # is not quite like javap output.
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // in particular, for goto & goto_w, the operand is PC relative
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // offset for jump. Javap adds relative offset with current PC
a61af66fc99e Initial load
duke
parents:
diff changeset
209 // to give absolute bci to jump to.
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 String message = "\t\t" + bci + " " + Bytecodes.name(bytecode);
a61af66fc99e Initial load
duke
parents:
diff changeset
212 if (hotspotcode != bytecode)
a61af66fc99e Initial load
duke
parents:
diff changeset
213 message += " [" + Bytecodes.name(hotspotcode) + "]";
a61af66fc99e Initial load
duke
parents:
diff changeset
214 if (operand != "")
a61af66fc99e Initial load
duke
parents:
diff changeset
215 message += " #" + operand;
a61af66fc99e Initial load
duke
parents:
diff changeset
216
a61af66fc99e Initial load
duke
parents:
diff changeset
217 if (DEBUG) debugMessage(message);
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 bci += len;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }