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