8224487: outputStream should not be copyable
authorstuefe
Wed, 22 May 2019 07:10:54 +0200
changeset 54973 0927d8c7296f
parent 54972 f98a0ab24887
child 54974 22961d673487
8224487: outputStream should not be copyable Reviewed-by: kbarrett, coleenp
src/hotspot/share/c1/c1_Runtime1.cpp
src/hotspot/share/code/codeHeapState.cpp
src/hotspot/share/compiler/compileBroker.cpp
src/hotspot/share/interpreter/bytecodeInterpreter.cpp
src/hotspot/share/interpreter/interpreterRuntime.cpp
src/hotspot/share/jvmci/jvmciRuntime.cpp
src/hotspot/share/utilities/events.cpp
src/hotspot/share/utilities/events.hpp
src/hotspot/share/utilities/exceptions.cpp
src/hotspot/share/utilities/exceptions.hpp
src/hotspot/share/utilities/ostream.hpp
--- a/src/hotspot/share/c1/c1_Runtime1.cpp	Tue May 21 20:14:30 2019 -0700
+++ b/src/hotspot/share/c1/c1_Runtime1.cpp	Wed May 22 07:10:54 2019 +0200
@@ -575,7 +575,7 @@
       tempst.print("compiled method <%s>\n"
                    " at PC" INTPTR_FORMAT " for thread " INTPTR_FORMAT,
                    nm->method()->print_value_string(), p2i(pc), p2i(thread));
-      Exceptions::log_exception(exception, tempst);
+      Exceptions::log_exception(exception, tempst.as_string());
     }
     // for AbortVMOnException flag
     Exceptions::debug_check_abort(exception);
--- a/src/hotspot/share/code/codeHeapState.cpp	Tue May 21 20:14:30 2019 -0700
+++ b/src/hotspot/share/code/codeHeapState.cpp	Wed May 22 07:10:54 2019 +0200
@@ -124,7 +124,7 @@
     size_t     _nlockedflush = 0;                             \
     size_t     _nflush_bytes = 0;                             \
     size_t         _capacity = _capa;                         \
-    bufferedStream   _sstobj = bufferedStream(_capa);         \
+    bufferedStream   _sstobj(_capa);                          \
     bufferedStream*  _sstbuf = &_sstobj;                      \
     outputStream*    _outbuf = _outst;                        \
     bufferedStream*   _anyst = &_sstobj; /* any stream. Use this to just print - no buffer flush.  */
--- a/src/hotspot/share/compiler/compileBroker.cpp	Tue May 21 20:14:30 2019 -0700
+++ b/src/hotspot/share/compiler/compileBroker.cpp	Wed May 22 07:10:54 2019 +0200
@@ -192,7 +192,7 @@
 
   void log_compile(JavaThread* thread, CompileTask* task) {
     StringLogMessage lm;
-    stringStream sstr = lm.stream();
+    stringStream sstr(lm.buffer(), lm.size());
     // msg.time_stamp().update_to(tty->time_stamp().ticks());
     task->print(&sstr, NULL, true, false);
     log(thread, "%s", (const char*)lm);
--- a/src/hotspot/share/interpreter/bytecodeInterpreter.cpp	Tue May 21 20:14:30 2019 -0700
+++ b/src/hotspot/share/interpreter/bytecodeInterpreter.cpp	Wed May 22 07:10:54 2019 +0200
@@ -2871,7 +2871,7 @@
                      METHOD->print_value_string(),
                      (int)(istate->bcp() - METHOD->code_base()),
                      (int)continuation_bci, p2i(THREAD));
-        Exceptions::log_exception(except_oop, tempst);
+        Exceptions::log_exception(except_oop, tempst.as_string());
       }
       // for AbortVMOnException flag
       Exceptions::debug_check_abort(except_oop);
@@ -2888,7 +2888,7 @@
              METHOD->print_value_string(),
              (int)(istate->bcp() - METHOD->code_base()),
              p2i(THREAD));
-      Exceptions::log_exception(except_oop, tempst);
+      Exceptions::log_exception(except_oop, tempst.as_string());
     }
     // for AbortVMOnException flag
     Exceptions::debug_check_abort(except_oop);
--- a/src/hotspot/share/interpreter/interpreterRuntime.cpp	Tue May 21 20:14:30 2019 -0700
+++ b/src/hotspot/share/interpreter/interpreterRuntime.cpp	Wed May 22 07:10:54 2019 +0200
@@ -543,7 +543,7 @@
       tempst.print("interpreter method <%s>\n"
                    " at bci %d for thread " INTPTR_FORMAT " (%s)",
                    h_method->print_value_string(), current_bci, p2i(thread), thread->name());
