1 /*
2 * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "classfile/classPrinter.hpp"
26 #include "classfile/javaClasses.inline.hpp"
27 #include "interpreter/bytecodeHistogram.hpp"
28 #include "interpreter/bytecodes.hpp"
29 #include "interpreter/bytecodeStream.hpp"
30 #include "interpreter/bytecodeTracer.hpp"
31 #include "interpreter/interpreter.hpp"
32 #include "memory/resourceArea.hpp"
33 #include "oops/constantPool.inline.hpp"
34 #include "oops/method.hpp"
35 #include "oops/methodData.hpp"
36 #include "runtime/atomicAccess.hpp"
37 #include "runtime/handles.inline.hpp"
38 #include "runtime/mutexLocker.hpp"
39 #include "runtime/osThread.hpp"
40 #include "utilities/align.hpp"
41
42 // Prints the current bytecode and its attributes using bytecode-specific information.
43
44 class BytecodePrinter {
45 private:
46 // %%% This field is not GC-ed, and so can contain garbage
47 // between critical sections. Use only pointer-comparison
48 // operations on the pointer, except within a critical section.
49 // (Also, ensure that occasional false positives are benign.)
50 Method* _current_method;
51 bool _is_wide;
52 Bytecodes::Code _code;
53 address _next_pc; // current decoding position
54 int _flags;
55 bool _is_linked;
56
57 bool is_linked() const { return _is_linked; }
58 void align() { _next_pc = align_up(_next_pc, sizeof(jint)); }
59 int get_byte() { return *(jbyte*) _next_pc++; } // signed
60 int get_index_u1() { return *(address)_next_pc++; } // returns 0x00 - 0xff as an int
61 short get_short() { short i = Bytes::get_Java_u2 (_next_pc); _next_pc += 2; return i; }
62 int get_int() { int i = Bytes::get_Java_u4 (_next_pc); _next_pc += 4; return i; }
63 int get_native_index_u2() { int i = Bytes::get_native_u2(_next_pc); _next_pc += 2; return i; }
64 int get_native_index_u4() { int i = Bytes::get_native_u4(_next_pc); _next_pc += 4; return i; }
65 int get_Java_index_u2() { int i = Bytes::get_Java_u2 (_next_pc); _next_pc += 2; return i; }
66 int get_Java_index_u4() { int i = Bytes::get_Java_u4 (_next_pc); _next_pc += 4; return i; }
67 int get_index_special() { return (is_wide()) ? get_Java_index_u2() : get_index_u1(); }
68 Method* method() const { return _current_method; }
69 bool is_wide() const { return _is_wide; }
70 Bytecodes::Code raw_code() const { return Bytecodes::Code(_code); }
71 ConstantPool* constants() const { return method()->constants(); }
72 ConstantPoolCache* cpcache() const { assert(is_linked(), "must be"); return constants()->cache(); }
73
74 void print_constant(int i, outputStream* st);
75 void print_cpcache_entry(int cpc_index, outputStream* st);
76 void print_invokedynamic(int indy_index, int cp_index, outputStream* st);
77 void print_bsm(int cp_index, outputStream* st);
78 void print_field_or_method(int cp_index, outputStream* st);
79 void print_dynamic(int cp_index, outputStream* st);
80 void print_attributes(int bci, outputStream* st);
81 void bytecode_epilog(int bci, outputStream* st);
82
83 public:
84 BytecodePrinter(int flags = 0) : _is_wide(false), _code(Bytecodes::_illegal), _flags(flags) {}
85
86 #ifndef PRODUCT
87 BytecodePrinter(Method* prev_method) : BytecodePrinter(0) {
88 _current_method = prev_method;
89 }
90
91 // This method is called while executing the raw bytecodes, so none of
92 // the adjustments that BytecodeStream performs applies.
93 void trace(const methodHandle& method, address bcp, uintptr_t tos, uintptr_t tos2, outputStream* st) {
94 ResourceMark rm;
95 bool method_changed = _current_method != method();
96 _current_method = method();
97 _is_linked = method->method_holder()->is_linked();
98 assert(_is_linked, "this function must be called on methods that are already executing");
99
100 if (method_changed) {
101 // Note 1: This code will not work as expected with true MT/MP.
102 // Need an explicit lock or a different solution.
103 // It is possible for this block to be skipped, if a garbage
104 // _current_method pointer happens to have the same bits as
105 // the incoming method. We could lose a line of trace output.
106 // This is acceptable in a debug-only feature.
107 st->cr();
108 st->print("[%zu] ", Thread::current()->osthread()->thread_id_for_printing());
109 method->print_name(st);
110 st->cr();
111 }
112 Bytecodes::Code code;
113 if (is_wide()) {
114 // bcp wasn't advanced if previous bytecode was _wide.
115 code = Bytecodes::code_at(method(), bcp+1);
116 } else {
117 code = Bytecodes::code_at(method(), bcp);
118 }
119 _code = code;
120 _next_pc = is_wide() ? bcp+2 : bcp+1;
121 // Trace each bytecode unless we're truncating the tracing output, then only print the first
122 // bytecode in every method as well as returns/throws that pop control flow
123 if (!TraceBytecodesTruncated || method_changed ||
124 code == Bytecodes::_athrow ||
125 code == Bytecodes::_return_register_finalizer ||
126 (code >= Bytecodes::_ireturn && code <= Bytecodes::_return)) {
127 int bci = (int)(bcp - method->code_base());
128 st->print("[%zu] ", Thread::current()->osthread()->thread_id_for_printing());
129 if (Verbose) {
130 st->print("%8zu %4d " INTPTR_FORMAT " " INTPTR_FORMAT " %s",
131 BytecodeCounter::counter_value(), bci, tos, tos2, Bytecodes::name(code));
132 } else {
133 st->print("%8zu %4d %s",
134 BytecodeCounter::counter_value(), bci, Bytecodes::name(code));
135 }
136 print_attributes(bci, st);
137 }
138 // Set is_wide for the next one, since the caller of this doesn't skip
139 // the next bytecode.
140 _is_wide = (code == Bytecodes::_wide);
141 _code = Bytecodes::_illegal;
142
143 if (TraceBytecodesStopAt != 0 && BytecodeCounter::counter_value() >= TraceBytecodesStopAt) {
144 TraceBytecodes = false;
145 }
146 }
147 #endif
148
149 // Used for Method::print_codes(). The input bcp comes from
150 // BytecodeStream, which will skip wide bytecodes.
151 void trace(const methodHandle& method, address bcp, outputStream* st) {
152 _current_method = method();
153 _is_linked = method->method_holder()->is_linked();
154 ResourceMark rm;
155 Bytecodes::Code code = Bytecodes::code_at(method(), bcp);
156 // Set is_wide
157 _is_wide = (code == Bytecodes::_wide);
158 if (is_wide()) {
159 code = Bytecodes::code_at(method(), bcp+1);
160 }
161 _code = code;
162 int bci = (int)(bcp - method->code_base());
163 // Print bytecode index and name
164 if (ClassPrinter::has_mode(_flags, ClassPrinter::PRINT_BYTECODE_ADDR)) {
165 st->print(INTPTR_FORMAT " ", p2i(bcp));
166 }
167 if (is_wide()) {
168 st->print("%4d %s_w", bci, Bytecodes::name(code));
169 } else {
170 st->print("%4d %s", bci, Bytecodes::name(code));
171 }
172 _next_pc = is_wide() ? bcp+2 : bcp+1;
173 print_attributes(bci, st);
174 bytecode_epilog(bci, st);
175 }
176 };
177
178 #ifndef PRODUCT
179 // We need a global instance to keep track of the method being printed so we can report that
180 // the method has changed. If this method is redefined and removed, that's ok because the method passed
181 // in won't match, and this will print the method passed in again. Racing threads changing this global
182 // will result in reprinting the method passed in again.
183 static Method* _method_currently_being_printed = nullptr;
184
185 void BytecodeTracer::trace_interpreter(const methodHandle& method, address bcp, uintptr_t tos, uintptr_t tos2, outputStream* st) {
186 if (TraceBytecodes && BytecodeCounter::counter_value() >= TraceBytecodesAt) {
187 BytecodePrinter printer(AtomicAccess::load_acquire(&_method_currently_being_printed));
188 printer.trace(method, bcp, tos, tos2, st);
189 // Save method currently being printed to detect when method printing changes.
190 AtomicAccess::release_store(&_method_currently_being_printed, method());
191 }
192 }
193 #endif
194
195 void BytecodeTracer::print_method_codes(const methodHandle& method, int from, int to, outputStream* st, int flags) {
196 BytecodePrinter method_printer(flags);
197 BytecodeStream s(method);
198 s.set_interval(from, to);
199
200 // Keep output to st coherent: collect all lines and print at once.
201 ResourceMark rm;
202 stringStream ss;
203 while (s.next() >= 0) {
204 method_printer.trace(method, s.bcp(), &ss);
205 }
206 st->print("%s", ss.as_string());
207 }
208
209 void BytecodePrinter::print_constant(int cp_index, outputStream* st) {
210 ConstantPool* constants = method()->constants();
211 constantTag tag = constants->tag_at(cp_index);
212
213 if (tag.is_int()) {
214 st->print_cr(" " INT32_FORMAT, constants->int_at(cp_index));
215 } else if (tag.is_long()) {
216 st->print_cr(" " INT64_FORMAT, (int64_t)(constants->long_at(cp_index)));
217 } else if (tag.is_float()) {
218 st->print_cr(" %f", constants->float_at(cp_index));
219 } else if (tag.is_double()) {
220 st->print_cr(" %f", constants->double_at(cp_index));
221 } else if (tag.is_string()) {
222 const char* string = constants->unresolved_string_at(cp_index)->as_quoted_ascii();
223 st->print_cr(" \"%s\"", string);
224 } else if (tag.is_klass()) {
225 st->print_cr(" %s", constants->resolved_klass_at(cp_index)->external_name());
226 } else if (tag.is_unresolved_klass()) {
227 st->print_cr(" %s", constants->klass_at_noresolve(cp_index)->as_quoted_ascii());
228 } else if (tag.is_method_type()) {
229 int i2 = constants->method_type_index_at(cp_index);
230 st->print(" <MethodType> %d", i2);
231 st->print_cr(" %s", constants->symbol_at(i2)->as_quoted_ascii());
232 } else if (tag.is_method_handle()) {
233 int kind = constants->method_handle_ref_kind_at(cp_index);
234 int i2 = constants->method_handle_index_at(cp_index);
235 st->print(" <MethodHandle of kind %d index at %d>", kind, i2);
236 print_field_or_method(i2, st);
237 } else if (tag.is_dynamic_constant()) {
238 print_dynamic(cp_index, st);
239 if (ClassPrinter::has_mode(_flags, ClassPrinter::PRINT_DYNAMIC)) {
240 print_bsm(cp_index, st);
241 }
242 } else {
243 st->print_cr(" bad tag=%d at %d", tag.value(), cp_index);
244 }
245 }
246
247 // Fieldref, Methodref, or InterfaceMethodref
248 void BytecodePrinter::print_field_or_method(int cp_index, outputStream* st) {
249 ConstantPool* constants = method()->constants();
250 constantTag tag = constants->tag_at(cp_index);
251
252 switch (tag.value()) {
253 case JVM_CONSTANT_Fieldref:
254 case JVM_CONSTANT_Methodref:
255 case JVM_CONSTANT_InterfaceMethodref:
256 break;
257 default:
258 st->print_cr(" bad tag=%d at %d", tag.value(), cp_index);
259 return;
260 }
261
262 Symbol* name = constants->uncached_name_ref_at(cp_index);
263 Symbol* signature = constants->uncached_signature_ref_at(cp_index);
264 Symbol* klass = constants->klass_name_at(constants->uncached_klass_ref_index_at(cp_index));
265 const char* sep = (tag.is_field() ? ":" : "");
266 st->print_cr(" %d <%s.%s%s%s> ", cp_index, klass->as_C_string(), name->as_C_string(), sep, signature->as_C_string());
267 }
268
269 // JVM_CONSTANT_Dynamic or JVM_CONSTANT_InvokeDynamic
270 void BytecodePrinter::print_dynamic(int cp_index, outputStream* st) {
271 ConstantPool* constants = method()->constants();
272 constantTag tag = constants->tag_at(cp_index);
273
274 switch (tag.value()) {
275 case JVM_CONSTANT_Dynamic:
276 case JVM_CONSTANT_InvokeDynamic:
277 break;
278 default:
279 st->print_cr(" bad tag=%d at %d", tag.value(), cp_index);
280 return;
281 }
282
283 int bsm = constants->bootstrap_method_ref_index_at(cp_index);
284 st->print(" bsm=%d", bsm);
285
286 Symbol* name = constants->uncached_name_ref_at(cp_index);
287 Symbol* signature = constants->uncached_signature_ref_at(cp_index);
288 const char* sep = tag.is_dynamic_constant() ? ":" : "";
289 st->print_cr(" %d <%s%s%s>", cp_index, name->as_C_string(), sep, signature->as_C_string());
290 }
291
292 void BytecodePrinter::print_invokedynamic(int indy_index, int cp_index, outputStream* st) {
293 print_dynamic(cp_index, st);
294
295 if (ClassPrinter::has_mode(_flags, ClassPrinter::PRINT_DYNAMIC)) {
296 print_bsm(cp_index, st);
297
298 if (is_linked()) {
299 ResolvedIndyEntry* indy_entry = constants()->resolved_indy_entry_at(indy_index);
300 st->print(" ResolvedIndyEntry: ");
301 indy_entry->print_on(st);
302 }
303 }
304 }
305
306 // cp_index: must be the cp_index of a JVM_CONSTANT_{Dynamic, DynamicInError, InvokeDynamic}
307 void BytecodePrinter::print_bsm(int cp_index, outputStream* st) {
308 assert(constants()->tag_at(cp_index).has_bootstrap(), "must be");
309 int bsm = constants()->bootstrap_method_ref_index_at(cp_index);
310 const char* ref_kind = "";
311 switch (constants()->method_handle_ref_kind_at(bsm)) {
312 case JVM_REF_getField : ref_kind = "REF_getField"; break;
313 case JVM_REF_getStatic : ref_kind = "REF_getStatic"; break;
314 case JVM_REF_putField : ref_kind = "REF_putField"; break;
315 case JVM_REF_putStatic : ref_kind = "REF_putStatic"; break;
316 case JVM_REF_invokeVirtual : ref_kind = "REF_invokeVirtual"; break;
317 case JVM_REF_invokeStatic : ref_kind = "REF_invokeStatic"; break;
318 case JVM_REF_invokeSpecial : ref_kind = "REF_invokeSpecial"; break;
319 case JVM_REF_newInvokeSpecial : ref_kind = "REF_newInvokeSpecial"; break;
320 case JVM_REF_invokeInterface : ref_kind = "REF_invokeInterface"; break;
321 default : ShouldNotReachHere();
322 }
323 st->print(" BSM: %s", ref_kind);
324 print_field_or_method(constants()->method_handle_index_at(bsm), st);
325 int argc = constants()->bootstrap_argument_count_at(cp_index);
326 st->print(" arguments[%d] = {", argc);
327 if (argc > 0) {
328 st->cr();
329 for (int arg_i = 0; arg_i < argc; arg_i++) {
330 int arg = constants()->bootstrap_argument_index_at(cp_index, arg_i);
331 st->print(" ");
332 print_constant(arg, st);
333 }
334 }
335 st->print_cr(" }");
336 }
337
338 void BytecodePrinter::print_attributes(int bci, outputStream* st) {
339 // Show attributes of pre-rewritten codes
340 Bytecodes::Code code = Bytecodes::java_code(raw_code());
341 // If the code doesn't have any fields there's nothing to print.
342 // note this is ==1 because the tableswitch and lookupswitch are
343 // zero size (for some reason) and we want to print stuff out for them.
344 // Also skip this if we're truncating bytecode output
345 if (TraceBytecodesTruncated || Bytecodes::length_for(code) == 1) {
346 st->cr();
347 return;
348 }
349
350 switch(code) {
351 // Java specific bytecodes only matter.
352 case Bytecodes::_bipush:
353 st->print_cr(" " INT32_FORMAT, get_byte());
354 break;
355 case Bytecodes::_sipush:
356 st->print_cr(" " INT32_FORMAT, get_short());
357 break;
358 case Bytecodes::_ldc:
359 {
360 int cp_index;
361 if (Bytecodes::uses_cp_cache(raw_code())) {
362 assert(is_linked(), "fast ldc bytecode must be in linked classes");
363 int obj_index = get_index_u1();
364 cp_index = constants()->object_to_cp_index(obj_index);
365 } else {
366 cp_index = get_index_u1();
367 }
368 print_constant(cp_index, st);
369 }
370 break;
371
372 case Bytecodes::_ldc_w:
373 case Bytecodes::_ldc2_w:
374 {
375 int cp_index;
376 if (Bytecodes::uses_cp_cache(raw_code())) {
377 assert(is_linked(), "fast ldc bytecode must be in linked classes");
378 int obj_index = get_native_index_u2();
379 cp_index = constants()->object_to_cp_index(obj_index);
380 } else {
381 cp_index = get_Java_index_u2();
382 }
383 print_constant(cp_index, st);
384 }
385 break;
386
387 case Bytecodes::_iload:
388 case Bytecodes::_lload:
389 case Bytecodes::_fload:
390 case Bytecodes::_dload:
391 case Bytecodes::_aload:
392 case Bytecodes::_istore:
393 case Bytecodes::_lstore:
394 case Bytecodes::_fstore:
395 case Bytecodes::_dstore:
396 case Bytecodes::_astore:
397 st->print_cr(" #%d", get_index_special());
398 break;
399
400 case Bytecodes::_iinc:
401 { int index = get_index_special();
402 jint offset = is_wide() ? get_short(): get_byte();
403 st->print_cr(" #%d " INT32_FORMAT, index, offset);
404 }
405 break;
406
407 case Bytecodes::_newarray: {
408 BasicType atype = (BasicType)get_index_u1();
409 const char* str = type2name(atype);
410 if (str == nullptr || is_reference_type(atype)) {
411 assert(false, "Unidentified basic type");
412 }
413 st->print_cr(" %s", str);
414 }
415 break;
416 case Bytecodes::_anewarray: {
417 int klass_index = get_Java_index_u2();
418 ConstantPool* constants = method()->constants();
419 Symbol* name = constants->klass_name_at(klass_index);
420 st->print_cr(" %s ", name->as_C_string());
421 }
422 break;
423 case Bytecodes::_multianewarray: {
424 int klass_index = get_Java_index_u2();
425 int nof_dims = get_index_u1();
426 ConstantPool* constants = method()->constants();
427 Symbol* name = constants->klass_name_at(klass_index);
428 st->print_cr(" %s %d", name->as_C_string(), nof_dims);
429 }
430 break;
431
432 case Bytecodes::_ifeq:
433 case Bytecodes::_ifnull:
434 case Bytecodes::_iflt:
435 case Bytecodes::_ifle:
436 case Bytecodes::_ifne:
437 case Bytecodes::_ifnonnull:
438 case Bytecodes::_ifgt:
439 case Bytecodes::_ifge:
440 case Bytecodes::_if_icmpeq:
441 case Bytecodes::_if_icmpne:
442 case Bytecodes::_if_icmplt:
443 case Bytecodes::_if_icmpgt:
444 case Bytecodes::_if_icmple:
445 case Bytecodes::_if_icmpge:
446 case Bytecodes::_if_acmpeq:
447 case Bytecodes::_if_acmpne:
448 case Bytecodes::_goto:
449 case Bytecodes::_jsr:
450 st->print_cr(" %d", bci + get_short());
451 break;
452
453 case Bytecodes::_goto_w:
454 case Bytecodes::_jsr_w:
455 st->print_cr(" %d", bci + get_int());
456 break;
457
458 case Bytecodes::_ret: st->print_cr(" %d", get_index_special()); break;
459
460 case Bytecodes::_tableswitch:
461 { align();
462 int default_dest = bci + get_int();
463 int lo = get_int();
464 int hi = get_int();
465 int len = hi - lo + 1;
466 jint* dest = NEW_RESOURCE_ARRAY(jint, len);
467 for (int i = 0; i < len; i++) {
468 dest[i] = bci + get_int();
469 }
470 st->print(" %d " INT32_FORMAT " " INT32_FORMAT " ",
471 default_dest, lo, hi);
472 const char *comma = "";
473 for (int ll = lo; ll <= hi; ll++) {
474 int idx = ll - lo;
475 st->print("%s %d:" INT32_FORMAT " (delta: %d)", comma, ll, dest[idx], dest[idx]-bci);
476 comma = ",";
477 }
478 st->cr();
479 }
480 break;
481 case Bytecodes::_lookupswitch:
482 { align();
483 int default_dest = bci + get_int();
484 int len = get_int();
485 jint* key = NEW_RESOURCE_ARRAY(jint, len);
486 jint* dest = NEW_RESOURCE_ARRAY(jint, len);
487 for (int i = 0; i < len; i++) {
488 key [i] = get_int();
489 dest[i] = bci + get_int();
490 };
491 st->print(" %d %d ", default_dest, len);
492 const char *comma = "";
493 for (int ll = 0; ll < len; ll++) {
494 st->print("%s " INT32_FORMAT ":" INT32_FORMAT, comma, key[ll], dest[ll]);
495 comma = ",";
496 }
497 st->cr();
498 }
499 break;
500
501 case Bytecodes::_putstatic:
502 case Bytecodes::_getstatic:
503 case Bytecodes::_putfield:
504 case Bytecodes::_getfield:
505 {
506 int cp_index;
507 if (is_linked()) {
508 int field_index = get_native_index_u2();
509 cp_index = cpcache()->resolved_field_entry_at(field_index)->constant_pool_index();
510 } else {
511 cp_index = get_Java_index_u2();
512 }
513 print_field_or_method(cp_index, st);
514 }
515 break;
516
517 case Bytecodes::_invokevirtual:
518 case Bytecodes::_invokespecial:
519 case Bytecodes::_invokestatic:
520 {
521 int cp_index;
522 if (is_linked()) {
523 int method_index = get_native_index_u2();
524 ResolvedMethodEntry* method_entry = cpcache()->resolved_method_entry_at(method_index);
525 cp_index = method_entry->constant_pool_index();
526 print_field_or_method(cp_index, st);
527
528 if (raw_code() == Bytecodes::_invokehandle &&
529 ClassPrinter::has_mode(_flags, ClassPrinter::PRINT_METHOD_HANDLE)) {
530 assert(is_linked(), "invokehandle is only in rewritten methods");
531 method_entry->print_on(st);
532 if (method_entry->has_appendix()) {
533 st->print(" appendix: ");
534 constants()->resolved_reference_from_method(method_index)->print_on(st);
535 }
536 }
537 } else {
538 cp_index = get_Java_index_u2();
539 print_field_or_method(cp_index, st);
540 }
541 }
542 break;
543
544 case Bytecodes::_invokeinterface:
545 {
546 int cp_index;
547 if (is_linked()) {
548 int method_index = get_native_index_u2();
549 cp_index = cpcache()->resolved_method_entry_at(method_index)->constant_pool_index();
550 } else {
551 cp_index = get_Java_index_u2();
552 }
553 int count = get_index_u1(); // TODO: this is not printed.
554 get_byte(); // ignore zero byte
555 print_field_or_method(cp_index, st);
556 }
557 break;
558
559 case Bytecodes::_invokedynamic:
560 {
561 int indy_index;
562 int cp_index;
563 if (is_linked()) {
564 indy_index = get_native_index_u4();
565 cp_index = constants()->resolved_indy_entry_at(indy_index)->constant_pool_index();
566 } else {
567 indy_index = -1;
568 cp_index = get_Java_index_u2();
569 get_byte(); // ignore zero byte
570 get_byte(); // ignore zero byte
571 }
572 print_invokedynamic(indy_index, cp_index, st);
573 }
574 break;
575
576 case Bytecodes::_new:
577 case Bytecodes::_checkcast:
578 case Bytecodes::_instanceof:
579 { int i = get_Java_index_u2();
580 ConstantPool* constants = method()->constants();
581 Symbol* name = constants->klass_name_at(i);
582 st->print_cr(" %d <%s>", i, name->as_C_string());
583 }
584 break;
585
586 case Bytecodes::_wide:
587 // length is zero not one, but printed with no more info.
588 break;
589
590 default:
591 ShouldNotReachHere();
592 break;
593 }
594 }
595
596
597 void BytecodePrinter::bytecode_epilog(int bci, outputStream* st) {
598 MethodData* mdo = method()->method_data();
599 if (mdo != nullptr) {
600
601 // Lock to read ProfileData, and ensure lock is not broken by a safepoint
602 MutexLocker ml(mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag);
603
604 ProfileData* data = mdo->bci_to_data(bci);
605 if (data != nullptr) {
606 st->print(" %d ", mdo->dp_to_di(data->dp()));
607 st->fill_to(7);
608 data->print_data_on(st, mdo);
609 }
610 }
611 }