src/hotspot/share/jfr/recorder/repository/jfrChunkWriter.cpp
branchJEP-349-branch
changeset 57882 562f598d303c
parent 57870 00860d9caf4d
child 57886 87f8a814310d
equal deleted inserted replaced
57878:bffba8d6611a 57882:562f598d303c
   181     }
   181     }
   182     DEBUG_ONLY(assert_writer_position(_writer, offset);)
   182     DEBUG_ONLY(assert_writer_position(_writer, offset);)
   183   }
   183   }
   184 };
   184 };
   185 
   185 
   186 static void write_checkpoint_header(JfrChunkWriter& cw, int64_t event_offset, bool flushpoint) {
   186 static void write_checkpoint_header(JfrChunkWriter& cw, int64_t event_offset, u1 mode) {
   187   const int64_t delta = cw.last_checkpoint_offset() == 0 ? 0 : cw.last_checkpoint_offset() - event_offset;
   187   const int64_t delta = cw.last_checkpoint_offset() == 0 ? 0 : cw.last_checkpoint_offset() - event_offset;
   188   cw.reserve(sizeof(u4));
   188   cw.reserve(sizeof(u4));
   189   cw.write<u8>(EVENT_CHECKPOINT);
   189   cw.write<u8>(EVENT_CHECKPOINT);
   190   cw.write<u8>(JfrTicks::now().value());
   190   cw.write<u8>(JfrTicks::now().value());
   191   cw.write<u8>(0); // duration
   191   cw.write<u8>(0); // duration
   192   cw.write<u8>(delta); // to previous checkpoint
   192   cw.write<u8>(delta); // to previous checkpoint
   193   cw.write<bool>(flushpoint);
   193   cw.write<u1>(mode);
   194   cw.write<u4>(1); // pool count
   194   cw.write<u4>(1); // pool count
   195   cw.write<u8>(TYPE_CHUNKHEADER);
   195   cw.write<u8>(TYPE_CHUNKHEADER);
   196   cw.write<u4>(1); // count
   196   cw.write<u4>(1); // count
   197   cw.write<u8>(1); // key
   197   cw.write<u8>(1); // key
   198   cw.write<u4>(HEADER_SIZE); // length of byte array
   198   cw.write<u4>(HEADER_SIZE); // length of byte array
   199 }
   199 }
   200 
   200 
   201 int64_t JfrChunkWriter::write_chunk_header_checkpoint(bool flushpoint) {
   201 int64_t JfrChunkWriter::write_chunk_header_checkpoint(bool flushpoint) {
   202   assert(this->has_valid_fd(), "invariant");
   202   assert(this->has_valid_fd(), "invariant");
   203   const int64_t event_size_offset = current_offset();
   203   const int64_t event_size_offset = current_offset();
   204   write_checkpoint_header(*this, event_size_offset, flushpoint);
   204   const u1 mode = flushpoint ? FLUSH | HEADER : HEADER;
       
   205   write_checkpoint_header(*this, event_size_offset, mode);
   205   const int64_t start_offset = current_offset();
   206   const int64_t start_offset = current_offset();
   206   JfrChunkHeadWriter head(this, start_offset, false);
   207   JfrChunkHeadWriter head(this, start_offset, false);
   207   head.write_magic();
   208   head.write_magic();
   208   head.write_version();
   209   head.write_version();
   209   const int64_t size_offset = reserve(sizeof(int64_t));
   210   const int64_t size_offset = reserve(sizeof(int64_t));