annotate src/share/vm/interpreter/bytecodeTracer.cpp @ 4181:319860ae697a

Simplify FrameMap: make offsets of spill slots and outgoing parameters independent so that they can be allocated at the same time, eliminating the separate phases. This makes the separate StackBlock unnecesary. Change CiStackSlot to use byte offsets instead of spill slot index. This makes CiTarget.spillSlotSize unnecessary.
author Christian Wimmer <Christian.Wimmer@Oracle.com>
date Mon, 02 Jan 2012 14:16:08 -0800
parents b20d64f83668
children da91efe96a93
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 2011
diff changeset
2 * Copyright (c) 1997, 2011, 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: 1138
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1138
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: 1138
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
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
26 #include "interpreter/bytecodeHistogram.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
27 #include "interpreter/bytecodeTracer.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
28 #include "interpreter/bytecodes.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
29 #include "interpreter/interpreter.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
30 #include "interpreter/interpreterRuntime.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
31 #include "memory/resourceArea.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
32 #include "oops/methodDataOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
33 #include "oops/methodOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
34 #include "runtime/mutexLocker.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
35 #include "runtime/timer.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // Standard closure for BytecodeTracer: prints the current bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // and its attributes using bytecode-specific information.
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 class BytecodePrinter: public BytecodeClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // %%% This field is not GC-ed, and so can contain garbage
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // between critical sections. Use only pointer-comparison
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // operations on the pointer, except within a critical section.
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // (Also, ensure that occasional false positives are benign.)
a61af66fc99e Initial load
duke
parents:
diff changeset
49 methodOop _current_method;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 bool _is_wide;
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
51 Bytecodes::Code _code;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
52 address _next_pc; // current decoding position
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 void align() { _next_pc = (address)round_to((intptr_t)_next_pc, sizeof(jint)); }
a61af66fc99e Initial load
duke
parents:
diff changeset
55 int get_byte() { return *(jbyte*) _next_pc++; } // signed
a61af66fc99e Initial load
duke
parents:
diff changeset
56 short get_short() { short i=Bytes::get_Java_u2(_next_pc); _next_pc+=2; return i; }
a61af66fc99e Initial load
duke
parents:
diff changeset
57 int get_int() { int i=Bytes::get_Java_u4(_next_pc); _next_pc+=4; return i; }
a61af66fc99e Initial load
duke
parents:
diff changeset
58
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
59 int get_index_u1() { return *(address)_next_pc++; }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
60 int get_index_u2() { int i=Bytes::get_Java_u2(_next_pc); _next_pc+=2; return i; }
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
61 int get_index_u1_cpcache() { return get_index_u1() + constantPoolOopDesc::CPCACHE_INDEX_TAG; }
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
62 int get_index_u2_cpcache() { int i=Bytes::get_native_u2(_next_pc); _next_pc+=2; return i + constantPoolOopDesc::CPCACHE_INDEX_TAG; }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
63 int get_index_u4() { int i=Bytes::get_native_u4(_next_pc); _next_pc+=4; return i; }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
64 int get_index_special() { return (is_wide()) ? get_index_u2() : get_index_u1(); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
65 methodOop method() { return _current_method; }
a61af66fc99e Initial load
duke
parents:
diff changeset
66 bool is_wide() { return _is_wide; }
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
67 Bytecodes::Code raw_code() { return Bytecodes::Code(_code); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
70 bool check_index(int i, int& cp_index, outputStream* st = tty);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
71 void print_constant(int i, outputStream* st = tty);
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
72 void print_field_or_method(int i, outputStream* st = tty);
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
73 void print_field_or_method(int orig_i, int i, outputStream* st = tty);
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
74 void print_attributes(int bci, outputStream* st = tty);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
75 void bytecode_epilog(int bci, outputStream* st = tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
78 BytecodePrinter() {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 _is_wide = false;
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
80 _code = Bytecodes::_illegal;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // This method is called while executing the raw bytecodes, so none of
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // the adjustments that BytecodeStream performs applies.
a61af66fc99e Initial load
duke
parents:
diff changeset
85 void trace(methodHandle method, address bcp, uintptr_t tos, uintptr_t tos2, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 if (_current_method != method()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // Note 1: This code will not work as expected with true MT/MP.
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // Need an explicit lock or a different solution.
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // It is possible for this block to be skipped, if a garbage
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // _current_method pointer happens to have the same bits as
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // the incoming method. We could lose a line of trace output.
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // This is acceptable in a debug-only feature.
a61af66fc99e Initial load
duke
parents:
diff changeset
94 st->cr();
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3388
diff changeset
95 st->print("[%ld] ", (long) Thread::current()->osthread()->thread_id());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
96 method->print_name(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
97 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
98 _current_method = method();
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100 Bytecodes::Code code;
a61af66fc99e Initial load
duke
parents:
diff changeset
101 if (is_wide()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // bcp wasn't advanced if previous bytecode was _wide.
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 2011
diff changeset
103 code = Bytecodes::code_at(method(), bcp+1);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
104 } else {
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 2011
diff changeset
105 code = Bytecodes::code_at(method(), bcp);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
107 _code = code;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
108 int bci = bcp - method->code_base();
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3388
diff changeset
109 st->print("[%ld] ", (long) Thread::current()->osthread()->thread_id());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
110 if (Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 st->print("%8d %4d " INTPTR_FORMAT " " INTPTR_FORMAT " %s",
a61af66fc99e Initial load
duke
parents:
diff changeset
112 BytecodeCounter::counter_value(), bci, tos, tos2, Bytecodes::name(code));
a61af66fc99e Initial load
duke
parents:
diff changeset
113 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 st->print("%8d %4d %s",
a61af66fc99e Initial load
duke
parents:
diff changeset
115 BytecodeCounter::counter_value(), bci, Bytecodes::name(code));
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 _next_pc = is_wide() ? bcp+2 : bcp+1;
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
118 print_attributes(bci);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // Set is_wide for the next one, since the caller of this doesn't skip
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // the next bytecode.
a61af66fc99e Initial load
duke
parents:
diff changeset
121 _is_wide = (code == Bytecodes::_wide);
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
122 _code = Bytecodes::_illegal;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // Used for methodOop::print_codes(). The input bcp comes from
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // BytecodeStream, which will skip wide bytecodes.
a61af66fc99e Initial load
duke
parents:
diff changeset
127 void trace(methodHandle method, address bcp, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
128 _current_method = method();
a61af66fc99e Initial load
duke
parents:
diff changeset
129 ResourceMark rm;
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 2011
diff changeset
130 Bytecodes::Code code = Bytecodes::code_at(method(), bcp);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // Set is_wide
a61af66fc99e Initial load
duke
parents:
diff changeset
132 _is_wide = (code == Bytecodes::_wide);
a61af66fc99e Initial load
duke
parents:
diff changeset
133 if (is_wide()) {
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 2011
diff changeset
134 code = Bytecodes::code_at(method(), bcp+1);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
136 _code = code;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
137 int bci = bcp - method->code_base();
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // Print bytecode index and name
a61af66fc99e Initial load
duke
parents:
diff changeset
139 if (is_wide()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 st->print("%d %s_w", bci, Bytecodes::name(code));
a61af66fc99e Initial load
duke
parents:
diff changeset
141 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 st->print("%d %s", bci, Bytecodes::name(code));
a61af66fc99e Initial load
duke
parents:
diff changeset
143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
144 _next_pc = is_wide() ? bcp+2 : bcp+1;
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
145 print_attributes(bci, st);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
146 bytecode_epilog(bci, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148 };
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // Implementation of BytecodeTracer
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // %%% This set_closure thing seems overly general, given that
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // nobody uses it. Also, if BytecodePrinter weren't hidden
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // then methodOop could use instances of it directly and it
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // would be easier to remove races on _current_method and bcp.
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // Since this is not product functionality, we can defer cleanup.
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 BytecodeClosure* BytecodeTracer::_closure = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 static BytecodePrinter std_closure;
a61af66fc99e Initial load
duke
parents:
diff changeset
162 BytecodeClosure* BytecodeTracer::std_closure() {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 return &::std_closure;
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 void BytecodeTracer::trace(methodHandle method, address bcp, uintptr_t tos, uintptr_t tos2, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 if (TraceBytecodes && BytecodeCounter::counter_value() >= TraceBytecodesAt) {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 ttyLocker ttyl; // 5065316: keep the following output coherent
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // The ttyLocker also prevents races between two threads
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // trying to use the single instance of BytecodePrinter.
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // Using the ttyLocker prevents the system from coming to
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // a safepoint within this code, which is sensitive to methodOop
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // movement.
a61af66fc99e Initial load
duke
parents:
diff changeset
175 //
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // There used to be a leaf mutex here, but the ttyLocker will
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // work just as well, as long as the printing operations never block.
a61af66fc99e Initial load
duke
parents:
diff changeset
178 //
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // We put the locker on the static trace method, not the
a61af66fc99e Initial load
duke
parents:
diff changeset
180 // virtual one, because the clients of this module go through
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // the static method.
a61af66fc99e Initial load
duke
parents:
diff changeset
182 _closure->trace(method, bcp, tos, tos2, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
183 }
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 void BytecodeTracer::trace(methodHandle method, address bcp, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 ttyLocker ttyl; // 5065316: keep the following output coherent
a61af66fc99e Initial load
duke
parents:
diff changeset
188 _closure->trace(method, bcp, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 2142
diff changeset
191 void print_symbol(Symbol* sym, outputStream* st) {
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
192 char buf[40];
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
193 int len = sym->utf8_length();
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
194 if (len >= (int)sizeof(buf)) {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
195 st->print_cr(" %s...[%d]", sym->as_C_string(buf, sizeof(buf)), len);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
196 } else {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
197 st->print(" ");
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
198 sym->print_on(st); st->cr();
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
199 }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
200 }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
201
0
a61af66fc99e Initial load
duke
parents:
diff changeset
202 void print_oop(oop value, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 if (value == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 st->print_cr(" NULL");
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
205 } else if (java_lang_String::is_instance(value)) {
3388
a80577f854f9 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 2460
diff changeset
206 char buf[40];
a80577f854f9 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 2460
diff changeset
207 int len = java_lang_String::utf8_length(value);
a80577f854f9 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 2460
diff changeset
208 java_lang_String::as_utf8_string(value, buf, sizeof(buf));
a80577f854f9 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 2460
diff changeset
209 if (len >= (int)sizeof(buf)) {
a80577f854f9 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 2460
diff changeset
210 st->print_cr(" %s...[%d]", buf, len);
a80577f854f9 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 2460
diff changeset
211 } else {
a80577f854f9 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 2460
diff changeset
212 st->print_cr(" %s", buf);
a80577f854f9 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 2460
diff changeset
213 }
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
214 } else {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
215 st->print_cr(" " PTR_FORMAT, (intptr_t) value);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
216 }
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
219 bool BytecodePrinter::check_index(int i, int& cp_index, outputStream* st) {
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
220 constantPoolOop constants = method()->constants();
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
221 int ilimit = constants->length(), climit = 0;
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
222 Bytecodes::Code code = raw_code();
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
223
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
224 constantPoolCacheOop cache = NULL;
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
225 if (Bytecodes::uses_cp_cache(code)) {
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
226 cache = constants->cache();
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
227 if (cache != NULL) {
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
228 //climit = cache->length(); // %%% private!
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
229 size_t size = cache->size() * HeapWordSize;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
230 size -= sizeof(constantPoolCacheOopDesc);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
231 size /= sizeof(ConstantPoolCacheEntry);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
232 climit = (int) size;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
233 }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
234 }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
235
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
236 if (cache != NULL && constantPoolCacheOopDesc::is_secondary_index(i)) {
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
237 i = constantPoolCacheOopDesc::decode_secondary_index(i);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
238 st->print(" secondary cache[%d] of", i);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
239 if (i >= 0 && i < climit) {
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
240 if (!cache->entry_at(i)->is_secondary_entry()) {
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
241 st->print_cr(" not secondary entry?", i);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
242 return false;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
243 }
4042
b20d64f83668 7090904: JSR 292: JRuby junit test crashes in PSScavengeRootsClosure::do_oop
twisti
parents: 3960
diff changeset
244 i = cache->entry_at(i)->main_entry_index() + constantPoolOopDesc::CPCACHE_INDEX_TAG;
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
245 goto check_cache_index;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
246 } else {
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
247 st->print_cr(" not in cache[*]?", i);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
248 return false;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
249 }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
250 }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
251
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
252 if (cache != NULL) {
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
253 goto check_cache_index;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
254 }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
255
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
256 check_cp_index:
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
257 if (i >= 0 && i < ilimit) {
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
258 if (WizardMode) st->print(" cp[%d]", i);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
259 cp_index = i;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
260 return true;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
261 }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
262
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
263 st->print_cr(" CP[%d] not in CP", i);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
264 return false;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
265
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
266 check_cache_index:
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
267 #ifdef ASSERT
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
268 {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
269 const int CPCACHE_INDEX_TAG = constantPoolOopDesc::CPCACHE_INDEX_TAG;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
270 if (i >= CPCACHE_INDEX_TAG && i < climit + CPCACHE_INDEX_TAG) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
271 i -= CPCACHE_INDEX_TAG;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
272 } else {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
273 st->print_cr(" CP[%d] missing bias?", i);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
274 return false;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
275 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
276 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
277 #endif //ASSERT
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
278 if (i >= 0 && i < climit) {
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
279 if (cache->entry_at(i)->is_secondary_entry()) {
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
280 st->print_cr(" secondary entry?");
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
281 return false;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
282 }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
283 i = cache->entry_at(i)->constant_pool_index();
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
284 goto check_cp_index;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
285 }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
286 st->print_cr(" not in CP[*]?", i);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
287 return false;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
288 }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
289
0
a61af66fc99e Initial load
duke
parents:
diff changeset
290 void BytecodePrinter::print_constant(int i, outputStream* st) {
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
291 int orig_i = i;
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
292 if (!check_index(orig_i, i, st)) return;
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
293
0
a61af66fc99e Initial load
duke
parents:
diff changeset
294 constantPoolOop constants = method()->constants();
a61af66fc99e Initial load
duke
parents:
diff changeset
295 constantTag tag = constants->tag_at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
296
a61af66fc99e Initial load
duke
parents:
diff changeset
297 if (tag.is_int()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 st->print_cr(" " INT32_FORMAT, constants->int_at(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
299 } else if (tag.is_long()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
300 st->print_cr(" " INT64_FORMAT, constants->long_at(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
301 } else if (tag.is_float()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
302 st->print_cr(" %f", constants->float_at(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
303 } else if (tag.is_double()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
304 st->print_cr(" %f", constants->double_at(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
305 } else if (tag.is_string()) {
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
306 oop string = constants->pseudo_string_at(i);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
307 print_oop(string, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
308 } else if (tag.is_unresolved_string()) {
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
309 const char* string = constants->string_at_noresolve(i);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
310 st->print_cr(" %s", string);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
311 } else if (tag.is_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
312 st->print_cr(" %s", constants->resolved_klass_at(i)->klass_part()->external_name());
a61af66fc99e Initial load
duke
parents:
diff changeset
313 } else if (tag.is_unresolved_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
314 st->print_cr(" <unresolved klass at %d>", i);
1138
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1059
diff changeset
315 } else if (tag.is_object()) {
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
316 st->print(" <Object>");
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
317 print_oop(constants->object_at(i), st);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
318 } else if (tag.is_method_type()) {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
319 int i2 = constants->method_type_index_at(i);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
320 st->print(" <MethodType> %d", i2);
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 2142
diff changeset
321 print_symbol(constants->symbol_at(i2), st);
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
322 } else if (tag.is_method_handle()) {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
323 int kind = constants->method_handle_ref_kind_at(i);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
324 int i2 = constants->method_handle_index_at(i);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
325 st->print(" <MethodHandle of kind %d>", kind, i2);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
326 print_field_or_method(-i, i2, st);
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
327 } else {
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
328 st->print_cr(" bad tag=%d at %d", tag.value(), i);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
329 }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
330 }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
331
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
332 void BytecodePrinter::print_field_or_method(int i, outputStream* st) {
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
333 int orig_i = i;
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
334 if (!check_index(orig_i, i, st)) return;
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
335 print_field_or_method(orig_i, i, st);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
336 }
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
337
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
338 void BytecodePrinter::print_field_or_method(int orig_i, int i, outputStream* st) {
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
339 constantPoolOop constants = method()->constants();
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
340 constantTag tag = constants->tag_at(i);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
341
1660
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
342 bool has_klass = true;
1059
389049f3f393 6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents: 844
diff changeset
343
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
344 switch (tag.value()) {
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
345 case JVM_CONSTANT_InterfaceMethodref:
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
346 case JVM_CONSTANT_Methodref:
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
347 case JVM_CONSTANT_Fieldref:
1660
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
348 break;
1059
389049f3f393 6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents: 844
diff changeset
349 case JVM_CONSTANT_NameAndType:
1660
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
350 case JVM_CONSTANT_InvokeDynamic:
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
351 has_klass = false;
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
352 break;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
353 default:
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
354 st->print_cr(" bad tag=%d at %d", tag.value(), i);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
355 return;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
356 }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
357
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 2142
diff changeset
358 Symbol* name = constants->uncached_name_ref_at(i);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 2142
diff changeset
359 Symbol* signature = constants->uncached_signature_ref_at(i);
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
360 const char* sep = (tag.is_field() ? "/" : "");
1660
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
361 if (has_klass) {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 2142
diff changeset
362 Symbol* klass = constants->klass_name_at(constants->uncached_klass_ref_index_at(i));
1660
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
363 st->print_cr(" %d <%s.%s%s%s> ", i, klass->as_C_string(), name->as_C_string(), sep, signature->as_C_string());
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
364 } else {
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
365 if (tag.is_invoke_dynamic()) {
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
366 int bsm = constants->invoke_dynamic_bootstrap_method_ref_index_at(i);
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
367 st->print(" bsm=%d", bsm);
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
368 }
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
369 st->print_cr(" %d <%s%s%s>", i, name->as_C_string(), sep, signature->as_C_string());
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
370 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
371 }
a61af66fc99e Initial load
duke
parents:
diff changeset
372
a61af66fc99e Initial load
duke
parents:
diff changeset
373
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
374 void BytecodePrinter::print_attributes(int bci, outputStream* st) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
375 // Show attributes of pre-rewritten codes
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
376 Bytecodes::Code code = Bytecodes::java_code(raw_code());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
377 // If the code doesn't have any fields there's nothing to print.
a61af66fc99e Initial load
duke
parents:
diff changeset
378 // note this is ==1 because the tableswitch and lookupswitch are
a61af66fc99e Initial load
duke
parents:
diff changeset
379 // zero size (for some reason) and we want to print stuff out for them.
a61af66fc99e Initial load
duke
parents:
diff changeset
380 if (Bytecodes::length_for(code) == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
381 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
382 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
383 }
a61af66fc99e Initial load
duke
parents:
diff changeset
384
a61af66fc99e Initial load
duke
parents:
diff changeset
385 switch(code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
386 // Java specific bytecodes only matter.
a61af66fc99e Initial load
duke
parents:
diff changeset
387 case Bytecodes::_bipush:
a61af66fc99e Initial load
duke
parents:
diff changeset
388 st->print_cr(" " INT32_FORMAT, get_byte());
a61af66fc99e Initial load
duke
parents:
diff changeset
389 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
390 case Bytecodes::_sipush:
a61af66fc99e Initial load
duke
parents:
diff changeset
391 st->print_cr(" " INT32_FORMAT, get_short());
a61af66fc99e Initial load
duke
parents:
diff changeset
392 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
393 case Bytecodes::_ldc:
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
394 if (Bytecodes::uses_cp_cache(raw_code())) {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
395 print_constant(get_index_u1_cpcache(), st);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
396 } else {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
397 print_constant(get_index_u1(), st);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
398 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
399 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
400
a61af66fc99e Initial load
duke
parents:
diff changeset
401 case Bytecodes::_ldc_w:
a61af66fc99e Initial load
duke
parents:
diff changeset
402 case Bytecodes::_ldc2_w:
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
403 if (Bytecodes::uses_cp_cache(raw_code())) {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
404 print_constant(get_index_u2_cpcache(), st);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
405 } else {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
406 print_constant(get_index_u2(), st);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
407 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
408 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
409
a61af66fc99e Initial load
duke
parents:
diff changeset
410 case Bytecodes::_iload:
a61af66fc99e Initial load
duke
parents:
diff changeset
411 case Bytecodes::_lload:
a61af66fc99e Initial load
duke
parents:
diff changeset
412 case Bytecodes::_fload:
a61af66fc99e Initial load
duke
parents:
diff changeset
413 case Bytecodes::_dload:
a61af66fc99e Initial load
duke
parents:
diff changeset
414 case Bytecodes::_aload:
a61af66fc99e Initial load
duke
parents:
diff changeset
415 case Bytecodes::_istore:
a61af66fc99e Initial load
duke
parents:
diff changeset
416 case Bytecodes::_lstore:
a61af66fc99e Initial load
duke
parents:
diff changeset
417 case Bytecodes::_fstore:
a61af66fc99e Initial load
duke
parents:
diff changeset
418 case Bytecodes::_dstore:
a61af66fc99e Initial load
duke
parents:
diff changeset
419 case Bytecodes::_astore:
a61af66fc99e Initial load
duke
parents:
diff changeset
420 st->print_cr(" #%d", get_index_special());
a61af66fc99e Initial load
duke
parents:
diff changeset
421 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
422
a61af66fc99e Initial load
duke
parents:
diff changeset
423 case Bytecodes::_iinc:
a61af66fc99e Initial load
duke
parents:
diff changeset
424 { int index = get_index_special();
a61af66fc99e Initial load
duke
parents:
diff changeset
425 jint offset = is_wide() ? get_short(): get_byte();
a61af66fc99e Initial load
duke
parents:
diff changeset
426 st->print_cr(" #%d " INT32_FORMAT, index, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
427 }
a61af66fc99e Initial load
duke
parents:
diff changeset
428 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
429
a61af66fc99e Initial load
duke
parents:
diff changeset
430 case Bytecodes::_newarray: {
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
431 BasicType atype = (BasicType)get_index_u1();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
432 const char* str = type2name(atype);
a61af66fc99e Initial load
duke
parents:
diff changeset
433 if (str == NULL || atype == T_OBJECT || atype == T_ARRAY) {
a61af66fc99e Initial load
duke
parents:
diff changeset
434 assert(false, "Unidentified basic type");
a61af66fc99e Initial load
duke
parents:
diff changeset
435 }
a61af66fc99e Initial load
duke
parents:
diff changeset
436 st->print_cr(" %s", str);
a61af66fc99e Initial load
duke
parents:
diff changeset
437 }
a61af66fc99e Initial load
duke
parents:
diff changeset
438 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
439 case Bytecodes::_anewarray: {
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
440 int klass_index = get_index_u2();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
441 constantPoolOop constants = method()->constants();
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 2142
diff changeset
442 Symbol* name = constants->klass_name_at(klass_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
443 st->print_cr(" %s ", name->as_C_string());
a61af66fc99e Initial load
duke
parents:
diff changeset
444 }
a61af66fc99e Initial load
duke
parents:
diff changeset
445 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
446 case Bytecodes::_multianewarray: {
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
447 int klass_index = get_index_u2();
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
448 int nof_dims = get_index_u1();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
449 constantPoolOop constants = method()->constants();
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 2142
diff changeset
450 Symbol* name = constants->klass_name_at(klass_index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
451 st->print_cr(" %s %d", name->as_C_string(), nof_dims);
a61af66fc99e Initial load
duke
parents:
diff changeset
452 }
a61af66fc99e Initial load
duke
parents:
diff changeset
453 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
454
a61af66fc99e Initial load
duke
parents:
diff changeset
455 case Bytecodes::_ifeq:
a61af66fc99e Initial load
duke
parents:
diff changeset
456 case Bytecodes::_ifnull:
a61af66fc99e Initial load
duke
parents:
diff changeset
457 case Bytecodes::_iflt:
a61af66fc99e Initial load
duke
parents:
diff changeset
458 case Bytecodes::_ifle:
a61af66fc99e Initial load
duke
parents:
diff changeset
459 case Bytecodes::_ifne:
a61af66fc99e Initial load
duke
parents:
diff changeset
460 case Bytecodes::_ifnonnull:
a61af66fc99e Initial load
duke
parents:
diff changeset
461 case Bytecodes::_ifgt:
a61af66fc99e Initial load
duke
parents:
diff changeset
462 case Bytecodes::_ifge:
a61af66fc99e Initial load
duke
parents:
diff changeset
463 case Bytecodes::_if_icmpeq:
a61af66fc99e Initial load
duke
parents:
diff changeset
464 case Bytecodes::_if_icmpne:
a61af66fc99e Initial load
duke
parents:
diff changeset
465 case Bytecodes::_if_icmplt:
a61af66fc99e Initial load
duke
parents:
diff changeset
466 case Bytecodes::_if_icmpgt:
a61af66fc99e Initial load
duke
parents:
diff changeset
467 case Bytecodes::_if_icmple:
a61af66fc99e Initial load
duke
parents:
diff changeset
468 case Bytecodes::_if_icmpge:
a61af66fc99e Initial load
duke
parents:
diff changeset
469 case Bytecodes::_if_acmpeq:
a61af66fc99e Initial load
duke
parents:
diff changeset
470 case Bytecodes::_if_acmpne:
a61af66fc99e Initial load
duke
parents:
diff changeset
471 case Bytecodes::_goto:
a61af66fc99e Initial load
duke
parents:
diff changeset
472 case Bytecodes::_jsr:
a61af66fc99e Initial load
duke
parents:
diff changeset
473 st->print_cr(" %d", bci + get_short());
a61af66fc99e Initial load
duke
parents:
diff changeset
474 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
475
a61af66fc99e Initial load
duke
parents:
diff changeset
476 case Bytecodes::_goto_w:
a61af66fc99e Initial load
duke
parents:
diff changeset
477 case Bytecodes::_jsr_w:
a61af66fc99e Initial load
duke
parents:
diff changeset
478 st->print_cr(" %d", bci + get_int());
a61af66fc99e Initial load
duke
parents:
diff changeset
479 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
480
a61af66fc99e Initial load
duke
parents:
diff changeset
481 case Bytecodes::_ret: st->print_cr(" %d", get_index_special()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
482
a61af66fc99e Initial load
duke
parents:
diff changeset
483 case Bytecodes::_tableswitch:
a61af66fc99e Initial load
duke
parents:
diff changeset
484 { align();
a61af66fc99e Initial load
duke
parents:
diff changeset
485 int default_dest = bci + get_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
486 int lo = get_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
487 int hi = get_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
488 int len = hi - lo + 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
489 jint* dest = NEW_RESOURCE_ARRAY(jint, len);
a61af66fc99e Initial load
duke
parents:
diff changeset
490 for (int i = 0; i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
491 dest[i] = bci + get_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
492 }
a61af66fc99e Initial load
duke
parents:
diff changeset
493 st->print(" %d " INT32_FORMAT " " INT32_FORMAT " ",
a61af66fc99e Initial load
duke
parents:
diff changeset
494 default_dest, lo, hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
495 int first = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
496 for (int ll = lo; ll <= hi; ll++, first = false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
497 int idx = ll - lo;
a61af66fc99e Initial load
duke
parents:
diff changeset
498 const char *format = first ? " %d:" INT32_FORMAT " (delta: %d)" :
a61af66fc99e Initial load
duke
parents:
diff changeset
499 ", %d:" INT32_FORMAT " (delta: %d)";
a61af66fc99e Initial load
duke
parents:
diff changeset
500 st->print(format, ll, dest[idx], dest[idx]-bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
501 }
a61af66fc99e Initial load
duke
parents:
diff changeset
502 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
503 }
a61af66fc99e Initial load
duke
parents:
diff changeset
504 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
505 case Bytecodes::_lookupswitch:
a61af66fc99e Initial load
duke
parents:
diff changeset
506 { align();
a61af66fc99e Initial load
duke
parents:
diff changeset
507 int default_dest = bci + get_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
508 int len = get_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
509 jint* key = NEW_RESOURCE_ARRAY(jint, len);
a61af66fc99e Initial load
duke
parents:
diff changeset
510 jint* dest = NEW_RESOURCE_ARRAY(jint, len);
a61af66fc99e Initial load
duke
parents:
diff changeset
511 for (int i = 0; i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
512 key [i] = get_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
513 dest[i] = bci + get_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
514 };
a61af66fc99e Initial load
duke
parents:
diff changeset
515 st->print(" %d %d ", default_dest, len);
a61af66fc99e Initial load
duke
parents:
diff changeset
516 bool first = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
517 for (int ll = 0; ll < len; ll++, first = false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
518 const char *format = first ? " " INT32_FORMAT ":" INT32_FORMAT :
a61af66fc99e Initial load
duke
parents:
diff changeset
519 ", " INT32_FORMAT ":" INT32_FORMAT ;
a61af66fc99e Initial load
duke
parents:
diff changeset
520 st->print(format, key[ll], dest[ll]);
a61af66fc99e Initial load
duke
parents:
diff changeset
521 }
a61af66fc99e Initial load
duke
parents:
diff changeset
522 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
523 }
a61af66fc99e Initial load
duke
parents:
diff changeset
524 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
525
a61af66fc99e Initial load
duke
parents:
diff changeset
526 case Bytecodes::_putstatic:
a61af66fc99e Initial load
duke
parents:
diff changeset
527 case Bytecodes::_getstatic:
a61af66fc99e Initial load
duke
parents:
diff changeset
528 case Bytecodes::_putfield:
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
529 case Bytecodes::_getfield:
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
530 print_field_or_method(get_index_u2_cpcache(), st);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
531 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
532
a61af66fc99e Initial load
duke
parents:
diff changeset
533 case Bytecodes::_invokevirtual:
a61af66fc99e Initial load
duke
parents:
diff changeset
534 case Bytecodes::_invokespecial:
a61af66fc99e Initial load
duke
parents:
diff changeset
535 case Bytecodes::_invokestatic:
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
536 print_field_or_method(get_index_u2_cpcache(), st);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
537 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
538
a61af66fc99e Initial load
duke
parents:
diff changeset
539 case Bytecodes::_invokeinterface:
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
540 { int i = get_index_u2_cpcache();
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
541 int n = get_index_u1();
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
542 get_byte(); // ignore zero byte
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
543 print_field_or_method(i, st);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
544 }
a61af66fc99e Initial load
duke
parents:
diff changeset
545 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
546
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
547 case Bytecodes::_invokedynamic:
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
548 print_field_or_method(get_index_u4(), st);
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
549 break;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
550
0
a61af66fc99e Initial load
duke
parents:
diff changeset
551 case Bytecodes::_new:
a61af66fc99e Initial load
duke
parents:
diff changeset
552 case Bytecodes::_checkcast:
a61af66fc99e Initial load
duke
parents:
diff changeset
553 case Bytecodes::_instanceof:
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
554 { int i = get_index_u2();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
555 constantPoolOop constants = method()->constants();
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 2142
diff changeset
556 Symbol* name = constants->klass_name_at(i);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
557 st->print_cr(" %d <%s>", i, name->as_C_string());
a61af66fc99e Initial load
duke
parents:
diff changeset
558 }
a61af66fc99e Initial load
duke
parents:
diff changeset
559 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
560
a61af66fc99e Initial load
duke
parents:
diff changeset
561 case Bytecodes::_wide:
a61af66fc99e Initial load
duke
parents:
diff changeset
562 // length is zero not one, but printed with no more info.
a61af66fc99e Initial load
duke
parents:
diff changeset
563 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
564
a61af66fc99e Initial load
duke
parents:
diff changeset
565 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
566 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
567 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
568 }
a61af66fc99e Initial load
duke
parents:
diff changeset
569 }
a61af66fc99e Initial load
duke
parents:
diff changeset
570
a61af66fc99e Initial load
duke
parents:
diff changeset
571
a61af66fc99e Initial load
duke
parents:
diff changeset
572 void BytecodePrinter::bytecode_epilog(int bci, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
573 methodDataOop mdo = method()->method_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
574 if (mdo != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
575 ProfileData* data = mdo->bci_to_data(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
576 if (data != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
577 st->print(" %d", mdo->dp_to_di(data->dp()));
a61af66fc99e Initial load
duke
parents:
diff changeset
578 st->fill_to(6);
a61af66fc99e Initial load
duke
parents:
diff changeset
579 data->print_data_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
580 }
a61af66fc99e Initial load
duke
parents:
diff changeset
581 }
a61af66fc99e Initial load
duke
parents:
diff changeset
582 }
a61af66fc99e Initial load
duke
parents:
diff changeset
583 #endif // PRODUCT