bytecodeTracer.cpp 20.3 KB
Newer Older
D
duke 已提交
1
/*
2
 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
D
duke 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
19 20 21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
D
duke 已提交
22 23 24
 *
 */

25 26 27 28 29 30 31
#include "precompiled.hpp"
#include "interpreter/bytecodeHistogram.hpp"
#include "interpreter/bytecodeTracer.hpp"
#include "interpreter/bytecodes.hpp"
#include "interpreter/interpreter.hpp"
#include "interpreter/interpreterRuntime.hpp"
#include "memory/resourceArea.hpp"
32 33
#include "oops/methodData.hpp"
#include "oops/method.hpp"
34 35
#include "runtime/mutexLocker.hpp"
#include "runtime/timer.hpp"
D
duke 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48


#ifndef PRODUCT

// Standard closure for BytecodeTracer: prints the current bytecode
// and its attributes using bytecode-specific information.

class BytecodePrinter: public BytecodeClosure {
 private:
  // %%% This field is not GC-ed, and so can contain garbage
  // between critical sections.  Use only pointer-comparison
  // operations on the pointer, except within a critical section.
  // (Also, ensure that occasional false positives are benign.)
49
  Method* _current_method;
D
duke 已提交
50
  bool      _is_wide;
51
  Bytecodes::Code _code;
D
duke 已提交
52 53 54 55 56 57 58
  address   _next_pc;                // current decoding position

  void      align()                  { _next_pc = (address)round_to((intptr_t)_next_pc, sizeof(jint)); }
  int       get_byte()               { return *(jbyte*) _next_pc++; }  // signed
  short     get_short()              { short i=Bytes::get_Java_u2(_next_pc); _next_pc+=2; return i; }
  int       get_int()                { int i=Bytes::get_Java_u4(_next_pc); _next_pc+=4; return i; }

59 60
  int       get_index_u1()           { return *(address)_next_pc++; }
  int       get_index_u2()           { int i=Bytes::get_Java_u2(_next_pc); _next_pc+=2; return i; }
61 62
  int       get_index_u1_cpcache()   { return get_index_u1() + ConstantPool::CPCACHE_INDEX_TAG; }
  int       get_index_u2_cpcache()   { int i=Bytes::get_native_u2(_next_pc); _next_pc+=2; return i + ConstantPool::CPCACHE_INDEX_TAG; }
63 64
  int       get_index_u4()           { int i=Bytes::get_native_u4(_next_pc); _next_pc+=4; return i; }
  int       get_index_special()      { return (is_wide()) ? get_index_u2() : get_index_u1(); }
65
  Method* method()                 { return _current_method; }
D
duke 已提交
66
  bool      is_wide()                { return _is_wide; }
67
  Bytecodes::Code raw_code()         { return Bytecodes::Code(_code); }
D
duke 已提交
68 69


70
  bool      check_index(int i, int& cp_index, outputStream* st = tty);
71 72 73
  bool      check_cp_cache_index(int i, int& cp_index, outputStream* st = tty);
  bool      check_obj_index(int i, int& cp_index, outputStream* st = tty);
  bool      check_invokedynamic_index(int i, int& cp_index, outputStream* st = tty);
D
duke 已提交
74
  void      print_constant(int i, outputStream* st = tty);
75
  void      print_field_or_method(int i, outputStream* st = tty);
76
  void      print_field_or_method(int orig_i, int i, outputStream* st = tty);
77
  void      print_attributes(int bci, outputStream* st = tty);
D
duke 已提交
78 79 80 81 82
  void      bytecode_epilog(int bci, outputStream* st = tty);

 public:
  BytecodePrinter() {
    _is_wide = false;
83
    _code = Bytecodes::_illegal;
D
duke 已提交
84 85 86 87 88 89 90 91 92 93 94 95 96 97
  }

