8024943: ciReplay: fails to dump replay data during safepointing
authorvlivanov
Mon, 07 Oct 2013 14:11:49 +0400
changeset 20692 65021f70c2fc
parent 20691 63d27d9c8e79
child 20693 1d94d9407c58
8024943: ciReplay: fails to dump replay data during safepointing Reviewed-by: kvn, twisti
hotspot/src/share/vm/ci/ciEnv.cpp
hotspot/src/share/vm/ci/ciEnv.hpp
hotspot/src/share/vm/ci/ciInstanceKlass.cpp
hotspot/src/share/vm/ci/ciMethod.cpp
hotspot/src/share/vm/ci/ciMethodData.cpp
hotspot/src/share/vm/utilities/vmError.cpp
--- a/hotspot/src/share/vm/ci/ciEnv.cpp	Mon Oct 07 14:10:29 2013 +0400
+++ b/hotspot/src/share/vm/ci/ciEnv.cpp	Mon Oct 07 14:11:49 2013 +0400
@@ -1154,9 +1154,12 @@
   GUARDED_VM_ENTRY(return _factory->get_unloaded_object_constant();)
 }
 
-void ciEnv::dump_replay_data(outputStream* out) {
-  VM_ENTRY_MARK;
-  MutexLocker ml(Compile_lock);
+// ------------------------------------------------------------------
+// ciEnv::dump_replay_data*
+
+// Don't change thread state and acquire any locks.
+// Safe to call from VM error reporter.
+void ciEnv::dump_replay_data_unsafe(outputStream* out) {
   ResourceMark rm;
 #if INCLUDE_JVMTI
   out->print_cr("JvmtiExport can_access_local_variables %d",     _jvmti_can_access_local_variables);
@@ -1181,3 +1184,10 @@
                 entry_bci, comp_level);
   out->flush();
 }
+
+void ciEnv::dump_replay_data(outputStream* out) {
+  GUARDED_VM_ENTRY(
+    MutexLocker ml(Compile_lock);
+    dump_replay_data_unsafe(out);
+  )
+}
--- a/hotspot/src/share/vm/ci/ciEnv.hpp	Mon Oct 07 14:10:29 2013 +0400
+++ b/hotspot/src/share/vm/ci/ciEnv.hpp	Mon Oct 07 14:11:49 2013 +0400
@@ -452,6 +452,7 @@
 
   // Dump the compilation replay data for the ciEnv to the stream.
   void dump_replay_data(outputStream* out);
+  void dump_replay_data_unsafe(outputStream* out);
 };
 
 #endif // SHARE_VM_CI_CIENV_HPP
--- a/hotspot/src/share/vm/ci/ciInstanceKlass.cpp	Mon Oct 07 14:10:29 2013 +0400
+++ b/hotspot/src/share/vm/ci/ciInstanceKlass.cpp	Mon Oct 07 14:11:49 2013 +0400
@@ -671,7 +671,6 @@
 
 
 void ciInstanceKlass::dump_replay_data(outputStream* out) {
-  ASSERT_IN_VM;
   ResourceMark rm;
 
   InstanceKlass* ik = get_instanceKlass();
--- a/hotspot/src/share/vm/ci/ciMethod.cpp	Mon Oct 07 14:10:29 2013 +0400
+++ b/hotspot/src/share/vm/ci/ciMethod.cpp	Mon Oct 07 14:11:49 2013 +0400
@@ -1247,7 +1247,6 @@
 #undef FETCH_FLAG_FROM_VM
 
 void ciMethod::dump_replay_data(outputStream* st) {
-  ASSERT_IN_VM;
   ResourceMark rm;
   Method* method = get_Method();
   MethodCounters* mcs = method->method_counters();
--- a/hotspot/src/share/vm/ci/ciMethodData.cpp	Mon Oct 07 14:10:29 2013 +0400
+++ b/hotspot/src/share/vm/ci/ciMethodData.cpp	Mon Oct 07 14:11:49 2013 +0400
@@ -373,7 +373,6 @@
 }
 
 void ciMethodData::dump_replay_data(outputStream* out) {
-  ASSERT_IN_VM;
   ResourceMark rm;
   MethodData* mdo = get_MethodData();
   Method* method = mdo->method();
--- a/hotspot/src/share/vm/utilities/vmError.cpp	Mon Oct 07 14:10:29 2013 +0400
+++ b/hotspot/src/share/vm/utilities/vmError.cpp	Mon Oct 07 14:11:49 2013 +0400
@@ -1050,7 +1050,7 @@
         FILE* replay_data_file = os::open(fd, "w");
         if (replay_data_file != NULL) {
           fileStream replay_data_stream(replay_data_file, /*need_close=*/true);
-          env->dump_replay_data(&replay_data_stream);
+          env->dump_replay_data_unsafe(&replay_data_stream);
           out.print_raw("#\n# Compiler replay data is saved as:\n# ");
           out.print_raw_cr(buffer);
         } else {