changeset 35542:9dccb7f9f656

8071374: -XX:+PrintAssembly -XX:+PrintSignatureHandlers crash fastdebug VM with assert(limit == __null || limit <= nm->code_end()) in RelocIterator::initialize Reviewed-by: kvn, iklam, shade
author vlivanov
date Fri, 18 Dec 2015 20:23:26 +0300
parents cba047a086d5
children 0961315f4016
files hotspot/src/share/tools/hsdis/hsdis.c hotspot/src/share/vm/c1/c1_Runtime1.cpp hotspot/src/share/vm/ci/ciEnv.cpp hotspot/src/share/vm/code/codeBlob.cpp hotspot/src/share/vm/code/codeBlob.hpp hotspot/src/share/vm/code/nmethod.cpp hotspot/src/share/vm/code/nmethod.hpp hotspot/src/share/vm/compiler/disassembler.cpp hotspot/src/share/vm/interpreter/interpreterRuntime.cpp hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp hotspot/src/share/vm/runtime/sharedRuntime.cpp hotspot/src/share/vm/runtime/vframe.hpp hotspot/src/share/vm/utilities/debug.cpp
diffstat 13 files changed, 33 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/src/share/tools/hsdis/hsdis.c	Fri Jan 08 10:14:02 2016 +0100
+++ b/hotspot/src/share/tools/hsdis/hsdis.c	Fri Dec 18 20:23:26 2015 +0300
@@ -125,15 +125,15 @@
                     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,
-                             (uintptr_t)end_pv,
-                             (unsigned char*)start_pv,
-                             (uintptr_t)end_pv - (uintptr_t)start_pv,
-                             event_callback_arg,
-                             event_stream_arg,
-                             printf_callback_arg,
-                             printf_stream_arg,
-                             options, false);
+  return decode_instructions_virtual((uintptr_t)start_pv,
+                                     (uintptr_t)end_pv,
+                                     (unsigned char*)start_pv,
+                                     (uintptr_t)end_pv - (uintptr_t)start_pv,
+                                     event_callback_arg,
+                                     event_stream_arg,
+                                     printf_callback_arg,
+                                     printf_stream_arg,
+                                     options, false);
 }
 
 static void* decode(struct hsdis_app_data* app_data, const char* options) {
@@ -212,6 +212,7 @@
   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);
--- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp	Fri Jan 08 10:14:02 2016 +0100
+++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp	Fri Dec 18 20:23:26 2015 +0300
@@ -1030,6 +1030,7 @@
         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());
--- a/hotspot/src/share/vm/ci/ciEnv.cpp	Fri Jan 08 10:14:02 2016 +0100
+++ b/hotspot/src/share/vm/ci/ciEnv.cpp	Fri Dec 18 20:23:26 2015 +0300
@@ -1045,9 +1045,6 @@
       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);
--- a/hotspot/src/share/vm/code/codeBlob.cpp	Fri Jan 08 10:14:02 2016 +0100
+++ b/hotspot/src/share/vm/code/codeBlob.cpp	Fri Dec 18 20:23:26 2015 +0300
@@ -181,6 +181,11 @@
   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
--- a/hotspot/src/share/vm/code/codeBlob.hpp	Fri Jan 08 10:14:02 2016 +0100
+++ b/hotspot/src/share/vm/code/codeBlob.hpp	Fri Dec 18 20:23:26 2015 +0300
@@ -196,6 +196,7 @@
   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 = "");
--- a/hotspot/src/share/vm/code/nmethod.cpp	Fri Jan 08 10:14:02 2016 +0100
+++ b/hotspot/src/share/vm/code/nmethod.cpp	Fri Dec 18 20:23:26 2015 +0300
@@ -2639,6 +2639,7 @@
     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 @@
                                               nul_chk_table_size());
 }
 
-void nmethod::print_code() {
-  HandleMark hm;
-  ResourceMark m;
-  Disassembler::decode(this);
-}
-
-
 #ifndef PRODUCT
 
 void nmethod::print_scopes() {
--- a/hotspot/src/share/vm/code/nmethod.hpp	Fri Jan 08 10:14:02 2016 +0100
+++ b/hotspot/src/share/vm/code/nmethod.hpp	Fri Dec 18 20:23:26 2015 +0300
@@ -704,7 +704,6 @@
 
   // printing support
   void print()                          const;
-  void print_code();
   void print_relocations()                        PRODUCT_RETURN;
   void print_pcs()                                PRODUCT_RETURN;
   void print_scopes()                             PRODUCT_RETURN;
--- a/hotspot/src/share/vm/compiler/disassembler.cpp	Fri Jan 08 10:14:02 2016 +0100
+++ b/hotspot/src/share/vm/compiler/disassembler.cpp	Fri Dec 18 20:23:26 2015 +0300
@@ -497,6 +497,7 @@
 
 
 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(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("----------------------------------------------------------------------");
--- a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp	Fri Jan 08 10:14:02 2016 +0100
+++ b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp	Fri Dec 18 20:23:26 2015 +0300
@@ -1252,6 +1252,7 @@
         } 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(),
--- a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp	Fri Jan 08 10:14:02 2016 +0100
+++ b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp	Fri Dec 18 20:23:26 2015 +0300
@@ -897,10 +897,8 @@
     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;
   }
--- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp	Fri Jan 08 10:14:02 2016 +0100
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp	Fri Dec 18 20:23:26 2015 +0300
@@ -726,6 +726,7 @@
 #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 @@
 
         DirectiveSet* directive = DirectivesStack::getDefaultDirective(CompileBroker::compiler(CompLevel_simple));
         if (directive->PrintAssemblyOption) {
-          Disassembler::decode(nm, tty);
+          nm->print_code();
         }
         DirectivesStack::release(directive);
       }
--- a/hotspot/src/share/vm/runtime/vframe.hpp	Fri Jan 08 10:14:02 2016 +0100
+++ b/hotspot/src/share/vm/runtime/vframe.hpp	Fri Dec 18 20:23:26 2015 +0300
@@ -406,6 +406,7 @@
     // 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);
--- a/hotspot/src/share/vm/utilities/debug.cpp	Fri Jan 08 10:14:02 2016 +0100
+++ b/hotspot/src/share/vm/utilities/debug.cpp	Fri Dec 18 20:23:26 2015 +0300
@@ -480,12 +480,13 @@
 extern "C" void disnm(intptr_t p) {
   Command c("disnm");
   CodeBlob* cb = CodeCache::find_blob((address) p);
-  nmethod* nm = cb->as_nmethod_or_null();
-  if (nm) {
-    nm->print();
-    Disassembler::decode(nm);
-  } else {
-    cb->print();
+  if (cb != NULL) {
+    nmethod* nm = cb->as_nmethod_or_null();
+    if (nm != NULL) {
+      nm->print();
+    } else {
+      cb->print();
+    }
     Disassembler::decode(cb);
   }
 }