  // This method is called while executing the raw bytecodes, so none of
  // the adjustments that BytecodeStream performs applies.
  void trace(methodHandle method, address bcp, uintptr_t tos, uintptr_t tos2, outputStream* st) {
    ResourceMark rm;
    if (_current_method != method()) {
      // Note 1: This code will not work as expected with true MT/MP.
      //         Need an explicit lock or a different solution.
      // It is possible for this block to be skipped, if a garbage
      // _current_method pointer happens to have the same bits as
      // the incoming method.  We could lose a line of trace output.
      // This is acceptable in a debug-only feature.
      st->cr();
N
never 已提交
98
      st->print("[%ld] ", (long) Thread::current()->osthread()->thread_id());
D
duke 已提交
99 100 101 102 103 104 105
      method->print_name(st);
      st->cr();
      _current_method = method();
    }
    Bytecodes::Code code;
    if (is_wide()) {
      // bcp wasn't advanced if previous bytecode was _wide.
106
      code = Bytecodes::code_at(method(), bcp+1);
D
duke 已提交
107
    } else {
108
      code = Bytecodes::code_at(method(), bcp);
D
duke 已提交
109
    }
110 111
    _code = code;
     int bci = bcp - method->code_base();
N
never 已提交
112
    st->print("[%ld] ", (long) Thread::current()->osthread()->thread_id());
D
duke 已提交
113 114 115 116 117 118 119 120
    if (Verbose) {
      st->print("%8d  %4d  " INTPTR_FORMAT " " INTPTR_FORMAT " %s",
           BytecodeCounter::counter_value(), bci, tos, tos2, Bytecodes::name(code));
    } else {
      st->print("%8d  %4d  %s",
           BytecodeCounter::counter_value(), bci, Bytecodes::name(code));
    }
    _next_pc = is_wide() ? bcp+2 : bcp+1;
121
    print_attributes(bci);
D
duke 已提交
122 123 124
    // Set is_wide for the next one, since the caller of this doesn't skip
    // the next bytecode.
    _is_wide = (code == Bytecodes::_wide);
125
    _code = Bytecodes::_illegal;
D
duke 已提交
126 127
  }

128
  // Used for Method*::print_codes().  The input bcp comes from
D
duke 已提交
129 130 131 132
  // BytecodeStream, which will skip wide bytecodes.
  void trace(methodHandle method, address bcp, outputStream* st) {
    _current_method = method();
    ResourceMark rm;
133
    Bytecodes::Code code = Bytecodes::code_at(method(), bcp);
D
duke 已提交
134 135 136
    // Set is_wide
    _is_wide = (code == Bytecodes::_wide);
    if (is_wide()) {
137
      code = Bytecodes::code_at(method(), bcp+1);
D
duke 已提交
138
    }
139
    _code = code;
D
duke 已提交
140 141 142 143 144 145 146 147
    int bci = bcp - method->code_base();
    // Print bytecode index and name
    if (is_wide()) {
      st->print("%d %s_w", bci, Bytecodes::name(code));
    } else {
      st->print("%d %s", bci, Bytecodes::name(code));
    }
    _next_pc = is_wide() ? bcp+2 : bcp+1;
148
    print_attributes(bci, st);
D
duke 已提交
149 150 151 152 153 154 155 156 157
    bytecode_epilog(bci, st);
  }
};


// Implementation of BytecodeTracer

// %%% This set_closure thing seems overly general, given that
// nobody uses it.  Also, if BytecodePrinter weren't hidden
158
// then Method* could use instances of it directly and it
D
duke 已提交
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
// would be easier to remove races on _current_method and bcp.
// Since this is not product functionality, we can defer cleanup.

BytecodeClosure* BytecodeTracer::_closure = NULL;

static BytecodePrinter std_closure;
BytecodeClosure* BytecodeTracer::std_closure() {
  return &::std_closure;
}


void BytecodeTracer::trace(methodHandle method, address bcp, uintptr_t tos, uintptr_t tos2, outputStream* st) {
  if (TraceBytecodes && BytecodeCounter::counter_value() >= TraceBytecodesAt) {
    ttyLocker ttyl;  // 5065316: keep the following output coherent
    // The ttyLocker also prevents races between two threads
    // trying to use the single instance of BytecodePrinter.
    // Using the ttyLocker prevents the system from coming to
176
    // a safepoint within this code, which is sensitive to Method*
D
duke 已提交
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
    // movement.
    //
    // There used to be a leaf mutex here, but the ttyLocker will
    // work just as well, as long as the printing operations never block.
    //
    // We put the locker on the static trace method, not the
    // virtual one, because the clients of this module go through
    // the static method.
    _closure->trace(method, bcp, tos, tos2, st);
  }
}

