8071374: -XX:+PrintAssembly -XX:+PrintSignatureHandlers crash fastdebug VM with assert(limit == __null || limit <= nm->code_end()) in RelocIterator::initialize

Reviewed-by: kvn, iklam, shade
This commit is contained in:
Vladimir Ivanov 2015-12-18 20:23:26 +03:00
parent f642bbcecd
commit a82be01120
13 changed files with 33 additions and 30 deletions

View file

@ -125,7 +125,7 @@ decode_instructions(void* start_pv, void* end_pv,
event_callback_t event_callback_arg, void* event_stream_arg,
printf_callback_t printf_callback_arg, void* printf_stream_arg,
const char* options) {
decode_instructions_virtual((uintptr_t)start_pv,
return decode_instructions_virtual((uintptr_t)start_pv,
(uintptr_t)end_pv,
(unsigned char*)start_pv,
(uintptr_t)end_pv - (uintptr_t)start_pv,
@ -212,6 +212,7 @@ static const char* format_insn_close(const char* close,
case dis_condjsr: type = "condjsr"; break;
case dis_dref: type = "dref"; break;
case dis_dref2: type = "dref2"; break;
case dis_noninsn: type = "noninsn"; break;
}
strcpy(buf, close);

View file

@ -1030,6 +1030,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i
address copy_buff = stub_location - *byte_skip - *byte_count;
address being_initialized_entry = stub_location - *being_initialized_entry_offset;
if (TracePatching) {
ttyLocker ttyl;
tty->print_cr(" Patching %s at bci %d at address " INTPTR_FORMAT " (%s)", Bytecodes::name(code), bci,
p2i(instr_pc), (stub_id == Runtime1::access_field_patching_id) ? "field" : "klass");
nmethod* caller_code = CodeCache::find_nmethod(caller_frame.pc());

View file

@ -1045,9 +1045,6 @@ void ciEnv::register_method(ciMethod* target,
if (printnmethods || PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers) {
nm->print_nmethod(printnmethods);
}
if (directives->PrintAssemblyOption) {
Disassembler::decode(nm);
}
nm->set_has_unsafe_access(has_unsafe_access);
nm->set_has_wide_vectors(has_wide_vectors);

View file

@ -181,6 +181,11 @@ const ImmutableOopMap* CodeBlob::oop_map_for_return_address(address return_addre
return oop_maps()->find_map_at_offset((intptr_t) return_address - (intptr_t) code_begin());
}
void CodeBlob::print_code() {
HandleMark hm;
ResourceMark m;
Disassembler::decode(this, tty);
}
//----------------------------------------------------------------------------------------------------
// Implementation of BufferBlob

View file

@ -196,6 +196,7 @@ class CodeBlob VALUE_OBJ_CLASS_SPEC {
void print() const { print_on(tty); }
virtual void print_on(outputStream* st) const;
virtual void print_value_on(outputStream* st) const;
void print_code();
// Deal with Disassembler, VTune, Forte, JvmtiExport, MemoryService.
static void trace_new_stub(CodeBlob* blob, const char* name1, const char* name2 = "");

View file

@ -2639,6 +2639,7 @@ address nmethod::continuation_for_implicit_exception(address pc) {
ResourceMark rm(thread);
CodeBlob* cb = CodeCache::find_blob(pc);
assert(cb != NULL && cb == this, "");
ttyLocker ttyl;
tty->print_cr("implicit exception happened at " INTPTR_FORMAT, p2i(pc));
print();
method()->print_codes();
@ -2960,13 +2961,6 @@ void nmethod::print() const {
nul_chk_table_size());
}
void nmethod::print_code() {
HandleMark hm;
ResourceMark m;
Disassembler::decode(this);
}
#ifndef PRODUCT
void nmethod::print_scopes() {

View file

@ -704,7 +704,6 @@ public:
// printing support
void print() const;
void print_code();
void print_relocations() PRODUCT_RETURN;
void print_pcs() PRODUCT_RETURN;
void print_scopes() PRODUCT_RETURN;

View file

@ -497,6 +497,7 @@ address decode_env::decode_instructions(address start, address end) {
void Disassembler::decode(CodeBlob* cb, outputStream* st) {
ttyLocker ttyl;
if (!load_library()) return;
if (cb->is_nmethod()) {
decode((nmethod*)cb, st);
@ -510,12 +511,14 @@ void Disassembler::decode(CodeBlob* cb, outputStream* st) {
}
void Disassembler::decode(address start, address end, outputStream* st, CodeStrings c) {
ttyLocker ttyl;
if (!load_library()) return;
decode_env env(CodeCache::find_blob_unsafe(start), st, c);
env.decode_instructions(start, end);
}
void Disassembler::decode(nmethod* nm, outputStream* st) {
ttyLocker ttyl;
if (!load_library()) return;
decode_env env(nm, st);
env.output()->print_cr("----------------------------------------------------------------------");

View file

@ -1252,6 +1252,7 @@ void SignatureHandlerLibrary::add(const methodHandle& method) {
} else {
// debugging suppport
if (PrintSignatureHandlers && (handler != Interpreter::slow_signature_handler())) {
ttyLocker ttyl;
tty->cr();
tty->print_cr("argument handler #%d for: %s %s (fingerprint = " UINT64_FORMAT ", %d bytes generated)",
_handlers->length(),

View file

@ -897,10 +897,8 @@ C2V_VMENTRY(jobject, disassembleCodeBlob, (JNIEnv *jniEnv, jobject, jobject inst
if (!nm->is_alive()) {
return NULL;
}
Disassembler::decode(nm, &st);
} else {
Disassembler::decode(cb, &st);
}
Disassembler::decode(cb, &st);
if (st.size() <= 0) {
return NULL;
}

View file

@ -726,6 +726,7 @@ address SharedRuntime::compute_compiled_exc_handler(nmethod* nm, address ret_pc,
#endif
if (t == NULL) {
ttyLocker ttyl;
tty->print_cr("MISSING EXCEPTION HANDLER for pc " INTPTR_FORMAT " and handler bci %d", p2i(ret_pc), handler_bci);
tty->print_cr(" Exception:");
exception->print();
@ -2759,7 +2760,7 @@ void AdapterHandlerLibrary::create_native_wrapper(const methodHandle& method) {
DirectiveSet* directive = DirectivesStack::getDefaultDirective(CompileBroker::compiler(CompLevel_simple));
if (directive->PrintAssemblyOption) {
Disassembler::decode(nm, tty);
nm->print_code();
}
DirectivesStack::release(directive);
}

View file

@ -406,6 +406,7 @@ inline void vframeStreamCommon::fill_from_compiled_frame(int decode_offset) {
// as it were a native compiled frame (no Java-level assumptions).
#ifdef ASSERT
if (WizardMode) {
ttyLocker ttyl;
tty->print_cr("Error in fill_from_frame: pc_desc for "
INTPTR_FORMAT " not found or invalid at %d",
p2i(_frame.pc()), decode_offset);

View file

@ -480,12 +480,13 @@ extern "C" void nm(intptr_t p) {
extern "C" void disnm(intptr_t p) {
Command c("disnm");
CodeBlob* cb = CodeCache::find_blob((address) p);
if (cb != NULL) {
nmethod* nm = cb->as_nmethod_or_null();
if (nm) {
if (nm != NULL) {
nm->print();
Disassembler::decode(nm);
} else {
cb->print();
}
Disassembler::decode(cb);
}
}