2828#include " memory/allocation.hpp"
2929#include " runtime/timer.hpp"
3030#include " utilities/globalDefinitions.hpp"
31+ #include " utilities/macros.hpp"
3132
3233DEBUG_ONLY (class ResourceMark ;)
3334
@@ -191,6 +192,7 @@ class ttyUnlocker: StackObj {
191192// for writing to strings; buffer will expand automatically.
192193// Buffer will always be zero-terminated.
193194class stringStream : public outputStream {
195+ DEBUG_ONLY (bool _is_frozen = false );
194196 char * _buffer;
195197 size_t _written; // Number of characters written, excluding termin. zero
196198 size_t _capacity;
@@ -215,9 +217,18 @@ class stringStream : public outputStream {
215217 // Return number of characters written into buffer, excluding terminating zero and
216218 // subject to truncation in static buffer mode.
217219 size_t size () const { return _written; }
220+ // Returns internal buffer containing the accumulated string.
221+ // Returned buffer is only guaranteed to be valid as long as stream is not modified
218222 const char * base () const { return _buffer; }
223+ // Freezes stringStream (no further modifications possible) and returns pointer to it.
224+ // No-op if stream is frozen already.
225+ // Returns the internal buffer containing the accumulated string.
226+ const char * freeze () NOT_DEBUG(const ) {
227+ DEBUG_ONLY (_is_frozen = true );
228+ return _buffer;
229+ };
219230 void reset ();
220- // copy to a resource, or C-heap, array as requested
231+ // Copy to a resource, or C-heap, array as requested
221232 char * as_string (bool c_heap = false ) const ;
222233};
223234
0 commit comments