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