-      Exceptions::log_exception(h_exception, tempst);
+      Exceptions::log_exception(h_exception, tempst.as_string());
     }
 // Don't go paging in something which won't be used.
 //     else if (extable->length() == 0) {
--- a/src/hotspot/share/jvmci/jvmciRuntime.cpp	Tue May 21 20:14:30 2019 -0700
+++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp	Wed May 22 07:10:54 2019 +0200
@@ -311,7 +311,7 @@
       tempst.print("compiled method <%s>\n"
                    " at PC" INTPTR_FORMAT " for thread " INTPTR_FORMAT,
                    cm->method()->print_value_string(), p2i(pc), p2i(thread));
-      Exceptions::log_exception(exception, tempst);
+      Exceptions::log_exception(exception, tempst.as_string());
     }
     // for AbortVMOnException flag
     NOT_PRODUCT(Exceptions::debug_check_abort(exception));
--- a/src/hotspot/share/utilities/events.cpp	Tue May 21 20:14:30 2019 -0700
+++ b/src/hotspot/share/utilities/events.cpp	Wed May 22 07:10:54 2019 +0200
@@ -108,7 +108,8 @@
   int index = compute_log_index();
   _records[index].thread = thread;
   _records[index].timestamp = timestamp;
-  stringStream st = _records[index].data.stream();
+  stringStream st(_records[index].data.buffer(),
+                  _records[index].data.size());
   st.print("Unloading class " INTPTR_FORMAT " ", p2i(ik));
   ik->name()->print_value_on(&st);
 }
@@ -121,7 +122,8 @@
   int index = compute_log_index();
   _records[index].thread = thread;
   _records[index].timestamp = timestamp;
-  stringStream st = _records[index].data.stream();
+  stringStream st(_records[index].data.buffer(),
+                  _records[index].data.size());
   st.print("Exception <");
   h_exception->print_value_on(&st);
   st.print("%s%s> (" INTPTR_FORMAT ") \n"
--- a/src/hotspot/share/utilities/events.hpp	Tue May 21 20:14:30 2019 -0700
+++ b/src/hotspot/share/utilities/events.hpp	Wed May 22 07:10:54 2019 +0200
@@ -137,11 +137,6 @@
 // A simple wrapper class for fixed size text messages.
 template <size_t bufsz>
 class FormatStringLogMessage : public FormatBuffer<bufsz> {
- public:
-  // Wrap this buffer in a stringStream.
-  stringStream stream() {
-    return stringStream(this->_buf, this->size());
-  }
 };
 typedef FormatStringLogMessage<256> StringLogMessage;
 typedef FormatStringLogMessage<512> ExtendedStringLogMessage;
--- a/src/hotspot/share/utilities/exceptions.cpp	Tue May 21 20:14:30 2019 -0700
+++ b/src/hotspot/share/utilities/exceptions.cpp	Wed May 22 07:10:54 2019 +0200
@@ -526,17 +526,17 @@
 }
 
 // for logging exceptions
-void Exceptions::log_exception(Handle exception, stringStream tempst) {
+void Exceptions::log_exception(Handle exception, const char* message) {
   ResourceMark rm;
-  Symbol* message = java_lang_Throwable::detail_message(exception());
-  if (message != NULL) {
+  Symbol* detail_message = java_lang_Throwable::detail_message(exception());
+  if (detail_message != NULL) {
     log_info(exceptions)("Exception <%s: %s>\n thrown in %s",
                          exception->print_value_string(),
-                         message->as_C_string(),
-                         tempst.as_string());
+                         detail_message->as_C_string(),
+                         message);
   } else {
     log_info(exceptions)("Exception <%s>\n thrown in %s",
                          exception->print_value_string(),
-                         tempst.as_string());
+                         message);
   }
 }
--- a/src/hotspot/share/utilities/exceptions.hpp	Tue May 21 20:14:30 2019 -0700
+++ b/src/hotspot/share/utilities/exceptions.hpp	Wed May 22 07:10:54 2019 +0200
@@ -186,7 +186,7 @@
   static void debug_check_abort(const char *value_string, const char* message = NULL);
 
   // for logging exceptions
-  static void log_exception(Handle exception, stringStream tempst);
+  static void log_exception(Handle exception, const char* message);
 };
 
 
--- a/src/hotspot/share/utilities/ostream.hpp	Tue May 21 20:14:30 2019 -0700
+++ b/src/hotspot/share/utilities/ostream.hpp	Wed May 22 07:10:54 2019 +0200
@@ -42,6 +42,10 @@
 // This allows for redirection via -XX:+DisplayVMOutputToStdout and
 // -XX:+DisplayVMOutputToStderr
 class outputStream : public ResourceObj {
+ private:
+   outputStream(const outputStream&);
+   outputStream& operator=(const outputStream&);
+
  protected:
    int _indentation; // current indentation
    int _width;       // width of the page