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