192 assert(mspace != NULL, "invariant"); |
192 assert(mspace != NULL, "invariant"); |
193 return lease_free(size, mspace, lease_retry, thread); |
193 return lease_free(size, mspace, lease_retry, thread); |
194 } |
194 } |
195 |
195 |
196 /* |
196 /* |
197 * If the buffer was a "lease", release back. |
197 * If the buffer was a lease, release back. |
198 * |
198 * |
199 * The buffer is effectively invalidated for the thread post-return, |
199 * The buffer is effectively invalidated for the thread post-return, |
200 * and the caller should take means to ensure that it is not referenced. |
200 * and the caller should take means to ensure that it is not referenced. |
201 */ |
201 */ |
202 static void release(BufferPtr const buffer, Thread* thread) { |
202 static void release(BufferPtr const buffer, Thread* thread) { |
203 DEBUG_ONLY(assert_release(buffer);) |
203 DEBUG_ONLY(assert_release(buffer);) |
204 buffer->clear_lease(); |
204 buffer->clear_lease(); |
205 buffer->release(); |
205 buffer->release(); |
206 } |
206 } |
333 assert(_checkpoint_epoch_state != JfrTraceIdEpoch::epoch(), "invariant"); |
333 assert(_checkpoint_epoch_state != JfrTraceIdEpoch::epoch(), "invariant"); |
334 OrderAccess::storestore(); |
334 OrderAccess::storestore(); |
335 _checkpoint_epoch_state = JfrTraceIdEpoch::epoch(); |
335 _checkpoint_epoch_state = JfrTraceIdEpoch::epoch(); |
336 } |
336 } |
337 |
337 |
338 void JfrCheckpointManager::shift_epoch() { |
338 |
339 debug_only(const u1 current_epoch = JfrTraceIdEpoch::current();) |
339 size_t JfrCheckpointManager::write() { |
340 JfrTraceIdEpoch::shift_epoch(); |
340 const size_t processed = write_mspace<MutexedWriteOp, CompositeOperation>(_free_list_mspace, _chunkwriter); |
341 assert(current_epoch != JfrTraceIdEpoch::current(), "invariant"); |
341 synchronize_epoch(); |
|
342 return processed; |
|
343 } |
|
344 |
|
345 size_t JfrCheckpointManager::write_epoch_transition_mspace() { |
|
346 return write_mspace<ExclusiveOp, CompositeOperation>(_epoch_transition_mspace, _chunkwriter); |
|
347 } |
|
348 |
|
349 typedef MutexedWriteOp<WriteOperation> FlushOperation; |
|
350 |
|
351 size_t JfrCheckpointManager::flush() { |
|
352 WriteOperation wo(_chunkwriter); |
|
353 FlushOperation fo(wo); |
|
354 assert(_free_list_mspace->is_full_empty(), "invariant"); |
|
355 process_free_list(fo, _free_list_mspace); |
|
356 return wo.processed(); |
342 } |
357 } |
343 |
358 |
344 typedef DiscardOp<DefaultDiscarder<JfrBuffer> > DiscardOperation; |
359 typedef DiscardOp<DefaultDiscarder<JfrBuffer> > DiscardOperation; |
345 size_t JfrCheckpointManager::clear() { |
360 size_t JfrCheckpointManager::clear() { |
346 DiscardOperation discarder(mutexed); // mutexed discard mode |
361 DiscardOperation discarder(mutexed); // mutexed discard mode |
347 process_free_list(discarder, _free_list_mspace); |
362 process_free_list(discarder, _free_list_mspace); |
348 process_free_list(discarder, _epoch_transition_mspace); |
363 process_free_list(discarder, _epoch_transition_mspace); |
349 synchronize_epoch(); |
364 synchronize_epoch(); |
350 return discarder.elements(); |
365 return discarder.elements(); |
351 } |
|
352 |
|
353 size_t JfrCheckpointManager::write() { |
|
354 const size_t processed = write_mspace<MutexedWriteOp, CompositeOperation>(_free_list_mspace, _chunkwriter); |
|
355 synchronize_epoch(); |
|
356 return processed; |
|
357 } |
|
358 |
|
359 typedef MutexedWriteOp<WriteOperation> FlushOperation; |
|
360 |
|
361 size_t JfrCheckpointManager::flush() { |
|
362 WriteOperation wo(_chunkwriter); |
|
363 FlushOperation fo(wo); |
|
364 assert(_free_list_mspace->is_full_empty(), "invariant"); |
|
365 process_free_list(fo, _free_list_mspace); |
|
366 return wo.processed(); |
|
367 } |
366 } |
368 |
367 |
369 // Optimization for write_types() and write_threads() is to write |
368 // Optimization for write_types() and write_threads() is to write |
370 // directly into the epoch transition mspace because we will immediately |
369 // directly into the epoch transition mspace because we will immediately |
371 // serialize and reset this mspace post-write. |
370 // serialize and reset this mspace post-write. |
394 Thread* const t = Thread::current(); |
393 Thread* const t = Thread::current(); |
395 JfrCheckpointWriter writer(t, get_epoch_transition_buffer(_epoch_transition_mspace, t), THREADS); |
394 JfrCheckpointWriter writer(t, get_epoch_transition_buffer(_epoch_transition_mspace, t), THREADS); |
396 JfrTypeManager::write_threads(writer); |
395 JfrTypeManager::write_threads(writer); |
397 return writer.used_size(); |
396 return writer.used_size(); |
398 } |
397 } |
399 |
|
400 size_t JfrCheckpointManager::write_epoch_transition_mspace() { |
|
401 return write_mspace<ExclusiveOp, CompositeOperation>(_epoch_transition_mspace, _chunkwriter); |
|
402 } |
|
403 |
|
404 size_t JfrCheckpointManager::write_constants() { |
398 size_t JfrCheckpointManager::write_constants() { |
405 write_types(); |
399 write_types(); |
406 write_threads(); |
400 write_threads(); |
407 return write_epoch_transition_mspace(); |
401 return write_epoch_transition_mspace(); |
408 } |
402 } |