470 } 471 472 return use_new_version ? 473 (address) 474 (*Disassembler::_decode_instructions_virtual)((uintptr_t)start, (uintptr_t)end, 475 start, end - start, 476 &event_to_env, (void*) this, 477 &printf_to_env, (void*) this, 478 options(), 0/*nice new line*/) 479 : 480 (address) 481 (*Disassembler::_decode_instructions)(start, end, 482 &event_to_env, (void*) this, 483 &printf_to_env, (void*) this, 484 options()); 485 } 486 487 488 void Disassembler::decode(CodeBlob* cb, outputStream* st) { 489 if (!load_library()) return; 490 decode_env env(cb, st); 491 env.output()->print_cr("Decoding CodeBlob " PTR_FORMAT, cb); 492 env.decode_instructions(cb->code_begin(), cb->code_end()); 493 } 494 495 void Disassembler::decode(address start, address end, outputStream* st, CodeStrings c) { 496 if (!load_library()) return; 497 decode_env env(CodeCache::find_blob_unsafe(start), st, c); 498 env.decode_instructions(start, end); 499 } 500 501 void Disassembler::decode(nmethod* nm, outputStream* st) { 502 if (!load_library()) return; 503 decode_env env(nm, st); 504 env.output()->print_cr("Decoding compiled method " PTR_FORMAT ":", nm); 505 env.output()->print_cr("Code:"); 506 507 #ifdef SHARK 508 SharkEntry* entry = (SharkEntry *) nm->code_begin(); 509 unsigned char* p = entry->code_start(); 510 unsigned char* end = entry->code_limit(); 511 #else 512 unsigned char* p = nm->code_begin(); 513 unsigned char* end = nm->code_end(); 514 #endif // SHARK 515 516 // If there has been profiling, print the buckets. 517 if (FlatProfiler::bucket_start_for(p) != NULL) { 518 unsigned char* p1 = p; 519 int total_bucket_count = 0; 520 while (p1 < end) { 521 unsigned char* p0 = p1; 522 p1 += pd_instruction_alignment(); 523 address bucket_pc = FlatProfiler::bucket_start_for(p1); 524 if (bucket_pc != NULL && bucket_pc > p0 && bucket_pc <= p1) 525 total_bucket_count += FlatProfiler::bucket_count_for(p0); 526 } 527 env.set_total_ticks(total_bucket_count); 528 } 529 530 // Print constant table. 531 if (nm->consts_size() > 0) { 532 nm->print_nmethod_labels(env.output(), nm->consts_begin()); 533 int offset = 0; 534 for (address p = nm->consts_begin(); p < nm->consts_end(); p += 4, offset += 4) { 535 if ((offset % 8) == 0) { | 470 } 471 472 return use_new_version ? 473 (address) 474 (*Disassembler::_decode_instructions_virtual)((uintptr_t)start, (uintptr_t)end, 475 start, end - start, 476 &event_to_env, (void*) this, 477 &printf_to_env, (void*) this, 478 options(), 0/*nice new line*/) 479 : 480 (address) 481 (*Disassembler::_decode_instructions)(start, end, 482 &event_to_env, (void*) this, 483 &printf_to_env, (void*) this, 484 options()); 485 } 486 487 488 void Disassembler::decode(CodeBlob* cb, outputStream* st) { 489 if (!load_library()) return; 490 if (cb->is_nmethod()) { 491 decode((nmethod*)cb, st); 492 return; 493 } 494 decode_env env(cb, st); 495 env.output()->print_cr("----------------------------------------------------------------------"); 496 env.output()->print_cr("%s", cb->name()); 497 env.output()->print_cr(" at [" PTR_FORMAT ", " PTR_FORMAT "] %d bytes", cb->code_begin(), cb->code_end(), ((jlong)(cb->code_end() - cb->code_begin())) * sizeof(unsigned char*)); 498 env.decode_instructions(cb->code_begin(), cb->code_end()); 499 } 500 501 void Disassembler::decode(address start, address end, outputStream* st, CodeStrings c) { 502 if (!load_library()) return; 503 decode_env env(CodeCache::find_blob_unsafe(start), st, c); 504 env.decode_instructions(start, end); 505 } 506 507 void Disassembler::decode(nmethod* nm, outputStream* st) { 508 if (!load_library()) return; 509 decode_env env(nm, st); 510 env.output()->print_cr("----------------------------------------------------------------------"); 511 512 #ifdef SHARK 513 SharkEntry* entry = (SharkEntry *) nm->code_begin(); 514 unsigned char* p = entry->code_start(); 515 unsigned char* end = entry->code_limit(); 516 #else 517 unsigned char* p = nm->code_begin(); 518 unsigned char* end = nm->code_end(); 519 #endif // SHARK 520 521 nm->method()->method_holder()->name()->print_symbol_on(env.output()); 522 env.output()->print("."); 523 nm->method()->name()->print_symbol_on(env.output()); 524 nm->method()->signature()->print_symbol_on(env.output()); 525 #if INCLUDE_JVMCI 526 { 527 char buffer[O_BUFLEN]; 528 char* jvmciName = nm->jvmci_installed_code_name(buffer, O_BUFLEN); 529 if (jvmciName != NULL) { 530 env.output()->print(" (%s)", jvmciName); 531 } 532 } 533 #endif 534 env.output()->print_cr(" [" PTR_FORMAT ", " PTR_FORMAT "] %d bytes", p, end, ((jlong)(end - p))); 535 536 // If there has been profiling, print the buckets. 537 if (FlatProfiler::bucket_start_for(p) != NULL) { 538 unsigned char* p1 = p; 539 int total_bucket_count = 0; 540 while (p1 < end) { 541 unsigned char* p0 = p1; 542 p1 += pd_instruction_alignment(); 543 address bucket_pc = FlatProfiler::bucket_start_for(p1); 544 if (bucket_pc != NULL && bucket_pc > p0 && bucket_pc <= p1) 545 total_bucket_count += FlatProfiler::bucket_count_for(p0); 546 } 547 env.set_total_ticks(total_bucket_count); 548 } 549 550 // Print constant table. 551 if (nm->consts_size() > 0) { 552 nm->print_nmethod_labels(env.output(), nm->consts_begin()); 553 int offset = 0; 554 for (address p = nm->consts_begin(); p < nm->consts_end(); p += 4, offset += 4) { 555 if ((offset % 8) == 0) { |