Mon, 19 Aug 2019 10:11:31 +0200
8229401: Fix JFR code cache test failures
8223689: Add JFR Thread Sampling Support
8223690: Add JFR BiasedLock Event Support
8223691: Add JFR G1 Region Type Change Event Support
8223692: Add JFR G1 Heap Summary Event Support
Summary: Backport JFR from JDK11, additional fixes
Reviewed-by: neugens, apetushkov
Contributed-by: denghui.ddh@alibaba-inc.com
apetushkov@9858 | 1 | /* |
apetushkov@9858 | 2 | * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
apetushkov@9858 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
apetushkov@9858 | 4 | * |
apetushkov@9858 | 5 | * This code is free software; you can redistribute it and/or modify it |
apetushkov@9858 | 6 | * under the terms of the GNU General Public License version 2 only, as |
apetushkov@9858 | 7 | * published by the Free Software Foundation. |
apetushkov@9858 | 8 | * |
apetushkov@9858 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
apetushkov@9858 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
apetushkov@9858 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
apetushkov@9858 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
apetushkov@9858 | 13 | * accompanied this code). |
apetushkov@9858 | 14 | * |
apetushkov@9858 | 15 | * You should have received a copy of the GNU General Public License version |
apetushkov@9858 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
apetushkov@9858 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
apetushkov@9858 | 18 | * |
apetushkov@9858 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
apetushkov@9858 | 20 | * or visit www.oracle.com if you need additional information or have any |
apetushkov@9858 | 21 | * questions. |
apetushkov@9858 | 22 | * |
apetushkov@9858 | 23 | */ |
apetushkov@9858 | 24 | |
apetushkov@9858 | 25 | #include "precompiled.hpp" |
apetushkov@9858 | 26 | #include "classfile/javaClasses.hpp" |
apetushkov@9858 | 27 | #include "jfr/recorder/jfrRecorder.hpp" |
apetushkov@9858 | 28 | #include "jfr/recorder/checkpoint/jfrCheckpointManager.hpp" |
apetushkov@9858 | 29 | #include "jfr/recorder/checkpoint/jfrCheckpointWriter.hpp" |
apetushkov@9858 | 30 | #include "jfr/recorder/checkpoint/types/jfrTypeManager.hpp" |
apetushkov@9858 | 31 | #include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp" |
apetushkov@9858 | 32 | #include "jfr/recorder/service/jfrOptionSet.hpp" |
apetushkov@9858 | 33 | #include "jfr/recorder/storage/jfrMemorySpace.inline.hpp" |
apetushkov@9858 | 34 | #include "jfr/recorder/storage/jfrStorageUtils.inline.hpp" |
apetushkov@9858 | 35 | #include "jfr/recorder/repository/jfrChunkWriter.hpp" |
apetushkov@9858 | 36 | #include "jfr/utilities/jfrBigEndian.hpp" |
apetushkov@9858 | 37 | #include "jfr/utilities/jfrTypes.hpp" |
apetushkov@9858 | 38 | #include "memory/resourceArea.hpp" |
apetushkov@9858 | 39 | #include "runtime/mutexLocker.hpp" |
apetushkov@9858 | 40 | #include "runtime/orderAccess.inline.hpp" |
apetushkov@9858 | 41 | #include "runtime/os.hpp" |
apetushkov@9858 | 42 | #include "runtime/safepoint.hpp" |
apetushkov@9858 | 43 | |
apetushkov@9858 | 44 | typedef JfrCheckpointManager::Buffer* BufferPtr; |
apetushkov@9858 | 45 | |
apetushkov@9858 | 46 | static JfrCheckpointManager* _instance = NULL; |
apetushkov@9858 | 47 | |
apetushkov@9858 | 48 | JfrCheckpointManager& JfrCheckpointManager::instance() { |
apetushkov@9858 | 49 | return *_instance; |
apetushkov@9858 | 50 | } |
apetushkov@9858 | 51 | |
apetushkov@9858 | 52 | JfrCheckpointManager* JfrCheckpointManager::create(JfrChunkWriter& cw) { |
apetushkov@9858 | 53 | assert(_instance == NULL, "invariant"); |
apetushkov@9858 | 54 | _instance = new JfrCheckpointManager(cw); |
apetushkov@9858 | 55 | return _instance; |
apetushkov@9858 | 56 | } |
apetushkov@9858 | 57 | |
apetushkov@9858 | 58 | void JfrCheckpointManager::destroy() { |
apetushkov@9858 | 59 | assert(_instance != NULL, "invariant"); |
apetushkov@9858 | 60 | delete _instance; |
apetushkov@9858 | 61 | _instance = NULL; |
apetushkov@9858 | 62 | } |
apetushkov@9858 | 63 | |
apetushkov@9858 | 64 | JfrCheckpointManager::JfrCheckpointManager(JfrChunkWriter& cw) : |
apetushkov@9858 | 65 | _free_list_mspace(NULL), |
apetushkov@9858 | 66 | _epoch_transition_mspace(NULL), |
apetushkov@9858 | 67 | _lock(NULL), |
apetushkov@9858 | 68 | _service_thread(NULL), |
apetushkov@9858 | 69 | _chunkwriter(cw), |
apetushkov@9858 | 70 | _checkpoint_epoch_state(JfrTraceIdEpoch::current()) {} |
apetushkov@9858 | 71 | |
apetushkov@9858 | 72 | JfrCheckpointManager::~JfrCheckpointManager() { |
apetushkov@9858 | 73 | if (_free_list_mspace != NULL) { |
apetushkov@9858 | 74 | delete _free_list_mspace; |
apetushkov@9858 | 75 | } |
apetushkov@9858 | 76 | if (_epoch_transition_mspace != NULL) { |
apetushkov@9858 | 77 | delete _epoch_transition_mspace; |
apetushkov@9858 | 78 | } |
apetushkov@9858 | 79 | if (_lock != NULL) { |
apetushkov@9858 | 80 | delete _lock; |
apetushkov@9858 | 81 | } |
apetushkov@9858 | 82 | JfrTypeManager::clear(); |
apetushkov@9858 | 83 | } |
apetushkov@9858 | 84 | |
apetushkov@9858 | 85 | static const size_t unlimited_mspace_size = 0; |
apetushkov@9858 | 86 | static const size_t checkpoint_buffer_cache_count = 2; |
apetushkov@9858 | 87 | static const size_t checkpoint_buffer_size = 512 * K; |
apetushkov@9858 | 88 | |
apetushkov@9858 | 89 | static JfrCheckpointMspace* create_mspace(size_t buffer_size, size_t limit, size_t cache_count, JfrCheckpointManager* system) { |
apetushkov@9858 | 90 | JfrCheckpointMspace* mspace = new JfrCheckpointMspace(buffer_size, limit, cache_count, system); |
apetushkov@9858 | 91 | if (mspace != NULL) { |
apetushkov@9858 | 92 | mspace->initialize(); |
apetushkov@9858 | 93 | } |
apetushkov@9858 | 94 | return mspace; |
apetushkov@9858 | 95 | } |
apetushkov@9858 | 96 | |
apetushkov@9858 | 97 | bool JfrCheckpointManager::initialize() { |
apetushkov@9858 | 98 | assert(_free_list_mspace == NULL, "invariant"); |
apetushkov@9858 | 99 | _free_list_mspace = create_mspace(checkpoint_buffer_size, unlimited_mspace_size, checkpoint_buffer_cache_count, this); |
apetushkov@9858 | 100 | if (_free_list_mspace == NULL) { |
apetushkov@9858 | 101 | return false; |
apetushkov@9858 | 102 | } |
apetushkov@9858 | 103 | assert(_epoch_transition_mspace == NULL, "invariant"); |
apetushkov@9858 | 104 | _epoch_transition_mspace = create_mspace(checkpoint_buffer_size, unlimited_mspace_size, checkpoint_buffer_cache_count, this); |
apetushkov@9858 | 105 | if (_epoch_transition_mspace == NULL) { |
apetushkov@9858 | 106 | return false; |
apetushkov@9858 | 107 | } |
apetushkov@9858 | 108 | assert(_lock == NULL, "invariant"); |
apetushkov@9858 | 109 | _lock = new Mutex(Monitor::leaf - 1, "Checkpoint mutex", Mutex::_allow_vm_block_flag); |
apetushkov@9858 | 110 | if (_lock == NULL) { |
apetushkov@9858 | 111 | return false; |
apetushkov@9858 | 112 | } |
apetushkov@9858 | 113 | return JfrTypeManager::initialize(); |
apetushkov@9858 | 114 | } |
apetushkov@9858 | 115 | |
apetushkov@9858 | 116 | bool JfrCheckpointManager::use_epoch_transition_mspace(const Thread* thread) const { |
apetushkov@9858 | 117 | return _service_thread != thread && OrderAccess::load_acquire((u1*)&_checkpoint_epoch_state) != JfrTraceIdEpoch::current(); |
apetushkov@9858 | 118 | } |
apetushkov@9858 | 119 | |
apetushkov@9858 | 120 | void JfrCheckpointManager::synchronize_epoch() { |
apetushkov@9858 | 121 | assert(_checkpoint_epoch_state != JfrTraceIdEpoch::current(), "invariant"); |
apetushkov@9858 | 122 | OrderAccess::storestore(); |
apetushkov@9858 | 123 | _checkpoint_epoch_state = JfrTraceIdEpoch::current(); |
apetushkov@9858 | 124 | } |
apetushkov@9858 | 125 | |
apetushkov@9858 | 126 | void JfrCheckpointManager::shift_epoch() { |
apetushkov@9858 | 127 | debug_only(const u1 current_epoch = JfrTraceIdEpoch::current();) |
apetushkov@9858 | 128 | JfrTraceIdEpoch::shift_epoch(); |
apetushkov@9858 | 129 | assert(current_epoch != JfrTraceIdEpoch::current(), "invariant"); |
apetushkov@9858 | 130 | } |
apetushkov@9858 | 131 | |
apetushkov@9858 | 132 | void JfrCheckpointManager::register_service_thread(const Thread* thread) { |
apetushkov@9858 | 133 | _service_thread = thread; |
apetushkov@9858 | 134 | } |
apetushkov@9858 | 135 | |
apetushkov@9858 | 136 | void JfrCheckpointManager::register_full(BufferPtr t, Thread* thread) { |
apetushkov@9858 | 137 | // nothing here at the moment |
apetushkov@9858 | 138 | assert(t->retired(), "invariant"); |
apetushkov@9858 | 139 | } |
apetushkov@9858 | 140 | |
apetushkov@9858 | 141 | void JfrCheckpointManager::lock() { |
apetushkov@9858 | 142 | assert(!_lock->owned_by_self(), "invariant"); |
apetushkov@9858 | 143 | _lock->lock_without_safepoint_check(); |
apetushkov@9858 | 144 | } |
apetushkov@9858 | 145 | |
apetushkov@9858 | 146 | void JfrCheckpointManager::unlock() { |
apetushkov@9858 | 147 | _lock->unlock(); |
apetushkov@9858 | 148 | } |
apetushkov@9858 | 149 | |
apetushkov@9858 | 150 | #ifdef ASSERT |
apetushkov@9858 | 151 | |
apetushkov@9858 | 152 | bool JfrCheckpointManager::is_locked() const { |
apetushkov@9858 | 153 | return _lock->owned_by_self(); |
apetushkov@9858 | 154 | } |
apetushkov@9858 | 155 | |
apetushkov@9858 | 156 | static void assert_free_lease(const BufferPtr buffer) { |
apetushkov@9858 | 157 | assert(buffer != NULL, "invariant"); |
apetushkov@9858 | 158 | assert(buffer->acquired_by_self(), "invariant"); |
apetushkov@9858 | 159 | assert(buffer->lease(), "invariant"); |
apetushkov@9858 | 160 | } |
apetushkov@9858 | 161 | |
apetushkov@9858 | 162 | static void assert_release(const BufferPtr buffer) { |
apetushkov@9858 | 163 | assert(buffer != NULL, "invariant"); |
apetushkov@9858 | 164 | assert(buffer->lease(), "invariant"); |
apetushkov@9858 | 165 | assert(buffer->acquired_by_self(), "invariant"); |
apetushkov@9858 | 166 | } |
apetushkov@9858 | 167 | |
apetushkov@9858 | 168 | #endif // ASSERT |
apetushkov@9858 | 169 | |
apetushkov@9858 | 170 | static BufferPtr lease_free(size_t size, JfrCheckpointMspace* mspace, size_t retry_count, Thread* thread) { |
apetushkov@9858 | 171 | static const size_t max_elem_size = mspace->min_elem_size(); // min is max |
apetushkov@9858 | 172 | BufferPtr buffer; |
apetushkov@9858 | 173 | if (size <= max_elem_size) { |
apetushkov@9858 | 174 | BufferPtr buffer = mspace_get_free_lease_with_retry(size, mspace, retry_count, thread); |
apetushkov@9858 | 175 | if (buffer != NULL) { |
apetushkov@9858 | 176 | DEBUG_ONLY(assert_free_lease(buffer);) |
apetushkov@9858 | 177 | return buffer; |
apetushkov@9858 | 178 | } |
apetushkov@9858 | 179 | } |
apetushkov@9858 | 180 | buffer = mspace_allocate_transient_lease_to_free(size, mspace, thread); |
apetushkov@9858 | 181 | DEBUG_ONLY(assert_free_lease(buffer);) |
apetushkov@9858 | 182 | return buffer; |
apetushkov@9858 | 183 | } |
apetushkov@9858 | 184 | |
apetushkov@9858 | 185 | static const size_t lease_retry = 10; |
apetushkov@9858 | 186 | |
apetushkov@9858 | 187 | BufferPtr JfrCheckpointManager::lease_buffer(Thread* thread, size_t size /* 0 */) { |
apetushkov@9858 | 188 | JfrCheckpointManager& manager = instance(); |
apetushkov@9858 | 189 | if (manager.use_epoch_transition_mspace(thread)) { |
apetushkov@9858 | 190 | return lease_free(size, manager._epoch_transition_mspace, lease_retry, thread); |
apetushkov@9858 | 191 | } |
apetushkov@9858 | 192 | return lease_free(size, manager._free_list_mspace, lease_retry, thread); |
apetushkov@9858 | 193 | } |
apetushkov@9858 | 194 | |
apetushkov@9858 | 195 | /* |
apetushkov@9858 | 196 | * If the buffer was a "lease" from the free list, release back. |
apetushkov@9858 | 197 | * |
apetushkov@9858 | 198 | * The buffer is effectively invalidated for the thread post-return, |
apetushkov@9858 | 199 | * and the caller should take means to ensure that it is not referenced. |
apetushkov@9858 | 200 | */ |
apetushkov@9858 | 201 | static void release(BufferPtr const buffer, Thread* thread) { |
apetushkov@9858 | 202 | DEBUG_ONLY(assert_release(buffer);) |
apetushkov@9858 | 203 | buffer->clear_lease(); |
apetushkov@9858 | 204 | buffer->release(); |
apetushkov@9858 | 205 | } |
apetushkov@9858 | 206 | |
apetushkov@9858 | 207 | BufferPtr JfrCheckpointManager::flush(BufferPtr old, size_t used, size_t requested, Thread* thread) { |
apetushkov@9858 | 208 | assert(old != NULL, "invariant"); |
apetushkov@9858 | 209 | assert(old->lease(), "invariant"); |
apetushkov@9858 | 210 | if (0 == requested) { |
apetushkov@9858 | 211 | // indicates a lease is being returned |
apetushkov@9858 | 212 | release(old, thread); |
apetushkov@9858 | 213 | return NULL; |
apetushkov@9858 | 214 | } |
apetushkov@9858 | 215 | // migration of in-flight information |
apetushkov@9858 | 216 | BufferPtr const new_buffer = lease_buffer(thread, used + requested); |
apetushkov@9858 | 217 | if (new_buffer != NULL) { |
apetushkov@9858 | 218 | migrate_outstanding_writes(old, new_buffer, used, requested); |
apetushkov@9858 | 219 | } |
apetushkov@9858 | 220 | release(old, thread); |
apetushkov@9858 | 221 | return new_buffer; // might be NULL |
apetushkov@9858 | 222 | } |
apetushkov@9858 | 223 | |
apetushkov@9858 | 224 | // offsets into the JfrCheckpointEntry |
apetushkov@9858 | 225 | static const juint starttime_offset = sizeof(jlong); |
apetushkov@9858 | 226 | static const juint duration_offset = starttime_offset + sizeof(jlong); |
apetushkov@9858 | 227 | static const juint flushpoint_offset = duration_offset + sizeof(jlong); |
apetushkov@9858 | 228 | static const juint types_offset = flushpoint_offset + sizeof(juint); |
apetushkov@9858 | 229 | static const juint payload_offset = types_offset + sizeof(juint); |
apetushkov@9858 | 230 | |
apetushkov@9858 | 231 | template <typename Return> |
apetushkov@9858 | 232 | static Return read_data(const u1* data) { |
apetushkov@9858 | 233 | return JfrBigEndian::read<Return>(data); |
apetushkov@9858 | 234 | } |
apetushkov@9858 | 235 | |
apetushkov@9858 | 236 | static jlong total_size(const u1* data) { |
apetushkov@9858 | 237 | return read_data<jlong>(data); |
apetushkov@9858 | 238 | } |
apetushkov@9858 | 239 | |
apetushkov@9858 | 240 | static jlong starttime(const u1* data) { |
apetushkov@9858 | 241 | return read_data<jlong>(data + starttime_offset); |
apetushkov@9858 | 242 | } |
apetushkov@9858 | 243 | |
apetushkov@9858 | 244 | static jlong duration(const u1* data) { |
apetushkov@9858 | 245 | return read_data<jlong>(data + duration_offset); |
apetushkov@9858 | 246 | } |
apetushkov@9858 | 247 | |
apetushkov@9858 | 248 | static bool is_flushpoint(const u1* data) { |
apetushkov@9858 | 249 | return read_data<juint>(data + flushpoint_offset) == (juint)1; |
apetushkov@9858 | 250 | } |
apetushkov@9858 | 251 | |
apetushkov@9858 | 252 | static juint number_of_types(const u1* data) { |
apetushkov@9858 | 253 | return read_data<juint>(data + types_offset); |
apetushkov@9858 | 254 | } |
apetushkov@9858 | 255 | |
apetushkov@9858 | 256 | static void write_checkpoint_header(JfrChunkWriter& cw, intptr_t offset_prev_cp_event, const u1* data) { |
apetushkov@9858 | 257 | cw.reserve(sizeof(u4)); |
apetushkov@9858 | 258 | cw.write((u8)EVENT_CHECKPOINT); |
apetushkov@9858 | 259 | cw.write(starttime(data)); |
apetushkov@9858 | 260 | cw.write(duration(data)); |
apetushkov@9858 | 261 | cw.write((jlong)offset_prev_cp_event); |
apetushkov@9858 | 262 | cw.write(is_flushpoint(data)); |
apetushkov@9858 | 263 | cw.write(number_of_types(data)); |
apetushkov@9858 | 264 | } |
apetushkov@9858 | 265 | |
apetushkov@9858 | 266 | static void write_checkpoint_content(JfrChunkWriter& cw, const u1* data, size_t size) { |
apetushkov@9858 | 267 | assert(data != NULL, "invariant"); |
apetushkov@9858 | 268 | cw.write_unbuffered(data + payload_offset, size); |
apetushkov@9858 | 269 | } |
apetushkov@9858 | 270 | |
apetushkov@9858 | 271 | static size_t write_checkpoint_event(JfrChunkWriter& cw, const u1* data) { |
apetushkov@9858 | 272 | assert(data != NULL, "invariant"); |
apetushkov@9858 | 273 | const intptr_t previous_checkpoint_event = cw.previous_checkpoint_offset(); |
apetushkov@9858 | 274 | const intptr_t event_begin = cw.current_offset(); |
apetushkov@9858 | 275 | const intptr_t offset_to_previous_checkpoint_event = 0 == previous_checkpoint_event ? 0 : previous_checkpoint_event - event_begin; |
apetushkov@9858 | 276 | const jlong total_checkpoint_size = total_size(data); |
apetushkov@9858 | 277 | write_checkpoint_header(cw, offset_to_previous_checkpoint_event, data); |
apetushkov@9858 | 278 | write_checkpoint_content(cw, data, total_checkpoint_size - sizeof(JfrCheckpointEntry)); |
apetushkov@9858 | 279 | const jlong checkpoint_event_size = cw.current_offset() - event_begin; |
apetushkov@9858 | 280 | cw.write_padded_at_offset<u4>(checkpoint_event_size, event_begin); |
apetushkov@9858 | 281 | cw.set_previous_checkpoint_offset(event_begin); |
apetushkov@9858 | 282 | return (size_t)total_checkpoint_size; |
apetushkov@9858 | 283 | } |
apetushkov@9858 | 284 | |
apetushkov@9858 | 285 | static size_t write_checkpoints(JfrChunkWriter& cw, const u1* data, size_t size) { |
apetushkov@9858 | 286 | assert(cw.is_valid(), "invariant"); |
apetushkov@9858 | 287 | assert(data != NULL, "invariant"); |
apetushkov@9858 | 288 | assert(size > 0, "invariant"); |
apetushkov@9858 | 289 | const u1* const limit = data + size; |
apetushkov@9858 | 290 | const u1* next_entry = data; |
apetushkov@9858 | 291 | size_t processed = 0; |
apetushkov@9858 | 292 | while (next_entry < limit) { |
apetushkov@9858 | 293 | const size_t checkpoint_size = write_checkpoint_event(cw, next_entry); |
apetushkov@9858 | 294 | processed += checkpoint_size; |
apetushkov@9858 | 295 | next_entry += checkpoint_size; |
apetushkov@9858 | 296 | } |
apetushkov@9858 | 297 | assert(next_entry == limit, "invariant"); |
apetushkov@9858 | 298 | return processed; |
apetushkov@9858 | 299 | } |
apetushkov@9858 | 300 | |
apetushkov@9858 | 301 | template <typename T> |
apetushkov@9858 | 302 | class CheckpointWriteOp { |
apetushkov@9858 | 303 | private: |
apetushkov@9858 | 304 | JfrChunkWriter& _writer; |
apetushkov@9858 | 305 | size_t _processed; |
apetushkov@9858 | 306 | public: |
apetushkov@9858 | 307 | typedef T Type; |
apetushkov@9858 | 308 | CheckpointWriteOp(JfrChunkWriter& writer) : _writer(writer), _processed(0) {} |
apetushkov@9858 | 309 | bool write(Type* t, const u1* data, size_t size) { |
apetushkov@9858 | 310 | _processed += write_checkpoints(_writer, data, size); |
apetushkov@9858 | 311 | return true; |
apetushkov@9858 | 312 | } |
apetushkov@9858 | 313 | size_t processed() const { return _processed; } |
apetushkov@9858 | 314 | }; |
apetushkov@9858 | 315 | |
apetushkov@9858 | 316 | typedef CheckpointWriteOp<JfrCheckpointMspace::Type> WriteOperation; |
apetushkov@9858 | 317 | typedef MutexedWriteOp<WriteOperation> MutexedWriteOperation; |
apetushkov@9858 | 318 | typedef ReleaseOp<JfrCheckpointMspace> CheckpointReleaseOperation; |
apetushkov@9858 | 319 | typedef CompositeOperation<MutexedWriteOperation, CheckpointReleaseOperation> CheckpointWriteOperation; |
apetushkov@9858 | 320 | |
apetushkov@9858 | 321 | static size_t write_mspace_exclusive(JfrCheckpointMspace* mspace, JfrChunkWriter& chunkwriter) { |
apetushkov@9858 | 322 | Thread* const thread = Thread::current(); |
apetushkov@9858 | 323 | WriteOperation wo(chunkwriter); |
apetushkov@9858 | 324 | MutexedWriteOperation mwo(wo); |
apetushkov@9858 | 325 | CheckpointReleaseOperation cro(mspace, thread, false); |
apetushkov@9858 | 326 | CheckpointWriteOperation cpwo(&mwo, &cro); |
apetushkov@9858 | 327 | assert(mspace->is_full_empty(), "invariant"); |
apetushkov@9858 | 328 | process_free_list(cpwo, mspace); |
apetushkov@9858 | 329 | return wo.processed(); |
apetushkov@9858 | 330 | } |
apetushkov@9858 | 331 | |
apetushkov@9858 | 332 | size_t JfrCheckpointManager::write() { |
apetushkov@9858 | 333 | const size_t processed = write_mspace_exclusive(_free_list_mspace, _chunkwriter); |
apetushkov@9858 | 334 | synchronize_epoch(); |
apetushkov@9858 | 335 | return processed; |
apetushkov@9858 | 336 | } |
apetushkov@9858 | 337 | |
apetushkov@9858 | 338 | size_t JfrCheckpointManager::write_epoch_transition_mspace() { |
apetushkov@9858 | 339 | return write_mspace_exclusive(_epoch_transition_mspace, _chunkwriter); |
apetushkov@9858 | 340 | } |
apetushkov@9858 | 341 | |
apetushkov@9858 | 342 | typedef DiscardOp<DefaultDiscarder<JfrBuffer> > DiscardOperation; |
apetushkov@9858 | 343 | size_t JfrCheckpointManager::clear() { |
apetushkov@9858 | 344 | DiscardOperation discarder(mutexed); // mutexed discard mode |
apetushkov@9858 | 345 | process_free_list(discarder, _free_list_mspace); |
apetushkov@9858 | 346 | process_free_list(discarder, _epoch_transition_mspace); |
apetushkov@9858 | 347 | synchronize_epoch(); |
apetushkov@9858 | 348 | return discarder.processed(); |
apetushkov@9858 | 349 | } |
apetushkov@9858 | 350 | |
apetushkov@9858 | 351 | size_t JfrCheckpointManager::write_types() { |
apetushkov@9858 | 352 | JfrCheckpointWriter writer(false, true, Thread::current()); |
apetushkov@9858 | 353 | JfrTypeManager::write_types(writer); |
apetushkov@9858 | 354 | return writer.used_size(); |
apetushkov@9858 | 355 | } |
apetushkov@9858 | 356 | |
apetushkov@9858 | 357 | size_t JfrCheckpointManager::write_safepoint_types() { |
apetushkov@9858 | 358 | // this is also a "flushpoint" |
apetushkov@9858 | 359 | JfrCheckpointWriter writer(true, true, Thread::current()); |
apetushkov@9858 | 360 | JfrTypeManager::write_safepoint_types(writer); |
apetushkov@9858 | 361 | return writer.used_size(); |
apetushkov@9858 | 362 | } |
apetushkov@9858 | 363 | |
apetushkov@9858 | 364 | void JfrCheckpointManager::write_type_set() { |
apetushkov@9858 | 365 | JfrTypeManager::write_type_set(); |
apetushkov@9858 | 366 | } |
apetushkov@9858 | 367 | |
apetushkov@9858 | 368 | void JfrCheckpointManager::write_type_set_for_unloaded_classes() { |
apetushkov@9858 | 369 | assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!"); |
apetushkov@9858 | 370 | JfrTypeManager::write_type_set_for_unloaded_classes(); |
apetushkov@9858 | 371 | } |
apetushkov@9858 | 372 | |
apetushkov@9858 | 373 | void JfrCheckpointManager::create_thread_checkpoint(JavaThread* jt) { |
apetushkov@9858 | 374 | JfrTypeManager::create_thread_checkpoint(jt); |
apetushkov@9858 | 375 | } |
apetushkov@9858 | 376 | |
apetushkov@9858 | 377 | void JfrCheckpointManager::write_thread_checkpoint(JavaThread* jt) { |
apetushkov@9858 | 378 | JfrTypeManager::write_thread_checkpoint(jt); |
apetushkov@9858 | 379 | } |