1 /*
   2  * Copyright (c) 1997, 2016, 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 "precompiled.hpp"
  26 #include "classfile/javaClasses.inline.hpp"
  27 #include "interpreter/bytecodeHistogram.hpp"
  28 #include "interpreter/bytecodeTracer.hpp"
  29 #include "interpreter/bytecodes.hpp"
  30 #include "interpreter/interpreter.hpp"
  31 #include "interpreter/interpreterRuntime.hpp"
  32 #include "memory/resourceArea.hpp"
  33 #include "oops/methodData.hpp"
  34 #include "oops/method.hpp"
  35 #include "runtime/mutexLocker.hpp"
  36 #include "runtime/timer.hpp"
  37 
  38 
  39 // Standard closure for BytecodeTracer: prints the current bytecode
  40 // and its attributes using bytecode-specific information.
  41 
  42 class BytecodePrinter: public BytecodeClosure {
  43  private:
  44   // %%% This field is not GC-ed, and so can contain garbage
  45   // between critical sections.  Use only pointer-comparison
  46   // operations on the pointer, except within a critical section.
  47   // (Also, ensure that occasional false positives are benign.)
  48   Method* _current_method;
  49   bool      _is_wide;
  50   Bytecodes::Code _code;
  51   address   _next_pc;                // current decoding position
  52 
  53   void      align()                  { _next_pc = (address)round_to((intptr_t)_next_pc, sizeof(jint)); }
  54   int       get_byte()               { return *(jbyte*) _next_pc++; }  // signed
  55   short     get_short()              { short i=Bytes::get_Java_u2(_next_pc); _next_pc+=2; return i; }
  56   int       get_int()                { int i=Bytes::get_Java_u4(_next_pc); _next_pc+=4; return i; }
  57 
  58   int       get_index_u1()           { return *(address)_next_pc++; }
  59   int       get_index_u2()           { int i=Bytes::get_Java_u2(_next_pc); _next_pc+=2; return i; }
  60   int       get_index_u1_cpcache()   { return get_index_u1() + ConstantPool::CPCACHE_INDEX_TAG; }
  61   int       get_index_u2_cpcache()   { int i=Bytes::get_native_u2(_next_pc); _next_pc+=2; return i + ConstantPool::CPCACHE_INDEX_TAG; }
  62   int       get_index_u4()           { int i=Bytes::get_native_u4(_next_pc); _next_pc+=4; return i; }
  63   int       get_index_special()      { return (is_wide()) ? get_index_u2() : get_index_u1(); }
  64   Method* method()                 { return _current_method; }
  65   bool      is_wide()                { return _is_wide; }
  66   Bytecodes::Code raw_code()         { return Bytecodes::Code(_code); }
  67 
  68 
  69   bool      check_index(int i, int& cp_index, outputStream* st = tty);
  70   bool      check_cp_cache_index(int i, int& cp_index, outputStream* st = tty);
  71   bool      check_obj_index(int i, int& cp_index, outputStream* st = tty);
  72   bool      check_invokedynamic_index(int i, int& cp_index, outputStream* st = tty);
  73   void      print_constant(int i, outputStream* st = tty);
  74   void      print_field_or_method(int i, outputStream* st = tty);
  75   void      print_field_or_method(int orig_i, int i, outputStream* st = tty);
  76   void      print_attributes(int bci, outputStream* st = tty);
  77   void      bytecode_epilog(int bci, outputStream* st = tty);
  78 
  79  public:
  80   BytecodePrinter() {
  81     _is_wide = false;
  82     _code = Bytecodes::_illegal;
  83   }
  84 
  85   // This method is called while executing the raw bytecodes, so none of
  86   // the adjustments that BytecodeStream performs applies.
  87   void trace(const methodHandle& method, address bcp, uintptr_t tos, uintptr_t tos2, outputStream* st) {
  88     ResourceMark rm;
  89     if (_current_method != method()) {
  90       // Note 1: This code will not work as expected with true MT/MP.
  91       //         Need an explicit lock or a different solution.
  92       // It is possible for this block to be skipped, if a garbage
  93       // _current_method pointer happens to have the same bits as
  94       // the incoming method.  We could lose a line of trace output.
  95       // This is acceptable in a debug-only feature.
  96       st->cr();
  97       st->print("[%ld] ", (long) Thread::current()->osthread()->thread_id());
  98       method->print_name(st);
  99       st->cr();
 100       _current_method = method();
 101     }
 102     Bytecodes::Code code;
 103     if (is_wide()) {
 104       // bcp wasn't advanced if previous bytecode was _wide.
 105       code = Bytecodes::code_at(method(), bcp+1);
 106     } else {
 107       code = Bytecodes::code_at(method(), bcp);
 108     }
 109     _code = code;
 110      int bci = bcp - method->code_base();
 111     st->print("[%ld] ", (long) Thread::current()->osthread()->thread_id());
 112     if (Verbose) {
 113       st->print("%8d  %4d  " INTPTR_FORMAT " " INTPTR_FORMAT " %s",
 114            BytecodeCounter::counter_value(), bci, tos, tos2, Bytecodes::name(code));
 115     } else {
 116       st->print("%8d  %4d  %s",
 117            BytecodeCounter::counter_value(), bci, Bytecodes::name(code));
 118     }
 119     _next_pc = is_wide() ? bcp+2 : bcp+1;
 120     print_attributes(bci);
 121     // Set is_wide for the next one, since the caller of this doesn't skip
 122     // the next bytecode.
 123     _is_wide = (code == Bytecodes::_wide);
 124     _code = Bytecodes::_illegal;
 125   }
 126 
 127   // Used for Method*::print_codes().  The input bcp comes from
 128   // BytecodeStream, which will skip wide bytecodes.
 129   void trace(const methodHandle& method, address bcp, outputStream* st) {
 130     _current_method = method();
 131     ResourceMark rm;
 132     Bytecodes::Code code = Bytecodes::code_at(method(), bcp);
 133     // Set is_wide
 134     _is_wide = (code == Bytecodes::_wide);
 135     if (is_wide()) {
 136       code = Bytecodes::code_at(method(), bcp+1);
 137     }
 138     _code = code;
 139     int bci = bcp - method->code_base();
 140     // Print bytecode index and name
 141     if (is_wide()) {
 142       st->print("%d %s_w", bci, Bytecodes::name(code));
 143     } else {
 144       st->print("%d %s", bci, Bytecodes::name(code));
 145     }
 146     _next_pc = is_wide() ? bcp+2 : bcp+1;
 147     print_attributes(bci, st);
 148     bytecode_epilog(bci, st);
 149   }
 150 };
 151 
 152 
 153 // Implementation of BytecodeTracer
 154 
 155 // %%% This set_closure thing seems overly general, given that
 156 // nobody uses it.  Also, if BytecodePrinter weren't hidden
 157 // then Method* could use instances of it directly and it
 158 // would be easier to remove races on _current_method and bcp.
 159 // Since this is not product functionality, we can defer cleanup.
 160 
 161 BytecodeClosure* BytecodeTracer::_closure = NULL;
 162 
 163 static BytecodePrinter std_closure;
 164 BytecodeClosure* BytecodeTracer::std_closure() {
 165   return &::std_closure;
 166 }
 167 
 168 
 169 void BytecodeTracer::trace(const methodHandle& method, address bcp, uintptr_t tos, uintptr_t tos2, outputStream* st) {
 170   bool stop_here = (StopInterpreterAt != 0 && BytecodeCounter::counter_value() >= StopInterpreterAt);
 171   if (stop_here || (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
 176     // a safepoint within this code, which is sensitive to Method*
 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     if (stop_here) {
 187       guarantee(false, "hit StopInterpreterAt");
 188     }
 189   }
 190 }
 191 
 192 void BytecodeTracer::trace(const methodHandle& method, address bcp, outputStream* st) {
 193   ttyLocker ttyl;  // 5065316: keep the following output coherent
 194   _closure->trace(method, bcp, st);
 195 }
 196 
 197 void print_symbol(Symbol* sym, outputStream* st) {
 198   char buf[40];
 199   int len = sym->utf8_length();
 200   if (len >= (int)sizeof(buf)) {
 201     st->print_cr(" %s...[%d]", sym->as_C_string(buf, sizeof(buf)), len);
 202   } else {
 203     st->print(" ");
 204     sym->print_on(st); st->cr();
 205   }
 206 }
 207 
 208 void print_oop(oop value, outputStream* st) {
 209   if (value == NULL) {
 210     st->print_cr(" NULL");
 211   } else if (java_lang_String::is_instance(value)) {
 212     char buf[40];
 213     int len = java_lang_String::utf8_length(value);
 214     java_lang_String::as_utf8_string(value, buf, sizeof(buf));
 215     if (len >= (int)sizeof(buf)) {
 216       st->print_cr(" %s...[%d]", buf, len);
 217     } else {
 218       st->print_cr(" %s", buf);
 219     }
 220   } else {
 221     st->print_cr(" " INTPTR_FORMAT, p2i((void *)value));
 222   }
 223 }
 224 
 225 bool BytecodePrinter::check_index(int i, int& cp_index, outputStream* st) {
 226   ConstantPool* constants = method()->constants();
 227   int ilimit = constants->length();
 228   Bytecodes::Code code = raw_code();
 229 
 230   ConstantPoolCache* cache = NULL;
 231   if (Bytecodes::uses_cp_cache(code)) {
 232     bool okay = true;
 233     switch (code) {
 234     case Bytecodes::_fast_aldc:
 235     case Bytecodes::_fast_aldc_w:
 236       okay = check_obj_index(i, cp_index, st);
 237       break;
 238     case Bytecodes::_invokedynamic:
 239       okay = check_invokedynamic_index(i, cp_index, st);
 240       break;
 241     default:
 242       okay = check_cp_cache_index(i, cp_index, st);
 243       break;
 244     }
 245     if (!okay) return false;
 246   }
 247 
 248 
 249   // check cp index
 250   if (cp_index >= 0 && cp_index < ilimit) {
 251     if (WizardMode)  st->print(" cp[%d]", cp_index);
 252     return true;
 253   }
 254 
 255   st->print_cr(" CP[%d] not in CP", cp_index);
 256   return false;
 257 }
 258 
 259 bool BytecodePrinter::check_cp_cache_index(int i, int& cp_index, outputStream* st) {
 260   ConstantPool* constants = method()->constants();
 261   int ilimit = constants->length(), climit = 0;
 262   Bytecodes::Code code = raw_code();
 263 
 264   ConstantPoolCache* cache = constants->cache();
 265   // If rewriter hasn't run, the index is the cp_index
 266   if (cache == NULL) {
 267     cp_index = i;
 268     return true;
 269   }
 270   //climit = cache->length();  // %%% private!
 271   size_t size = cache->size() * wordSize;
 272   size -= sizeof(ConstantPoolCache);
 273   size /= sizeof(ConstantPoolCacheEntry);
 274   climit = (int) size;
 275 
 276 #ifdef ASSERT
 277   {
 278     const int CPCACHE_INDEX_TAG = ConstantPool::CPCACHE_INDEX_TAG;
 279     if (i >= CPCACHE_INDEX_TAG && i < climit + CPCACHE_INDEX_TAG) {
 280       i -= CPCACHE_INDEX_TAG;
 281     } else {
 282       st->print_cr(" CP[%d] missing bias?", i);
 283       return false;
 284     }
 285   }
 286 #endif //ASSERT
 287   if (i >= 0 && i < climit) {
 288     cp_index = cache->entry_at(i)->constant_pool_index();
 289   } else {
 290     st->print_cr("%d not in CP[*]?", i);
 291       return false;
 292     }
 293   return true;
 294   }
 295 
 296 
 297 bool BytecodePrinter::check_obj_index(int i, int& cp_index, outputStream* st) {
 298   ConstantPool* constants = method()->constants();
 299   i -= ConstantPool::CPCACHE_INDEX_TAG;
 300 
 301   if (i >= 0 && i < constants->resolved_references()->length()) {
 302      cp_index = constants->object_to_cp_index(i);
 303      return true;
 304   } else {
 305     st->print_cr("%d not in OBJ[*]?", i);
 306   return false;
 307 }
 308 }
 309 
 310 
 311 bool BytecodePrinter::check_invokedynamic_index(int i, int& cp_index, outputStream* st) {
 312   ConstantPool* constants = method()->constants();
 313   assert(ConstantPool::is_invokedynamic_index(i), "not secondary index?");
 314   i = ConstantPool::decode_invokedynamic_index(i) + ConstantPool::CPCACHE_INDEX_TAG;
 315 
 316   return check_cp_cache_index(i, cp_index, st);
 317 }
 318 
 319 void BytecodePrinter::print_constant(int i, outputStream* st) {
 320   int orig_i = i;
 321   if (!check_index(orig_i, i, st))  return;
 322 
 323   ConstantPool* constants = method()->constants();
 324   constantTag tag = constants->tag_at(i);
 325 
 326   if (tag.is_int()) {
 327     st->print_cr(" " INT32_FORMAT, constants->int_at(i));
 328   } else if (tag.is_long()) {
 329     st->print_cr(" " INT64_FORMAT, (int64_t)(constants->long_at(i)));
 330   } else if (tag.is_float()) {
 331     st->print_cr(" %f", constants->float_at(i));
 332   } else if (tag.is_double()) {
 333     st->print_cr(" %f", constants->double_at(i));
 334   } else if (tag.is_string()) {
 335     const char* string = constants->string_at_noresolve(i);
 336     st->print_cr(" %s", string);
 337   } else if (tag.is_klass()) {
 338     st->print_cr(" %s", constants->resolved_klass_at(i)->external_name());
 339   } else if (tag.is_unresolved_klass()) {
 340     st->print_cr(" <unresolved klass at %d>", i);
 341   } else if (tag.is_method_type()) {
 342     int i2 = constants->method_type_index_at(i);
 343     st->print(" <MethodType> %d", i2);
 344     print_symbol(constants->symbol_at(i2), st);
 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 index at %d>", kind, i2);
 349     print_field_or_method(-i, i2, st);
 350   } else {
 351     st->print_cr(" bad tag=%d at %d", tag.value(), i);
 352   }
 353 }
 354 
 355 void BytecodePrinter::print_field_or_method(int i, outputStream* st) {
 356   int orig_i = i;
 357   if (!check_index(orig_i, i, st))  return;
 358   print_field_or_method(orig_i, i, st);
 359 }
 360 
 361 void BytecodePrinter::print_field_or_method(int orig_i, int i, outputStream* st) {
 362   ConstantPool* constants = method()->constants();
 363   constantTag tag = constants->tag_at(i);
 364 
 365   bool has_klass = true;
 366 
 367   switch (tag.value()) {
 368   case JVM_CONSTANT_InterfaceMethodref:
 369   case JVM_CONSTANT_Methodref:
 370   case JVM_CONSTANT_Fieldref:
 371     break;
 372   case JVM_CONSTANT_NameAndType:
 373   case JVM_CONSTANT_InvokeDynamic:
 374     has_klass = false;
 375     break;
 376   default:
 377     st->print_cr(" bad tag=%d at %d", tag.value(), i);
 378     return;
 379   }
 380 
 381   Symbol* name = constants->uncached_name_ref_at(i);
 382   Symbol* signature = constants->uncached_signature_ref_at(i);
 383   const char* sep = (tag.is_field() ? "/" : "");
 384   if (has_klass) {
 385     Symbol* klass = constants->klass_name_at(constants->uncached_klass_ref_index_at(i));
 386     st->print_cr(" %d <%s.%s%s%s> ", i, klass->as_C_string(), name->as_C_string(), sep, signature->as_C_string());
 387   } else {
 388     if (tag.is_invoke_dynamic()) {
 389       int bsm = constants->invoke_dynamic_bootstrap_method_ref_index_at(i);
 390       st->print(" bsm=%d", bsm);
 391     }
 392     st->print_cr(" %d <%s%s%s>", i, name->as_C_string(), sep, signature->as_C_string());
 393   }
 394 }
 395 
 396 
 397 void BytecodePrinter::print_attributes(int bci, outputStream* st) {
 398   // Show attributes of pre-rewritten codes
 399   Bytecodes::Code code = Bytecodes::java_code(raw_code());
 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:
 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       }
 422       break;
 423 
 424     case Bytecodes::_ldc_w:
 425     case Bytecodes::_ldc2_w:
 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       }
 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::_vload:
 439     case Bytecodes::_istore:
 440     case Bytecodes::_lstore:
 441     case Bytecodes::_fstore:
 442     case Bytecodes::_dstore:
 443     case Bytecodes::_astore:
 444     case Bytecodes::_vstore:
 445       st->print_cr(" #%d", get_index_special());
 446       break;
 447 
 448     case Bytecodes::_iinc:
 449       { int index = get_index_special();
 450         jint offset = is_wide() ? get_short(): get_byte();
 451         st->print_cr(" #%d " INT32_FORMAT, index, offset);
 452       }
 453       break;
 454 
 455     case Bytecodes::_newarray: {
 456         BasicType atype = (BasicType)get_index_u1();
 457         const char* str = type2name(atype);
 458         if (str == NULL || atype == T_OBJECT || atype == T_ARRAY) {
 459           assert(false, "Unidentified basic type");
 460         }
 461         st->print_cr(" %s", str);
 462       }
 463       break;
 464     case Bytecodes::_anewarray: {
 465         int klass_index = get_index_u2();
 466         ConstantPool* constants = method()->constants();
 467         Symbol* name = constants->klass_name_at(klass_index);
 468         st->print_cr(" %s ", name->as_C_string());
 469       }
 470       break;
 471     case Bytecodes::_multianewarray: {
 472         int klass_index = get_index_u2();
 473         int nof_dims = get_index_u1();
 474         ConstantPool* constants = method()->constants();
 475         Symbol* name = constants->klass_name_at(klass_index);
 476         st->print_cr(" %s %d", name->as_C_string(), nof_dims);
 477       }
 478       break;
 479 
 480     case Bytecodes::_ifeq:
 481     case Bytecodes::_ifnull:
 482     case Bytecodes::_iflt:
 483     case Bytecodes::_ifle:
 484     case Bytecodes::_ifne:
 485     case Bytecodes::_ifnonnull:
 486     case Bytecodes::_ifgt:
 487     case Bytecodes::_ifge:
 488     case Bytecodes::_if_icmpeq:
 489     case Bytecodes::_if_icmpne:
 490     case Bytecodes::_if_icmplt:
 491     case Bytecodes::_if_icmpgt:
 492     case Bytecodes::_if_icmple:
 493     case Bytecodes::_if_icmpge:
 494     case Bytecodes::_if_acmpeq:
 495     case Bytecodes::_if_acmpne:
 496     case Bytecodes::_goto:
 497     case Bytecodes::_jsr:
 498       st->print_cr(" %d", bci + get_short());
 499       break;
 500 
 501     case Bytecodes::_goto_w:
 502     case Bytecodes::_jsr_w:
 503       st->print_cr(" %d", bci + get_int());
 504       break;
 505 
 506     case Bytecodes::_ret: st->print_cr(" %d", get_index_special()); break;
 507 
 508     case Bytecodes::_tableswitch:
 509       { align();
 510         int  default_dest = bci + get_int();
 511         int  lo           = get_int();
 512         int  hi           = get_int();
 513         int  len          = hi - lo + 1;
 514         jint* dest        = NEW_RESOURCE_ARRAY(jint, len);
 515         for (int i = 0; i < len; i++) {
 516           dest[i] = bci + get_int();
 517         }
 518         st->print(" %d " INT32_FORMAT " " INT32_FORMAT " ",
 519                       default_dest, lo, hi);
 520         const char *comma = "";
 521         for (int ll = lo; ll <= hi; ll++) {
 522           int idx = ll - lo;
 523           st->print("%s %d:" INT32_FORMAT " (delta: %d)", comma, ll, dest[idx], dest[idx]-bci);
 524           comma = ",";
 525         }
 526         st->cr();
 527       }
 528       break;
 529     case Bytecodes::_lookupswitch:
 530       { align();
 531         int  default_dest = bci + get_int();
 532         int  len          = get_int();
 533         jint* key         = NEW_RESOURCE_ARRAY(jint, len);
 534         jint* dest        = NEW_RESOURCE_ARRAY(jint, len);
 535         for (int i = 0; i < len; i++) {
 536           key [i] = get_int();
 537           dest[i] = bci + get_int();
 538         };
 539         st->print(" %d %d ", default_dest, len);
 540         const char *comma = "";
 541         for (int ll = 0; ll < len; ll++)  {
 542           st->print("%s " INT32_FORMAT ":" INT32_FORMAT, comma, key[ll], dest[ll]);
 543           comma = ",";
 544         }
 545         st->cr();
 546       }
 547       break;
 548 
 549     case Bytecodes::_putstatic:
 550     case Bytecodes::_getstatic:
 551     case Bytecodes::_putfield:
 552     case Bytecodes::_getfield:
 553     case Bytecodes::_vgetfield:
 554       print_field_or_method(get_index_u2_cpcache(), st);
 555       break;
 556 
 557     case Bytecodes::_invokevirtual:
 558     case Bytecodes::_invokedirect:
 559     case Bytecodes::_invokespecial:
 560     case Bytecodes::_invokestatic:
 561       print_field_or_method(get_index_u2_cpcache(), st);
 562       break;
 563 
 564     case Bytecodes::_invokeinterface:
 565       { int i = get_index_u2_cpcache();
 566         int n = get_index_u1();
 567         get_byte();            // ignore zero byte
 568         print_field_or_method(i, st);
 569       }
 570       break;
 571 
 572     case Bytecodes::_invokedynamic:
 573       print_field_or_method(get_index_u4(), st);
 574       break;
 575 
 576     case Bytecodes::_new:
 577     case Bytecodes::_checkcast:
 578     case Bytecodes::_instanceof:
 579     case Bytecodes::_vbox:
 580     case Bytecodes::_vunbox:
 581       { int i = get_index_u2();
 582         ConstantPool* constants = method()->constants();
 583         Symbol* name = constants->klass_name_at(i);
 584         st->print_cr(" %d <%s>", i, name->as_C_string());
 585       }
 586       break;
 587     case Bytecodes::_vnew:
 588       { int i = get_index_u2();
 589         ConstantPool* constants = method()->constants();
 590         int class_index = constants->uncached_klass_ref_index_at(i);
 591         Symbol* classname = constants->klass_name_at(class_index);
 592         Symbol* method_name = constants->uncached_name_ref_at(i);
 593         Symbol* method_signature = constants->uncached_signature_ref_at(i);
 594         st->print_cr(" %d <%s.%s%s>", i, classname->as_C_string(),
 595             method_name->as_C_string(), method_signature->as_C_string());
 596       }
 597     break;
 598 
 599     case Bytecodes::_wide:
 600       // length is zero not one, but printed with no more info.
 601       break;
 602 
 603     default:
 604       ShouldNotReachHere();
 605       break;
 606   }
 607 }
 608 
 609 
 610 void BytecodePrinter::bytecode_epilog(int bci, outputStream* st) {
 611   MethodData* mdo = method()->method_data();
 612   if (mdo != NULL) {
 613     ProfileData* data = mdo->bci_to_data(bci);
 614     if (data != NULL) {
 615       st->print("  %d", mdo->dp_to_di(data->dp()));
 616       st->fill_to(6);
 617       data->print_data_on(st, mdo);
 618     }
 619   }
 620 }