128 } |
128 } |
129 } |
129 } |
130 bool not_acquired() const { return !_acquired; } |
130 bool not_acquired() const { return !_acquired; } |
131 }; |
131 }; |
132 |
132 |
133 static intptr_t write_checkpoint_event_prologue(JfrChunkWriter& cw, u8 type_id) { |
133 static int64_t write_checkpoint_event_prologue(JfrChunkWriter& cw, u8 type_id) { |
134 const intptr_t prev_cp_offset = cw.previous_checkpoint_offset(); |
134 const int64_t prev_cp_offset = cw.previous_checkpoint_offset(); |
135 const intptr_t prev_cp_relative_offset = 0 == prev_cp_offset ? 0 : prev_cp_offset - cw.current_offset(); |
135 const int64_t prev_cp_relative_offset = 0 == prev_cp_offset ? 0 : prev_cp_offset - cw.current_offset(); |
136 cw.reserve(sizeof(u4)); |
136 cw.reserve(sizeof(u4)); |
137 cw.write<u8>(EVENT_CHECKPOINT); |
137 cw.write<u8>(EVENT_CHECKPOINT); |
138 cw.write(JfrTicks::now()); |
138 cw.write(JfrTicks::now()); |
139 cw.write<jlong>((jlong)0); |
139 cw.write((int64_t)0); |
140 cw.write(prev_cp_relative_offset); // write previous checkpoint offset delta |
140 cw.write(prev_cp_relative_offset); // write previous checkpoint offset delta |
141 cw.write<bool>(false); // flushpoint |
141 cw.write<bool>(false); // flushpoint |
142 cw.write<u4>((u4)1); // nof types in this checkpoint |
142 cw.write((u4)1); // nof types in this checkpoint |
143 cw.write<u8>(type_id); |
143 cw.write(type_id); |
144 const intptr_t number_of_elements_offset = cw.current_offset(); |
144 const int64_t number_of_elements_offset = cw.current_offset(); |
145 cw.reserve(sizeof(u4)); |
145 cw.reserve(sizeof(u4)); |
146 return number_of_elements_offset; |
146 return number_of_elements_offset; |
147 } |
147 } |
148 |
148 |
149 template <typename ContentFunctor> |
149 template <typename ContentFunctor> |
159 _content_functor(functor) { |
159 _content_functor(functor) { |
160 assert(_cw.is_valid(), "invariant"); |
160 assert(_cw.is_valid(), "invariant"); |
161 } |
161 } |
162 bool process() { |
162 bool process() { |
163 // current_cp_offset is also offset for the event size header field |
163 // current_cp_offset is also offset for the event size header field |
164 const intptr_t current_cp_offset = _cw.current_offset(); |
164 const int64_t current_cp_offset = _cw.current_offset(); |
165 const intptr_t num_elements_offset = write_checkpoint_event_prologue(_cw, _type_id); |
165 const int64_t num_elements_offset = write_checkpoint_event_prologue(_cw, _type_id); |
166 // invocation |
166 // invocation |
167 _content_functor.process(); |
167 _content_functor.process(); |
168 const u4 number_of_elements = (u4)_content_functor.processed(); |
168 const u4 number_of_elements = (u4)_content_functor.processed(); |
169 if (number_of_elements == 0) { |
169 if (number_of_elements == 0) { |
170 // nothing to do, rewind writer to start |
170 // nothing to do, rewind writer to start |
466 _checkpoint_manager.shift_epoch(); |
466 _checkpoint_manager.shift_epoch(); |
467 _chunkwriter.time_stamp_chunk_now(); |
467 _chunkwriter.time_stamp_chunk_now(); |
468 JfrMetadataEvent::lock(); |
468 JfrMetadataEvent::lock(); |
469 } |
469 } |
470 |
470 |
471 static jlong write_metadata_event(JfrChunkWriter& chunkwriter) { |
471 static int64_t write_metadata_event(JfrChunkWriter& chunkwriter) { |
472 assert(chunkwriter.is_valid(), "invariant"); |
472 assert(chunkwriter.is_valid(), "invariant"); |
473 const jlong metadata_offset = chunkwriter.current_offset(); |
473 const int64_t metadata_offset = chunkwriter.current_offset(); |
474 JfrMetadataEvent::write(chunkwriter, metadata_offset); |
474 JfrMetadataEvent::write(chunkwriter, metadata_offset); |
475 return metadata_offset; |
475 return metadata_offset; |
476 } |
476 } |
477 |
477 |
478 // |
478 // |