annotate src/share/vm/interpreter/bytecodeTracer.cpp @ 1565:ab102d5d923e

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