Sun, 11 Oct 2009 16:19:25 -0700
6888953: some calls to function-like macros are missing semicolons
Reviewed-by: pbk, kvn
duke@435 | 1 | /* |
xdono@1279 | 2 | * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
duke@435 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@435 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@435 | 21 | * have any questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
duke@435 | 25 | #include "incls/_precompiled.incl" |
duke@435 | 26 | #include "incls/_bytecodeTracer.cpp.incl" |
duke@435 | 27 | |
duke@435 | 28 | |
duke@435 | 29 | #ifndef PRODUCT |
duke@435 | 30 | |
duke@435 | 31 | // Standard closure for BytecodeTracer: prints the current bytecode |
duke@435 | 32 | // and its attributes using bytecode-specific information. |
duke@435 | 33 | |
duke@435 | 34 | class BytecodePrinter: public BytecodeClosure { |
duke@435 | 35 | private: |
duke@435 | 36 | // %%% This field is not GC-ed, and so can contain garbage |
duke@435 | 37 | // between critical sections. Use only pointer-comparison |
duke@435 | 38 | // operations on the pointer, except within a critical section. |
duke@435 | 39 | // (Also, ensure that occasional false positives are benign.) |
duke@435 | 40 | methodOop _current_method; |
duke@435 | 41 | bool _is_wide; |
duke@435 | 42 | address _next_pc; // current decoding position |
duke@435 | 43 | |
duke@435 | 44 | void align() { _next_pc = (address)round_to((intptr_t)_next_pc, sizeof(jint)); } |
duke@435 | 45 | int get_byte() { return *(jbyte*) _next_pc++; } // signed |
duke@435 | 46 | short get_short() { short i=Bytes::get_Java_u2(_next_pc); _next_pc+=2; return i; } |
duke@435 | 47 | int get_int() { int i=Bytes::get_Java_u4(_next_pc); _next_pc+=4; return i; } |
duke@435 | 48 | |
duke@435 | 49 | int get_index() { return *(address)_next_pc++; } |
duke@435 | 50 | int get_big_index() { int i=Bytes::get_Java_u2(_next_pc); _next_pc+=2; return i; } |
jrose@1161 | 51 | int get_giant_index() { int i=Bytes::get_native_u4(_next_pc); _next_pc+=4; return i; } |
duke@435 | 52 | int get_index_special() { return (is_wide()) ? get_big_index() : get_index(); } |
duke@435 | 53 | methodOop method() { return _current_method; } |
duke@435 | 54 | bool is_wide() { return _is_wide; } |
duke@435 | 55 | |
duke@435 | 56 | |
jrose@1161 | 57 | bool check_index(int i, bool in_cp_cache, int& cp_index, outputStream* st = tty); |
duke@435 | 58 | void print_constant(int i, outputStream* st = tty); |
jrose@1161 | 59 | void print_field_or_method(int i, outputStream* st = tty); |
duke@435 | 60 | void print_attributes(Bytecodes::Code code, int bci, outputStream* st = tty); |
duke@435 | 61 | void bytecode_epilog(int bci, outputStream* st = tty); |
duke@435 | 62 | |
duke@435 | 63 | public: |
duke@435 | 64 | BytecodePrinter() { |
duke@435 | 65 | _is_wide = false; |
duke@435 | 66 | } |
duke@435 | 67 | |
duke@435 | 68 | // This method is called while executing the raw bytecodes, so none of |
duke@435 | 69 | // the adjustments that BytecodeStream performs applies. |
duke@435 | 70 | void trace(methodHandle method, address bcp, uintptr_t tos, uintptr_t tos2, outputStream* st) { |
duke@435 | 71 | ResourceMark rm; |
duke@435 | 72 | if (_current_method != method()) { |
duke@435 | 73 | // Note 1: This code will not work as expected with true MT/MP. |
duke@435 | 74 | // Need an explicit lock or a different solution. |
duke@435 | 75 | // It is possible for this block to be skipped, if a garbage |
duke@435 | 76 | // _current_method pointer happens to have the same bits as |
duke@435 | 77 | // the incoming method. We could lose a line of trace output. |
duke@435 | 78 | // This is acceptable in a debug-only feature. |
duke@435 | 79 | st->cr(); |
duke@435 | 80 | st->print("[%d] ", (int) Thread::current()->osthread()->thread_id()); |
duke@435 | 81 | method->print_name(st); |
duke@435 | 82 | st->cr(); |
duke@435 | 83 | _current_method = method(); |
duke@435 | 84 | } |
duke@435 | 85 | Bytecodes::Code code; |
duke@435 | 86 | if (is_wide()) { |
duke@435 | 87 | // bcp wasn't advanced if previous bytecode was _wide. |
duke@435 | 88 | code = Bytecodes::code_at(bcp+1); |
duke@435 | 89 | } else { |
duke@435 | 90 | code = Bytecodes::code_at(bcp); |
duke@435 | 91 | } |
duke@435 | 92 | int bci = bcp - method->code_base(); |
duke@435 | 93 | st->print("[%d] ", (int) Thread::current()->osthread()->thread_id()); |
duke@435 | 94 | if (Verbose) { |
duke@435 | 95 | st->print("%8d %4d " INTPTR_FORMAT " " INTPTR_FORMAT " %s", |
duke@435 | 96 | BytecodeCounter::counter_value(), bci, tos, tos2, Bytecodes::name(code)); |
duke@435 | 97 | } else { |
duke@435 | 98 | st->print("%8d %4d %s", |
duke@435 | 99 | BytecodeCounter::counter_value(), bci, Bytecodes::name(code)); |
duke@435 | 100 | } |
duke@435 | 101 | _next_pc = is_wide() ? bcp+2 : bcp+1; |
duke@435 | 102 | print_attributes(code, bci); |
duke@435 | 103 | // Set is_wide for the next one, since the caller of this doesn't skip |
duke@435 | 104 | // the next bytecode. |
duke@435 | 105 | _is_wide = (code == Bytecodes::_wide); |
duke@435 | 106 | } |
duke@435 | 107 | |
duke@435 | 108 | // Used for methodOop::print_codes(). The input bcp comes from |
duke@435 | 109 | // BytecodeStream, which will skip wide bytecodes. |
duke@435 | 110 | void trace(methodHandle method, address bcp, outputStream* st) { |
duke@435 | 111 | _current_method = method(); |
duke@435 | 112 | ResourceMark rm; |
duke@435 | 113 | Bytecodes::Code code = Bytecodes::code_at(bcp); |
duke@435 | 114 | // Set is_wide |
duke@435 | 115 | _is_wide = (code == Bytecodes::_wide); |
duke@435 | 116 | if (is_wide()) { |
duke@435 | 117 | code = Bytecodes::code_at(bcp+1); |
duke@435 | 118 | } |
duke@435 | 119 | int bci = bcp - method->code_base(); |
duke@435 | 120 | // Print bytecode index and name |
duke@435 | 121 | if (is_wide()) { |
duke@435 | 122 | st->print("%d %s_w", bci, Bytecodes::name(code)); |
duke@435 | 123 | } else { |
duke@435 | 124 | st->print("%d %s", bci, Bytecodes::name(code)); |
duke@435 | 125 | } |
duke@435 | 126 | _next_pc = is_wide() ? bcp+2 : bcp+1; |
duke@435 | 127 | print_attributes(code, bci, st); |
duke@435 | 128 | bytecode_epilog(bci, st); |
duke@435 | 129 | } |
duke@435 | 130 | }; |
duke@435 | 131 | |
duke@435 | 132 | |
duke@435 | 133 | // Implementation of BytecodeTracer |
duke@435 | 134 | |
duke@435 | 135 | // %%% This set_closure thing seems overly general, given that |
duke@435 | 136 | // nobody uses it. Also, if BytecodePrinter weren't hidden |
duke@435 | 137 | // then methodOop could use instances of it directly and it |
duke@435 | 138 | // would be easier to remove races on _current_method and bcp. |
duke@435 | 139 | // Since this is not product functionality, we can defer cleanup. |
duke@435 | 140 | |
duke@435 | 141 | BytecodeClosure* BytecodeTracer::_closure = NULL; |
duke@435 | 142 | |
duke@435 | 143 | static BytecodePrinter std_closure; |
duke@435 | 144 | BytecodeClosure* BytecodeTracer::std_closure() { |
duke@435 | 145 | return &::std_closure; |
duke@435 | 146 | } |
duke@435 | 147 | |
duke@435 | 148 | |
duke@435 | 149 | void BytecodeTracer::trace(methodHandle method, address bcp, uintptr_t tos, uintptr_t tos2, outputStream* st) { |
duke@435 | 150 | if (TraceBytecodes && BytecodeCounter::counter_value() >= TraceBytecodesAt) { |
duke@435 | 151 | ttyLocker ttyl; // 5065316: keep the following output coherent |
duke@435 | 152 | // The ttyLocker also prevents races between two threads |
duke@435 | 153 | // trying to use the single instance of BytecodePrinter. |
duke@435 | 154 | // Using the ttyLocker prevents the system from coming to |
duke@435 | 155 | // a safepoint within this code, which is sensitive to methodOop |
duke@435 | 156 | // movement. |
duke@435 | 157 | // |
duke@435 | 158 | // There used to be a leaf mutex here, but the ttyLocker will |
duke@435 | 159 | // work just as well, as long as the printing operations never block. |
duke@435 | 160 | // |
duke@435 | 161 | // We put the locker on the static trace method, not the |
duke@435 | 162 | // virtual one, because the clients of this module go through |
duke@435 | 163 | // the static method. |
duke@435 | 164 | _closure->trace(method, bcp, tos, tos2, st); |
duke@435 | 165 | } |
duke@435 | 166 | } |
duke@435 | 167 | |
duke@435 | 168 | void BytecodeTracer::trace(methodHandle method, address bcp, outputStream* st) { |
duke@435 | 169 | ttyLocker ttyl; // 5065316: keep the following output coherent |
duke@435 | 170 | _closure->trace(method, bcp, st); |
duke@435 | 171 | } |
duke@435 | 172 | |
duke@435 | 173 | void print_oop(oop value, outputStream* st) { |
duke@435 | 174 | if (value == NULL) { |
duke@435 | 175 | st->print_cr(" NULL"); |
duke@435 | 176 | } else { |
duke@435 | 177 | EXCEPTION_MARK; |
duke@435 | 178 | Handle h_value (THREAD, value); |
duke@435 | 179 | symbolHandle sym = java_lang_String::as_symbol(h_value, CATCH); |
duke@435 | 180 | if (sym->utf8_length() > 32) { |
duke@435 | 181 | st->print_cr(" ...."); |
duke@435 | 182 | } else { |
duke@435 | 183 | sym->print_on(st); st->cr(); |
duke@435 | 184 | } |
duke@435 | 185 | } |
duke@435 | 186 | } |
duke@435 | 187 | |
jrose@1161 | 188 | bool BytecodePrinter::check_index(int i, bool in_cp_cache, int& cp_index, outputStream* st) { |
jrose@1161 | 189 | constantPoolOop constants = method()->constants(); |
jrose@1161 | 190 | int ilimit = constants->length(), climit = 0; |
jrose@1161 | 191 | |
jrose@1161 | 192 | constantPoolCacheOop cache = NULL; |
jrose@1161 | 193 | if (in_cp_cache) { |
jrose@1161 | 194 | cache = constants->cache(); |
jrose@1161 | 195 | if (cache != NULL) { |
jrose@1161 | 196 | //climit = cache->length(); // %%% private! |
jrose@1161 | 197 | size_t size = cache->size() * HeapWordSize; |
jrose@1161 | 198 | size -= sizeof(constantPoolCacheOopDesc); |
jrose@1161 | 199 | size /= sizeof(ConstantPoolCacheEntry); |
jrose@1161 | 200 | climit = (int) size; |
jrose@1161 | 201 | } |
jrose@1161 | 202 | } |
jrose@1161 | 203 | |
jrose@1161 | 204 | if (in_cp_cache && constantPoolCacheOopDesc::is_secondary_index(i)) { |
jrose@1161 | 205 | i = constantPoolCacheOopDesc::decode_secondary_index(i); |
jrose@1161 | 206 | st->print(" secondary cache[%d] of", i); |
jrose@1161 | 207 | if (i >= 0 && i < climit) { |
jrose@1161 | 208 | if (!cache->entry_at(i)->is_secondary_entry()) { |
jrose@1161 | 209 | st->print_cr(" not secondary entry?", i); |
jrose@1161 | 210 | return false; |
jrose@1161 | 211 | } |
jrose@1161 | 212 | i = cache->entry_at(i)->main_entry_index(); |
jrose@1161 | 213 | goto check_cache_index; |
jrose@1161 | 214 | } else { |
jrose@1161 | 215 | st->print_cr(" not in cache[*]?", i); |
jrose@1161 | 216 | return false; |
jrose@1161 | 217 | } |
jrose@1161 | 218 | } |
jrose@1161 | 219 | |
jrose@1161 | 220 | if (cache != NULL) { |
jrose@1161 | 221 | i = Bytes::swap_u2(i); |
jrose@1161 | 222 | if (WizardMode) st->print(" (swap=%d)", i); |
jrose@1161 | 223 | goto check_cache_index; |
jrose@1161 | 224 | } |
jrose@1161 | 225 | |
jrose@1161 | 226 | check_cp_index: |
jrose@1161 | 227 | if (i >= 0 && i < ilimit) { |
jrose@1161 | 228 | if (WizardMode) st->print(" cp[%d]", i); |
jrose@1161 | 229 | cp_index = i; |
jrose@1161 | 230 | return true; |
jrose@1161 | 231 | } |
jrose@1161 | 232 | |
jrose@1161 | 233 | st->print_cr(" CP[%d] not in CP", i); |
jrose@1161 | 234 | return false; |
jrose@1161 | 235 | |
jrose@1161 | 236 | check_cache_index: |
jrose@1161 | 237 | if (i >= 0 && i < climit) { |
jrose@1161 | 238 | if (cache->entry_at(i)->is_secondary_entry()) { |
jrose@1161 | 239 | st->print_cr(" secondary entry?"); |
jrose@1161 | 240 | return false; |
jrose@1161 | 241 | } |
jrose@1161 | 242 | i = cache->entry_at(i)->constant_pool_index(); |
jrose@1161 | 243 | goto check_cp_index; |
jrose@1161 | 244 | } |
jrose@1161 | 245 | st->print_cr(" not in CP[*]?", i); |
jrose@1161 | 246 | return false; |
jrose@1161 | 247 | } |
jrose@1161 | 248 | |
duke@435 | 249 | void BytecodePrinter::print_constant(int i, outputStream* st) { |
jrose@1161 | 250 | int orig_i = i; |
jrose@1161 | 251 | if (!check_index(orig_i, false, i, st)) return; |
jrose@1161 | 252 | |
duke@435 | 253 | constantPoolOop constants = method()->constants(); |
duke@435 | 254 | constantTag tag = constants->tag_at(i); |
duke@435 | 255 | |
duke@435 | 256 | if (tag.is_int()) { |
duke@435 | 257 | st->print_cr(" " INT32_FORMAT, constants->int_at(i)); |
duke@435 | 258 | } else if (tag.is_long()) { |
duke@435 | 259 | st->print_cr(" " INT64_FORMAT, constants->long_at(i)); |
duke@435 | 260 | } else if (tag.is_float()) { |
duke@435 | 261 | st->print_cr(" %f", constants->float_at(i)); |
duke@435 | 262 | } else if (tag.is_double()) { |
duke@435 | 263 | st->print_cr(" %f", constants->double_at(i)); |
duke@435 | 264 | } else if (tag.is_string()) { |
duke@435 | 265 | oop string = constants->resolved_string_at(i); |
duke@435 | 266 | print_oop(string, st); |
duke@435 | 267 | } else if (tag.is_unresolved_string()) { |
duke@435 | 268 | st->print_cr(" <unresolved string at %d>", i); |
duke@435 | 269 | } else if (tag.is_klass()) { |
duke@435 | 270 | st->print_cr(" %s", constants->resolved_klass_at(i)->klass_part()->external_name()); |
duke@435 | 271 | } else if (tag.is_unresolved_klass()) { |
duke@435 | 272 | st->print_cr(" <unresolved klass at %d>", i); |
twisti@1573 | 273 | } else if (tag.is_object()) { |
twisti@1573 | 274 | st->print_cr(" " PTR_FORMAT, constants->object_at(i)); |
jrose@1161 | 275 | } else { |
jrose@1161 | 276 | st->print_cr(" bad tag=%d at %d", tag.value(), i); |
jrose@1161 | 277 | } |
jrose@1161 | 278 | } |
jrose@1161 | 279 | |
jrose@1161 | 280 | void BytecodePrinter::print_field_or_method(int i, outputStream* st) { |
jrose@1161 | 281 | int orig_i = i; |
jrose@1161 | 282 | if (!check_index(orig_i, true, i, st)) return; |
jrose@1161 | 283 | |
jrose@1161 | 284 | constantPoolOop constants = method()->constants(); |
jrose@1161 | 285 | constantTag tag = constants->tag_at(i); |
jrose@1161 | 286 | |
jrose@1494 | 287 | int nt_index = -1; |
jrose@1494 | 288 | |
jrose@1161 | 289 | switch (tag.value()) { |
jrose@1161 | 290 | case JVM_CONSTANT_InterfaceMethodref: |
jrose@1161 | 291 | case JVM_CONSTANT_Methodref: |
jrose@1161 | 292 | case JVM_CONSTANT_Fieldref: |
jrose@1494 | 293 | case JVM_CONSTANT_NameAndType: |
jrose@1161 | 294 | break; |
jrose@1161 | 295 | default: |
jrose@1161 | 296 | st->print_cr(" bad tag=%d at %d", tag.value(), i); |
jrose@1161 | 297 | return; |
jrose@1161 | 298 | } |
jrose@1161 | 299 | |
jrose@1494 | 300 | symbolOop name = constants->uncached_name_ref_at(i); |
jrose@1494 | 301 | symbolOop signature = constants->uncached_signature_ref_at(i); |
jrose@1161 | 302 | st->print_cr(" %d <%s> <%s> ", i, name->as_C_string(), signature->as_C_string()); |
duke@435 | 303 | } |
duke@435 | 304 | |
duke@435 | 305 | |
duke@435 | 306 | void BytecodePrinter::print_attributes(Bytecodes::Code code, int bci, outputStream* st) { |
duke@435 | 307 | // Show attributes of pre-rewritten codes |
kvn@1169 | 308 | code = Bytecodes::java_code(code); |
duke@435 | 309 | // If the code doesn't have any fields there's nothing to print. |
duke@435 | 310 | // note this is ==1 because the tableswitch and lookupswitch are |
duke@435 | 311 | // zero size (for some reason) and we want to print stuff out for them. |
duke@435 | 312 | if (Bytecodes::length_for(code) == 1) { |
duke@435 | 313 | st->cr(); |
duke@435 | 314 | return; |
duke@435 | 315 | } |
duke@435 | 316 | |
duke@435 | 317 | switch(code) { |
duke@435 | 318 | // Java specific bytecodes only matter. |
duke@435 | 319 | case Bytecodes::_bipush: |
duke@435 | 320 | st->print_cr(" " INT32_FORMAT, get_byte()); |
duke@435 | 321 | break; |
duke@435 | 322 | case Bytecodes::_sipush: |
duke@435 | 323 | st->print_cr(" " INT32_FORMAT, get_short()); |
duke@435 | 324 | break; |
duke@435 | 325 | case Bytecodes::_ldc: |
duke@435 | 326 | print_constant(get_index(), st); |
duke@435 | 327 | break; |
duke@435 | 328 | |
duke@435 | 329 | case Bytecodes::_ldc_w: |
duke@435 | 330 | case Bytecodes::_ldc2_w: |
duke@435 | 331 | print_constant(get_big_index(), st); |
duke@435 | 332 | break; |
duke@435 | 333 | |
duke@435 | 334 | case Bytecodes::_iload: |
duke@435 | 335 | case Bytecodes::_lload: |
duke@435 | 336 | case Bytecodes::_fload: |
duke@435 | 337 | case Bytecodes::_dload: |
duke@435 | 338 | case Bytecodes::_aload: |
duke@435 | 339 | case Bytecodes::_istore: |
duke@435 | 340 | case Bytecodes::_lstore: |
duke@435 | 341 | case Bytecodes::_fstore: |
duke@435 | 342 | case Bytecodes::_dstore: |
duke@435 | 343 | case Bytecodes::_astore: |
duke@435 | 344 | st->print_cr(" #%d", get_index_special()); |
duke@435 | 345 | break; |
duke@435 | 346 | |
duke@435 | 347 | case Bytecodes::_iinc: |
duke@435 | 348 | { int index = get_index_special(); |
duke@435 | 349 | jint offset = is_wide() ? get_short(): get_byte(); |
duke@435 | 350 | st->print_cr(" #%d " INT32_FORMAT, index, offset); |
duke@435 | 351 | } |
duke@435 | 352 | break; |
duke@435 | 353 | |
duke@435 | 354 | case Bytecodes::_newarray: { |
duke@435 | 355 | BasicType atype = (BasicType)get_index(); |
duke@435 | 356 | const char* str = type2name(atype); |
duke@435 | 357 | if (str == NULL || atype == T_OBJECT || atype == T_ARRAY) { |
duke@435 | 358 | assert(false, "Unidentified basic type"); |
duke@435 | 359 | } |
duke@435 | 360 | st->print_cr(" %s", str); |
duke@435 | 361 | } |
duke@435 | 362 | break; |
duke@435 | 363 | case Bytecodes::_anewarray: { |
duke@435 | 364 | int klass_index = get_big_index(); |
duke@435 | 365 | constantPoolOop constants = method()->constants(); |
duke@435 | 366 | symbolOop name = constants->klass_name_at(klass_index); |
duke@435 | 367 | st->print_cr(" %s ", name->as_C_string()); |
duke@435 | 368 | } |
duke@435 | 369 | break; |
duke@435 | 370 | case Bytecodes::_multianewarray: { |
duke@435 | 371 | int klass_index = get_big_index(); |
duke@435 | 372 | int nof_dims = get_index(); |
duke@435 | 373 | constantPoolOop constants = method()->constants(); |
duke@435 | 374 | symbolOop name = constants->klass_name_at(klass_index); |
duke@435 | 375 | st->print_cr(" %s %d", name->as_C_string(), nof_dims); |
duke@435 | 376 | } |
duke@435 | 377 | break; |
duke@435 | 378 | |
duke@435 | 379 | case Bytecodes::_ifeq: |
duke@435 | 380 | case Bytecodes::_ifnull: |
duke@435 | 381 | case Bytecodes::_iflt: |
duke@435 | 382 | case Bytecodes::_ifle: |
duke@435 | 383 | case Bytecodes::_ifne: |
duke@435 | 384 | case Bytecodes::_ifnonnull: |
duke@435 | 385 | case Bytecodes::_ifgt: |
duke@435 | 386 | case Bytecodes::_ifge: |
duke@435 | 387 | case Bytecodes::_if_icmpeq: |
duke@435 | 388 | case Bytecodes::_if_icmpne: |
duke@435 | 389 | case Bytecodes::_if_icmplt: |
duke@435 | 390 | case Bytecodes::_if_icmpgt: |
duke@435 | 391 | case Bytecodes::_if_icmple: |
duke@435 | 392 | case Bytecodes::_if_icmpge: |
duke@435 | 393 | case Bytecodes::_if_acmpeq: |
duke@435 | 394 | case Bytecodes::_if_acmpne: |
duke@435 | 395 | case Bytecodes::_goto: |
duke@435 | 396 | case Bytecodes::_jsr: |
duke@435 | 397 | st->print_cr(" %d", bci + get_short()); |
duke@435 | 398 | break; |
duke@435 | 399 | |
duke@435 | 400 | case Bytecodes::_goto_w: |
duke@435 | 401 | case Bytecodes::_jsr_w: |
duke@435 | 402 | st->print_cr(" %d", bci + get_int()); |
duke@435 | 403 | break; |
duke@435 | 404 | |
duke@435 | 405 | case Bytecodes::_ret: st->print_cr(" %d", get_index_special()); break; |
duke@435 | 406 | |
duke@435 | 407 | case Bytecodes::_tableswitch: |
duke@435 | 408 | { align(); |
duke@435 | 409 | int default_dest = bci + get_int(); |
duke@435 | 410 | int lo = get_int(); |
duke@435 | 411 | int hi = get_int(); |
duke@435 | 412 | int len = hi - lo + 1; |
duke@435 | 413 | jint* dest = NEW_RESOURCE_ARRAY(jint, len); |
duke@435 | 414 | for (int i = 0; i < len; i++) { |
duke@435 | 415 | dest[i] = bci + get_int(); |
duke@435 | 416 | } |
duke@435 | 417 | st->print(" %d " INT32_FORMAT " " INT32_FORMAT " ", |
duke@435 | 418 | default_dest, lo, hi); |
duke@435 | 419 | int first = true; |
duke@435 | 420 | for (int ll = lo; ll <= hi; ll++, first = false) { |
duke@435 | 421 | int idx = ll - lo; |
duke@435 | 422 | const char *format = first ? " %d:" INT32_FORMAT " (delta: %d)" : |
duke@435 | 423 | ", %d:" INT32_FORMAT " (delta: %d)"; |
duke@435 | 424 | st->print(format, ll, dest[idx], dest[idx]-bci); |
duke@435 | 425 | } |
duke@435 | 426 | st->cr(); |
duke@435 | 427 | } |
duke@435 | 428 | break; |
duke@435 | 429 | case Bytecodes::_lookupswitch: |
duke@435 | 430 | { align(); |
duke@435 | 431 | int default_dest = bci + get_int(); |
duke@435 | 432 | int len = get_int(); |
duke@435 | 433 | jint* key = NEW_RESOURCE_ARRAY(jint, len); |
duke@435 | 434 | jint* dest = NEW_RESOURCE_ARRAY(jint, len); |
duke@435 | 435 | for (int i = 0; i < len; i++) { |
duke@435 | 436 | key [i] = get_int(); |
duke@435 | 437 | dest[i] = bci + get_int(); |
duke@435 | 438 | }; |
duke@435 | 439 | st->print(" %d %d ", default_dest, len); |
duke@435 | 440 | bool first = true; |
duke@435 | 441 | for (int ll = 0; ll < len; ll++, first = false) { |
duke@435 | 442 | const char *format = first ? " " INT32_FORMAT ":" INT32_FORMAT : |
duke@435 | 443 | ", " INT32_FORMAT ":" INT32_FORMAT ; |
duke@435 | 444 | st->print(format, key[ll], dest[ll]); |
duke@435 | 445 | } |
duke@435 | 446 | st->cr(); |
duke@435 | 447 | } |
duke@435 | 448 | break; |
duke@435 | 449 | |
duke@435 | 450 | case Bytecodes::_putstatic: |
duke@435 | 451 | case Bytecodes::_getstatic: |
duke@435 | 452 | case Bytecodes::_putfield: |
jrose@1161 | 453 | case Bytecodes::_getfield: |
jrose@1161 | 454 | print_field_or_method(get_big_index(), st); |
duke@435 | 455 | break; |
duke@435 | 456 | |
duke@435 | 457 | case Bytecodes::_invokevirtual: |
duke@435 | 458 | case Bytecodes::_invokespecial: |
duke@435 | 459 | case Bytecodes::_invokestatic: |
jrose@1161 | 460 | print_field_or_method(get_big_index(), st); |
duke@435 | 461 | break; |
duke@435 | 462 | |
duke@435 | 463 | case Bytecodes::_invokeinterface: |
duke@435 | 464 | { int i = get_big_index(); |
duke@435 | 465 | int n = get_index(); |
jrose@1161 | 466 | get_index(); // ignore zero byte |
jrose@1161 | 467 | print_field_or_method(i, st); |
duke@435 | 468 | } |
duke@435 | 469 | break; |
duke@435 | 470 | |
jrose@1161 | 471 | case Bytecodes::_invokedynamic: |
jrose@1161 | 472 | print_field_or_method(get_giant_index(), st); |
jrose@1161 | 473 | break; |
jrose@1161 | 474 | |
duke@435 | 475 | case Bytecodes::_new: |
duke@435 | 476 | case Bytecodes::_checkcast: |
duke@435 | 477 | case Bytecodes::_instanceof: |
duke@435 | 478 | { int i = get_big_index(); |
duke@435 | 479 | constantPoolOop constants = method()->constants(); |
duke@435 | 480 | symbolOop name = constants->klass_name_at(i); |
duke@435 | 481 | st->print_cr(" %d <%s>", i, name->as_C_string()); |
duke@435 | 482 | } |
duke@435 | 483 | break; |
duke@435 | 484 | |
duke@435 | 485 | case Bytecodes::_wide: |
duke@435 | 486 | // length is zero not one, but printed with no more info. |
duke@435 | 487 | break; |
duke@435 | 488 | |
duke@435 | 489 | default: |
duke@435 | 490 | ShouldNotReachHere(); |
duke@435 | 491 | break; |
duke@435 | 492 | } |
duke@435 | 493 | } |
duke@435 | 494 | |
duke@435 | 495 | |
duke@435 | 496 | void BytecodePrinter::bytecode_epilog(int bci, outputStream* st) { |
duke@435 | 497 | methodDataOop mdo = method()->method_data(); |
duke@435 | 498 | if (mdo != NULL) { |
duke@435 | 499 | ProfileData* data = mdo->bci_to_data(bci); |
duke@435 | 500 | if (data != NULL) { |
duke@435 | 501 | st->print(" %d", mdo->dp_to_di(data->dp())); |
duke@435 | 502 | st->fill_to(6); |
duke@435 | 503 | data->print_data_on(st); |
duke@435 | 504 | } |
duke@435 | 505 | } |
duke@435 | 506 | } |
duke@435 | 507 | #endif // PRODUCT |