void BytecodeTracer::trace(methodHandle method, address bcp, outputStream* st) {
  ttyLocker ttyl;  // 5065316: keep the following output coherent
  _closure->trace(method, bcp, st);
}

194
void print_symbol(Symbol* sym, outputStream* st) {
195 196 197 198 199 200 201 202 203 204
  char buf[40];
  int len = sym->utf8_length();
  if (len >= (int)sizeof(buf)) {
    st->print_cr(" %s...[%d]", sym->as_C_string(buf, sizeof(buf)), len);
  } else {
    st->print(" ");
    sym->print_on(st); st->cr();
  }
}

D
duke 已提交
205 206 207
void print_oop(oop value, outputStream* st) {
  if (value == NULL) {
    st->print_cr(" NULL");
208
  } else if (java_lang_String::is_instance(value)) {
209 210 211 212 213 214 215 216
    char buf[40];
    int len = java_lang_String::utf8_length(value);
    java_lang_String::as_utf8_string(value, buf, sizeof(buf));
    if (len >= (int)sizeof(buf)) {
      st->print_cr(" %s...[%d]", buf, len);
    } else {
      st->print_cr(" %s", buf);
    }
217 218
  } else {
    st->print_cr(" " PTR_FORMAT, (intptr_t) value);
D
duke 已提交
219 220 221
  }
}

222
bool BytecodePrinter::check_index(int i, int& cp_index, outputStream* st) {
223 224
  ConstantPool* constants = method()->constants();
  int ilimit = constants->length();
225
  Bytecodes::Code code = raw_code();
226

227
  ConstantPoolCache* cache = NULL;
228
  if (Bytecodes::uses_cp_cache(code)) {
229 230 231 232 233 234 235 236 237 238 239 240
    bool okay = true;
    switch (code) {
    case Bytecodes::_fast_aldc:
    case Bytecodes::_fast_aldc_w:
      okay = check_obj_index(i, cp_index, st);
      break;
    case Bytecodes::_invokedynamic:
      okay = check_invokedynamic_index(i, cp_index, st);
      break;
    default:
      okay = check_cp_cache_index(i, cp_index, st);
      break;
241
    }
242
    if (!okay) return false;
243 244 245
  }


246 247 248 249
  // check cp index
  if (cp_index >= 0 && cp_index < ilimit) {
    if (WizardMode)  st->print(" cp[%d]", cp_index);
    return true;
250 251
  }

252 253 254 255 256 257 258 259 260 261 262 263
  st->print_cr(" CP[%d] not in CP", cp_index);
  return false;
}

bool BytecodePrinter::check_cp_cache_index(int i, int& cp_index, outputStream* st) {
  ConstantPool* constants = method()->constants();
  int ilimit = constants->length(), climit = 0;
  Bytecodes::Code code = raw_code();

  ConstantPoolCache* cache = constants->cache();
  // If rewriter hasn't run, the index is the cp_index
  if (cache == NULL) {
264 265 266
    cp_index = i;
    return true;
  }
267 268 269 270 271
  //climit = cache->length();  // %%% private!
  size_t size = cache->size() * HeapWordSize;
  size -= sizeof(ConstantPoolCache);
  size /= sizeof(ConstantPoolCacheEntry);
  climit = (int) size;
272

273 274
#ifdef ASSERT
  {
275
    const int CPCACHE_INDEX_TAG = ConstantPool::CPCACHE_INDEX_TAG;
276 277 278 279 280 281 282 283
    if (i >= CPCACHE_INDEX_TAG && i < climit + CPCACHE_INDEX_TAG) {
      i -= CPCACHE_INDEX_TAG;
    } else {
      st->print_cr(" CP[%d] missing bias?", i);
      return false;
    }
  }
#endif //ASSERT
284
  if (i >= 0 && i < climit) {
285 286 287
    cp_index = cache->entry_at(i)->constant_pool_index();
  } else {
    st->print_cr(" not in CP[*]?", i);
288 289
      return false;
    }
290
  return true;
291
  }
