diff -r 2c3cc4b01880 -r c16ac7a2eba4 src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointWriter.cpp --- a/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointWriter.cpp Wed Oct 30 16:14:56 2019 +0100 +++ b/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointWriter.cpp Wed Oct 30 19:43:52 2019 +0100 @@ -31,12 +31,26 @@ JfrCheckpointFlush::JfrCheckpointFlush(Type* old, size_t used, size_t requested, Thread* t) : _result(JfrCheckpointManager::flush(old, used, requested, t)) {} -JfrCheckpointWriter::JfrCheckpointWriter(bool flushpoint, bool header, Thread* thread) : - JfrCheckpointWriterBase(JfrCheckpointManager::lease_buffer(thread), thread), +JfrCheckpointWriter::JfrCheckpointWriter(JfrCheckpointType type /* GENERIC */) : + JfrCheckpointWriterBase(JfrCheckpointManager::lease_buffer(Thread::current()), Thread::current()), _time(JfrTicks::now()), _offset(0), _count(0), - _flushpoint(flushpoint), + _type(type), + _header(true) { + assert(this->is_acquired(), "invariant"); + assert(0 == this->current_offset(), "invariant"); + if (_header) { + reserve(sizeof(JfrCheckpointEntry)); + } +} + +JfrCheckpointWriter::JfrCheckpointWriter(Thread* t, bool header /* true */, JfrCheckpointType type /* GENERIC */) : + JfrCheckpointWriterBase(JfrCheckpointManager::lease_buffer(t), t), + _time(JfrTicks::now()), + _offset(0), + _count(0), + _type(type), _header(header) { assert(this->is_acquired(), "invariant"); assert(0 == this->current_offset(), "invariant"); @@ -45,13 +59,27 @@ } } -static void write_checkpoint_header(u1* pos, int64_t size, jlong time, bool flushpoint, u4 type_count) { +JfrCheckpointWriter::JfrCheckpointWriter(Thread* t, JfrBuffer* buffer, JfrCheckpointType type /* GENERIC */) : + JfrCheckpointWriterBase(buffer, t), + _time(JfrTicks::now()), + _offset(0), + _count(0), + _type(type), + _header(true) { + assert(this->is_acquired(), "invariant"); + assert(0 == this->current_offset(), "invariant"); + if (_header) { + reserve(sizeof(JfrCheckpointEntry)); + } +} + +static void write_checkpoint_header(u1* pos, int64_t size, jlong time, u4 checkpoint_type, u4 type_count) { assert(pos != NULL, "invariant"); JfrBigEndianWriter be_writer(pos, sizeof(JfrCheckpointEntry)); be_writer.write(size); be_writer.write(time); be_writer.write(JfrTicks::now().value() - time); - be_writer.write(flushpoint ? (u4)1 : (u4)0); + be_writer.write(checkpoint_type); be_writer.write(type_count); assert(be_writer.is_valid(), "invariant"); } @@ -74,18 +102,10 @@ assert(this->used_size() > sizeof(JfrCheckpointEntry), "invariant"); const int64_t size = this->current_offset(); assert(size + this->start_pos() == this->current_pos(), "invariant"); - write_checkpoint_header(const_cast(this->start_pos()), size, _time, is_flushpoint(), count()); + write_checkpoint_header(const_cast(this->start_pos()), size, _time, (u4)_type, count()); release(); } -void JfrCheckpointWriter::set_flushpoint(bool flushpoint) { - _flushpoint = flushpoint; -} - -bool JfrCheckpointWriter::is_flushpoint() const { - return _flushpoint; -} - u4 JfrCheckpointWriter::count() const { return _count; } @@ -140,7 +160,7 @@ } *size = this->used_size(); assert(this->start_pos() + *size == this->current_pos(), "invariant"); - write_checkpoint_header(const_cast(this->start_pos()), this->used_offset(), _time, is_flushpoint(), count()); + write_checkpoint_header(const_cast(this->start_pos()), this->used_offset(), _time, (u4)_type, count()); _header = false; // the header was just written if (move) { this->seek(_offset);