--- old/src/share/vm/logging/logStream.hpp 2017-06-18 08:42:39.220358000 +0200 +++ new/src/share/vm/logging/logStream.hpp 2017-06-18 08:42:38.344294200 +0200 @@ -32,9 +32,31 @@ class LogStream : public outputStream { - bufferedStream _current_line; + + // Helper class, maintains the line buffer. For small line lengths, + // we avoid malloc and use a fixed sized member char array. If LogStream + // is allocated on the stack, this means small lines are assembled + // directly on the stack. + class LineBuffer { + char _smallbuf[128]; + char* _buf; + size_t _cap; + size_t _pos; + void ensure_cap(size_t cap); + public: + LineBuffer(); + ~LineBuffer(); + const char* ptr() const { return _buf; } + void append(const char* s, size_t len); + void reset(); + }; + LineBuffer _current_line; LogTargetHandle _log_handle; + // Prevent operator new for LogStream. +// static void* operator new (size_t); +// static void* operator new[] (size_t); + public: // Constructor to support creation from a LogTarget instance. // @@ -65,10 +87,6 @@ // LogStreamBase(level, tageset); LogStream(LogLevelType level, LogTagSet* tagset) : _log_handle(level, tagset) {} - ~LogStream() { - guarantee(_current_line.size() == 0, "Buffer not flushed. Missing call to print_cr()?"); - } - public: void write(const char* s, size_t len); };