292 293 294 295 296 297 298 299 300 301 302


bool BytecodePrinter::check_obj_index(int i, int& cp_index, outputStream* st) {
  ConstantPool* constants = method()->constants();
  i -= ConstantPool::CPCACHE_INDEX_TAG;

  if (i >= 0 && i < constants->resolved_references()->length()) {
     cp_index = constants->object_to_cp_index(i);
     return true;
  } else {
    st->print_cr(" not in OBJ[*]?", i);
303 304
  return false;
}
305 306 307 308 309 310 311 312 313 314
}


bool BytecodePrinter::check_invokedynamic_index(int i, int& cp_index, outputStream* st) {
  ConstantPool* constants = method()->constants();
  assert(ConstantPool::is_invokedynamic_index(i), "not secondary index?");
  i = ConstantPool::decode_invokedynamic_index(i) + ConstantPool::CPCACHE_INDEX_TAG;

  return check_cp_cache_index(i, cp_index, st);
}
315

D
duke 已提交
316
void BytecodePrinter::print_constant(int i, outputStream* st) {
317
  int orig_i = i;
318
  if (!check_index(orig_i, i, st))  return;
319

320
  ConstantPool* constants = method()->constants();
D
duke 已提交
321 322 323 324 325 326 327 328 329 330 331
  constantTag tag = constants->tag_at(i);

  if (tag.is_int()) {
    st->print_cr(" " INT32_FORMAT, constants->int_at(i));
  } else if (tag.is_long()) {
    st->print_cr(" " INT64_FORMAT, constants->long_at(i));
  } else if (tag.is_float()) {
    st->print_cr(" %f", constants->float_at(i));
  } else if (tag.is_double()) {
    st->print_cr(" %f", constants->double_at(i));
  } else if (tag.is_string()) {
332 333
    const char* string = constants->string_at_noresolve(i);
    st->print_cr(" %s", string);
D
duke 已提交
334
  } else if (tag.is_klass()) {
335
    st->print_cr(" %s", constants->resolved_klass_at(i)->external_name());
D
duke 已提交
336 337
  } else if (tag.is_unresolved_klass()) {
    st->print_cr(" <unresolved klass at %d>", i);
338 339 340
  } else if (tag.is_method_type()) {
    int i2 = constants->method_type_index_at(i);
    st->print(" <MethodType> %d", i2);
341
    print_symbol(constants->symbol_at(i2), st);
342 343 344 345 346
  } else if (tag.is_method_handle()) {
    int kind = constants->method_handle_ref_kind_at(i);
    int i2 = constants->method_handle_index_at(i);
    st->print(" <MethodHandle of kind %d>", kind, i2);
    print_field_or_method(-i, i2, st);
347 348 349 350 351 352 353
  } else {
    st->print_cr(" bad tag=%d at %d", tag.value(), i);
  }
}

void BytecodePrinter::print_field_or_method(int i, outputStream* st) {
  int orig_i = i;
354
  if (!check_index(orig_i, i, st))  return;
355 356
  print_field_or_method(orig_i, i, st);
}
357

358
void BytecodePrinter::print_field_or_method(int orig_i, int i, outputStream* st) {
359
  ConstantPool* constants = method()->constants();
360 361
  constantTag tag = constants->tag_at(i);

362
  bool has_klass = true;
363

364 365 366 367
  switch (tag.value()) {
  case JVM_CONSTANT_InterfaceMethodref:
  case JVM_CONSTANT_Methodref:
  case JVM_CONSTANT_Fieldref:
368
    break;
369
  case JVM_CONSTANT_NameAndType:
370 371
  case JVM_CONSTANT_InvokeDynamic:
    has_klass = false;
372 373 374 375 376 377
    break;
  default:
    st->print_cr(" bad tag=%d at %d", tag.value(), i);
    return;
  }

378 379
  Symbol* name = constants->uncached_name_ref_at(i);
  Symbol* signature = constants->uncached_signature_ref_at(i);
380
  const char* sep = (tag.is_field() ? "/" : "");
381
  if (has_klass) {
382
    Symbol* klass = constants->klass_name_at(constants->uncached_klass_ref_index_at(i));
383 384 385 386 387 388 389 390
    st->print_cr(" %d <%s.%s%s%s> ", i, klass->as_C_string(), name->as_C_string(), sep, signature->as_C_string());
  } else {
    if (tag.is_invoke_dynamic()) {
      int bsm = constants->invoke_dynamic_bootstrap_method_ref_index_at(i);
      st->print(" bsm=%d", bsm);
    }
    st->print_cr(" %d <%s%s%s>", i, name->as_C_string(), sep, signature->as_C_string());
  }
D
duke 已提交
391 392 393
}


394
void BytecodePrinter::print_attributes(int bci, outputStream* st) {
D
duke 已提交
395
  // Show attributes of pre-rewritten codes
396
  Bytecodes::Code code = Bytecodes::java_code(raw_code());
D
duke 已提交
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
  // If the code doesn't have any fields there's nothing to print.
  // note this is ==1 because the tableswitch and lookupswitch are
  // zero size (for some reason) and we want to print stuff out for them.
  if (Bytecodes::length_for(code) == 1) {
    st->cr();
    return;
  }

  switch(code) {
    // Java specific bytecodes only matter.
    case Bytecodes::_bipush:
      st->print_cr(" " INT32_FORMAT, get_byte());
      break;
    case Bytecodes::_sipush:
      st->print_cr(" " INT32_FORMAT, get_short());
      break;
    case Bytecodes::_ldc:
414 415 416 417 418
      if (Bytecodes::uses_cp_cache(raw_code())) {
        print_constant(get_index_u1_cpcache(), st);
      } else {
        print_constant(get_index_u1(), st);
      }
D
duke 已提交
419 420 421 422
      break;

    case Bytecodes::_ldc_w:
    case Bytecodes::_ldc2_w:
423 424 425 426 427
      if (Bytecodes::uses_cp_cache(raw_code())) {
        print_constant(get_index_u2_cpcache(), st);
      } else {
        print_constant(get_index_u2(), st);
      }
D
duke 已提交
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450
      break;

    case Bytecodes::_iload:
    case Bytecodes::_lload:
    case Bytecodes::_fload:
    case Bytecodes::_dload:
    case Bytecodes::_aload:
    case Bytecodes::_istore:
    case Bytecodes::_lstore:
    case Bytecodes::_fstore:
    case Bytecodes::_dstore:
    case Bytecodes::_astore:
      st->print_cr(" #%d", get_index_special());
      break;

    case Bytecodes::_iinc:
      { int index = get_index_special();
        jint offset = is_wide() ? get_short(): get_byte();
        st->print_cr(" #%d " INT32_FORMAT, index, offset);
      }
      break;

    case Bytecodes::_newarray: {
451
        BasicType atype = (BasicType)get_index_u1();
D
duke 已提交
452 453 454 455 456 457 458 459
        const char* str = type2name(atype);
        if (str == NULL || atype == T_OBJECT || atype == T_ARRAY) {
          assert(false, "Unidentified basic type");
        }
        st->print_cr(" %s", str);
      }
      break;
    case Bytecodes::_anewarray: {
460
        int klass_index = get_index_u2();
461
        ConstantPool* constants = method()->constants();
462
        Symbol* name = constants->klass_name_at(klass_index);
D
duke 已提交
463 464 465 466
        st->print_cr(" %s ", name->as_C_string());
      }
      break;
    case Bytecodes::_multianewarray: {
467 468
        int klass_index = get_index_u2();
        int nof_dims = get_index_u1();
469
        ConstantPool* constants = method()->constants();
470
        Symbol* name = constants->klass_name_at(klass_index);
D
duke 已提交
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548
        st->print_cr(" %s %d", name->as_C_string(), nof_dims);
      }
      break;

    case Bytecodes::_ifeq:
    case Bytecodes::_ifnull:
    case Bytecodes::_iflt:
    case Bytecodes::_ifle:
    case Bytecodes::_ifne:
    case Bytecodes::_ifnonnull:
    case Bytecodes::_ifgt:
    case Bytecodes::_ifge:
    case Bytecodes::_if_icmpeq:
    case Bytecodes::_if_icmpne:
    case Bytecodes::_if_icmplt:
    case Bytecodes::_if_icmpgt:
    case Bytecodes::_if_icmple:
    case Bytecodes::_if_icmpge:
    case Bytecodes::_if_acmpeq:
    case Bytecodes::_if_acmpne:
    case Bytecodes::_goto:
    case Bytecodes::_jsr:
      st->print_cr(" %d", bci + get_short());
      break;

    case Bytecodes::_goto_w:
    case Bytecodes::_jsr_w:
      st->print_cr(" %d", bci + get_int());
      break;

    case Bytecodes::_ret: st->print_cr(" %d", get_index_special()); break;

    case Bytecodes::_tableswitch:
      { align();
        int  default_dest = bci + get_int();
        int  lo           = get_int();
        int  hi           = get_int();
        int  len          = hi - lo + 1;
        jint* dest        = NEW_RESOURCE_ARRAY(jint, len);
        for (int i = 0; i < len; i++) {
          dest[i] = bci + get_int();
        }
        st->print(" %d " INT32_FORMAT " " INT32_FORMAT " ",
                      default_dest, lo, hi);
        int first = true;
        for (int ll = lo; ll <= hi; ll++, first = false)  {
          int idx = ll - lo;
          const char *format = first ? " %d:" INT32_FORMAT " (delta: %d)" :
                                       ", %d:" INT32_FORMAT " (delta: %d)";
          st->print(format, ll, dest[idx], dest[idx]-bci);
        }
        st->cr();
      }
      break;
    case Bytecodes::_lookupswitch:
      { align();
        int  default_dest = bci + get_int();
        int  len          = get_int();
        jint* key         = NEW_RESOURCE_ARRAY(jint, len);
        jint* dest        = NEW_RESOURCE_ARRAY(jint, len);
        for (int i = 0; i < len; i++) {
          key [i] = get_int();
          dest[i] = bci + get_int();
        };
        st->print(" %d %d ", default_dest, len);
        bool first = true;
        for (int ll = 0; ll < len; ll++, first = false)  {
          const char *format = first ? " " INT32_FORMAT ":" INT32_FORMAT :
                                       ", " INT32_FORMAT ":" INT32_FORMAT ;
          st->print(format, key[ll], dest[ll]);
        }
        st->cr();
      }
      break;

    case Bytecodes::_putstatic:
    case Bytecodes::_getstatic:
    case Bytecodes::_putfield:
549
    case Bytecodes::_getfield:
550
      print_field_or_method(get_index_u2_cpcache(), st);
D
duke 已提交
551 552 553 554 555
      break;

    case Bytecodes::_invokevirtual:
    case Bytecodes::_invokespecial:
    case Bytecodes::_invokestatic:
556
      print_field_or_method(get_index_u2_cpcache(), st);
D
duke 已提交
557 558 559
      break;

    case Bytecodes::_invokeinterface:
560 561 562
      { int i = get_index_u2_cpcache();
        int n = get_index_u1();
        get_byte();            // ignore zero byte
563
        print_field_or_method(i, st);
D
duke 已提交
564 565 566
      }
      break;

567
    case Bytecodes::_invokedynamic:
568
      print_field_or_method(get_index_u4(), st);
569 570
      break;

D
duke 已提交
571 572 573
    case Bytecodes::_new:
    case Bytecodes::_checkcast:
    case Bytecodes::_instanceof:
574
      { int i = get_index_u2();
575
        ConstantPool* constants = method()->constants();
576
        Symbol* name = constants->klass_name_at(i);
D
duke 已提交
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592
        st->print_cr(" %d <%s>", i, name->as_C_string());
      }
      break;

    case Bytecodes::_wide:
      // length is zero not one, but printed with no more info.
      break;

    default:
      ShouldNotReachHere();
      break;
  }
}


void BytecodePrinter::bytecode_epilog(int bci, outputStream* st) {
593
  MethodData* mdo = method()->method_data();
D
duke 已提交
594 595 596 597 598 599 600 601 602 603
  if (mdo != NULL) {
    ProfileData* data = mdo->bci_to_data(bci);
    if (data != NULL) {
      st->print("  %d", mdo->dp_to_di(data->dp()));
      st->fill_to(6);
      data->print_data_on(st);
    }
  }
}
#endif // PRODUCT