author | mgronlun |
Thu, 24 Oct 2019 16:37:22 +0200 | |
changeset 58786 | 7909763ad193 |
parent 58132 | caa25ab47aca |
child 58823 | 6a21dba79b81 |
child 58836 | 31ec3e55fa3d |
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" |
|
58786
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
27 |
#include "jfr/leakprofiler/checkpoint/objectSampleCheckpoint.hpp" |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
28 |
#include "jfr/leakprofiler/leakProfiler.hpp" |
50113 | 29 |
#include "jfr/recorder/checkpoint/jfrCheckpointManager.hpp" |
30 |
#include "jfr/recorder/checkpoint/jfrCheckpointWriter.hpp" |
|
31 |
#include "jfr/recorder/checkpoint/types/jfrTypeManager.hpp" |
|
58786
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
32 |
#include "jfr/recorder/checkpoint/types/jfrTypeSet.hpp" |
50113 | 33 |
#include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp" |
58786
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
34 |
#include "jfr/recorder/jfrRecorder.hpp" |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
35 |
#include "jfr/recorder/repository/jfrChunkWriter.hpp" |
50113 | 36 |
#include "jfr/recorder/service/jfrOptionSet.hpp" |
37 |
#include "jfr/recorder/storage/jfrMemorySpace.inline.hpp" |
|
38 |
#include "jfr/recorder/storage/jfrStorageUtils.inline.hpp" |
|
39 |
#include "jfr/utilities/jfrBigEndian.hpp" |
|
40 |
#include "jfr/utilities/jfrTypes.hpp" |
|
41 |
#include "logging/log.hpp" |
|
42 |
#include "memory/resourceArea.hpp" |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
43 |
#include "runtime/handles.inline.hpp" |
50113 | 44 |
#include "runtime/mutexLocker.hpp" |
50429
83aec1d357d4
8204301: Make OrderAccess functions available to hpp rather than inline.hpp files
coleenp
parents:
50117
diff
changeset
|
45 |
#include "runtime/orderAccess.hpp" |
50117
fb66b2959eaf
8203251: Non-PCH build failed after JDK-8199712 (Flight Recorder)
shade
parents:
50113
diff
changeset
|
46 |
#include "runtime/os.inline.hpp" |
50113 | 47 |
#include "runtime/safepoint.hpp" |
48 |
||
49 |
typedef JfrCheckpointManager::Buffer* BufferPtr; |
|
50 |
||
51 |
static JfrCheckpointManager* _instance = NULL; |
|
52 |
||
53 |
JfrCheckpointManager& JfrCheckpointManager::instance() { |
|
54 |
return *_instance; |
|
55 |
} |
|
56 |
||
57 |
JfrCheckpointManager* JfrCheckpointManager::create(JfrChunkWriter& cw) { |
|
58 |
assert(_instance == NULL, "invariant"); |
|
59 |
_instance = new JfrCheckpointManager(cw); |
|
60 |
return _instance; |
|
61 |
} |
|
62 |
||
63 |
void JfrCheckpointManager::destroy() { |
|
64 |
assert(_instance != NULL, "invariant"); |
|
65 |
delete _instance; |
|
66 |
_instance = NULL; |
|
67 |
} |
|
68 |
||
69 |
JfrCheckpointManager::JfrCheckpointManager(JfrChunkWriter& cw) : |
|
70 |
_free_list_mspace(NULL), |
|
71 |
_epoch_transition_mspace(NULL), |
|
72 |
_lock(NULL), |
|
73 |
_service_thread(NULL), |
|
74 |
_chunkwriter(cw), |
|
75 |
_checkpoint_epoch_state(JfrTraceIdEpoch::epoch()) {} |
|
76 |
||
77 |
JfrCheckpointManager::~JfrCheckpointManager() { |
|
78 |
if (_free_list_mspace != NULL) { |
|
79 |
delete _free_list_mspace; |
|
80 |
} |
|
81 |
if (_epoch_transition_mspace != NULL) { |
|
82 |
delete _epoch_transition_mspace; |
|
83 |
} |
|
84 |
if (_lock != NULL) { |
|
85 |
delete _lock; |
|
86 |
} |
|
58786
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
87 |
JfrTypeManager::destroy(); |
50113 | 88 |
} |
89 |
||
90 |
static const size_t unlimited_mspace_size = 0; |
|
91 |
static const size_t checkpoint_buffer_cache_count = 2; |
|
92 |
static const size_t checkpoint_buffer_size = 512 * K; |
|
93 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
94 |
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
|
95 |
return create_mspace<JfrCheckpointMspace, JfrCheckpointManager>(size, limit, cache_count, mgr); |
50113 | 96 |
} |
97 |
||
98 |
bool JfrCheckpointManager::initialize() { |
|
99 |
assert(_free_list_mspace == NULL, "invariant"); |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
100 |
_free_list_mspace = allocate_mspace(checkpoint_buffer_size, unlimited_mspace_size, checkpoint_buffer_cache_count, this); |
50113 | 101 |
if (_free_list_mspace == NULL) { |
102 |
return false; |
|
103 |
} |
|
104 |
assert(_epoch_transition_mspace == NULL, "invariant"); |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
105 |
_epoch_transition_mspace = allocate_mspace(checkpoint_buffer_size, unlimited_mspace_size, checkpoint_buffer_cache_count, this); |
50113 | 106 |
if (_epoch_transition_mspace == NULL) { |
107 |
return false; |
|
108 |
} |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50429
diff
changeset
|
109 |
assert(_lock == NULL, "invariant"); |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50429
diff
changeset
|
110 |
_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
|
111 |
if (_lock == NULL) { |
50113 | 112 |
return false; |
113 |
} |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50429
diff
changeset
|
114 |
return JfrTypeManager::initialize(); |
50113 | 115 |
} |
116 |
||
117 |
void JfrCheckpointManager::register_service_thread(const Thread* thread) { |
|
118 |
_service_thread = thread; |
|
119 |
} |
|
120 |
||
121 |
void JfrCheckpointManager::register_full(BufferPtr t, Thread* thread) { |
|
122 |
// nothing here at the moment |
|
54964 | 123 |
assert(t != NULL, "invariant"); |
124 |
assert(t->acquired_by(thread), "invariant"); |
|
50113 | 125 |
assert(t->retired(), "invariant"); |
126 |
} |
|
127 |
||
128 |
void JfrCheckpointManager::lock() { |
|
129 |
assert(!_lock->owned_by_self(), "invariant"); |
|
130 |
_lock->lock_without_safepoint_check(); |
|
131 |
} |
|
132 |
||
133 |
void JfrCheckpointManager::unlock() { |
|
134 |
_lock->unlock(); |
|
135 |
} |
|
136 |
||
137 |
#ifdef ASSERT |
|
138 |
bool JfrCheckpointManager::is_locked() const { |
|
139 |
return _lock->owned_by_self(); |
|
140 |
} |
|
141 |
||
142 |
static void assert_free_lease(const BufferPtr buffer) { |
|
143 |
assert(buffer != NULL, "invariant"); |
|
144 |
assert(buffer->acquired_by_self(), "invariant"); |
|
145 |
assert(buffer->lease(), "invariant"); |
|
146 |
} |
|
147 |
||
148 |
static void assert_release(const BufferPtr buffer) { |
|
149 |
assert(buffer != NULL, "invariant"); |
|
150 |
assert(buffer->lease(), "invariant"); |
|
151 |
assert(buffer->acquired_by_self(), "invariant"); |
|
152 |
} |
|
153 |
#endif // ASSERT |
|
154 |
||
155 |
static BufferPtr lease_free(size_t size, JfrCheckpointMspace* mspace, size_t retry_count, Thread* thread) { |
|
156 |
static const size_t max_elem_size = mspace->min_elem_size(); // min is max |
|
157 |
BufferPtr buffer; |
|
158 |
if (size <= max_elem_size) { |
|
159 |
BufferPtr buffer = mspace_get_free_lease_with_retry(size, mspace, retry_count, thread); |
|
160 |
if (buffer != NULL) { |
|
161 |
DEBUG_ONLY(assert_free_lease(buffer);) |
|
162 |
return buffer; |
|
163 |
} |
|
164 |
} |
|
165 |
buffer = mspace_allocate_transient_lease_to_free(size, mspace, thread); |
|
166 |
DEBUG_ONLY(assert_free_lease(buffer);) |
|
167 |
return buffer; |
|
168 |
} |
|
169 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
170 |
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
|
171 |
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
|
172 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
173 |
|
50113 | 174 |
static const size_t lease_retry = 10; |
175 |
||
176 |
BufferPtr JfrCheckpointManager::lease_buffer(Thread* thread, size_t size /* 0 */) { |
|
177 |
JfrCheckpointManager& manager = instance(); |
|
178 |
if (manager.use_epoch_transition_mspace(thread)) { |
|
179 |
return lease_free(size, manager._epoch_transition_mspace, lease_retry, thread); |
|
180 |
} |
|
181 |
return lease_free(size, manager._free_list_mspace, lease_retry, thread); |
|
182 |
} |
|
183 |
||
184 |
/* |
|
185 |
* If the buffer was a "lease" from the free list, release back. |
|
186 |
* |
|
187 |
* The buffer is effectively invalidated for the thread post-return, |
|
188 |
* and the caller should take means to ensure that it is not referenced. |
|
189 |
*/ |
|
190 |
static void release(BufferPtr const buffer, Thread* thread) { |
|
191 |
DEBUG_ONLY(assert_release(buffer);) |
|
192 |
buffer->clear_lease(); |
|
193 |
buffer->release(); |
|
194 |
} |
|
195 |
||
196 |
BufferPtr JfrCheckpointManager::flush(BufferPtr old, size_t used, size_t requested, Thread* thread) { |
|
197 |
assert(old != NULL, "invariant"); |
|
198 |
assert(old->lease(), "invariant"); |
|
199 |
if (0 == requested) { |
|
200 |
// indicates a lease is being returned |
|
201 |
release(old, thread); |
|
202 |
return NULL; |
|
203 |
} |
|
204 |
// migration of in-flight information |
|
205 |
BufferPtr const new_buffer = lease_buffer(thread, used + requested); |
|
206 |
if (new_buffer != NULL) { |
|
207 |
migrate_outstanding_writes(old, new_buffer, used, requested); |
|
208 |
} |
|
209 |
release(old, thread); |
|
210 |
return new_buffer; // might be NULL |
|
211 |
} |
|
212 |
||
213 |
// offsets into the JfrCheckpointEntry |
|
214 |
static const juint starttime_offset = sizeof(jlong); |
|
215 |
static const juint duration_offset = starttime_offset + sizeof(jlong); |
|
216 |
static const juint flushpoint_offset = duration_offset + sizeof(jlong); |
|
217 |
static const juint types_offset = flushpoint_offset + sizeof(juint); |
|
218 |
static const juint payload_offset = types_offset + sizeof(juint); |
|
219 |
||
220 |
template <typename Return> |
|
221 |
static Return read_data(const u1* data) { |
|
222 |
return JfrBigEndian::read<Return>(data); |
|
223 |
} |
|
224 |
||
225 |
static jlong total_size(const u1* data) { |
|
226 |
return read_data<jlong>(data); |
|
227 |
} |
|
228 |
||
229 |
static jlong starttime(const u1* data) { |
|
230 |
return read_data<jlong>(data + starttime_offset); |
|
231 |
} |
|
232 |
||
233 |
static jlong duration(const u1* data) { |
|
234 |
return read_data<jlong>(data + duration_offset); |
|
235 |
} |
|
236 |
||
237 |
static bool is_flushpoint(const u1* data) { |
|
238 |
return read_data<juint>(data + flushpoint_offset) == (juint)1; |
|
239 |
} |
|
240 |
||
241 |
static juint number_of_types(const u1* data) { |
|
242 |
return read_data<juint>(data + types_offset); |
|
243 |
} |
|
244 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
245 |
static void write_checkpoint_header(JfrChunkWriter& cw, int64_t offset_prev_cp_event, const u1* data) { |
50113 | 246 |
cw.reserve(sizeof(u4)); |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
247 |
cw.write<u8>(EVENT_CHECKPOINT); |
50113 | 248 |
cw.write(starttime(data)); |
249 |
cw.write(duration(data)); |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
250 |
cw.write(offset_prev_cp_event); |
50113 | 251 |
cw.write(is_flushpoint(data)); |
252 |
cw.write(number_of_types(data)); |
|
253 |
} |
|
254 |
||
255 |
static void write_checkpoint_content(JfrChunkWriter& cw, const u1* data, size_t size) { |
|
256 |
assert(data != NULL, "invariant"); |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
257 |
cw.write_unbuffered(data + payload_offset, size - sizeof(JfrCheckpointEntry)); |
50113 | 258 |
} |
259 |
||
260 |
static size_t write_checkpoint_event(JfrChunkWriter& cw, const u1* data) { |
|
261 |
assert(data != NULL, "invariant"); |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
262 |
const int64_t event_begin = cw.current_offset(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
263 |
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
|
264 |
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
|
265 |
const int64_t checkpoint_size = total_size(data); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
266 |
write_checkpoint_header(cw, delta, data); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
267 |
write_checkpoint_content(cw, data, checkpoint_size); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
268 |
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
|
269 |
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
|
270 |
cw.set_last_checkpoint_offset(event_begin); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
271 |
return (size_t)checkpoint_size; |
50113 | 272 |
} |
273 |
||
274 |
static size_t write_checkpoints(JfrChunkWriter& cw, const u1* data, size_t size) { |
|
275 |
assert(cw.is_valid(), "invariant"); |
|
276 |
assert(data != NULL, "invariant"); |
|
277 |
assert(size > 0, "invariant"); |
|
278 |
const u1* const limit = data + size; |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
279 |
const u1* next = data; |
50113 | 280 |
size_t processed = 0; |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
281 |
while (next < limit) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
282 |
const size_t checkpoint_size = write_checkpoint_event(cw, next); |
50113 | 283 |
processed += checkpoint_size; |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
284 |
next += checkpoint_size; |
50113 | 285 |
} |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
286 |
assert(next == limit, "invariant"); |
50113 | 287 |
return processed; |
288 |
} |
|
289 |
||
290 |
template <typename T> |
|
291 |
class CheckpointWriteOp { |
|
292 |
private: |
|
293 |
JfrChunkWriter& _writer; |
|
294 |
size_t _processed; |
|
295 |
public: |
|
296 |
typedef T Type; |
|
297 |
CheckpointWriteOp(JfrChunkWriter& writer) : _writer(writer), _processed(0) {} |
|
298 |
bool write(Type* t, const u1* data, size_t size) { |
|
299 |
_processed += write_checkpoints(_writer, data, size); |
|
300 |
return true; |
|
301 |
} |
|
302 |
size_t processed() const { return _processed; } |
|
303 |
}; |
|
304 |
||
305 |
typedef CheckpointWriteOp<JfrCheckpointMspace::Type> WriteOperation; |
|
306 |
typedef ReleaseOp<JfrCheckpointMspace> CheckpointReleaseOperation; |
|
307 |
||
57980
ca9e3b68a969
8227411: TestTimeMultiple.java failed "assert(!lease()) failed: invariant"
mgronlun
parents:
54964
diff
changeset
|
308 |
template <template <typename> class WriterHost, template <typename, typename> class CompositeOperation> |
ca9e3b68a969
8227411: TestTimeMultiple.java failed "assert(!lease()) failed: invariant"
mgronlun
parents:
54964
diff
changeset
|
309 |
static size_t write_mspace(JfrCheckpointMspace* mspace, JfrChunkWriter& chunkwriter) { |
ca9e3b68a969
8227411: TestTimeMultiple.java failed "assert(!lease()) failed: invariant"
mgronlun
parents:
54964
diff
changeset
|
310 |
assert(mspace != NULL, "invariant"); |
50113 | 311 |
WriteOperation wo(chunkwriter); |
57980
ca9e3b68a969
8227411: TestTimeMultiple.java failed "assert(!lease()) failed: invariant"
mgronlun
parents:
54964
diff
changeset
|
312 |
WriterHost<WriteOperation> wh(wo); |
ca9e3b68a969
8227411: TestTimeMultiple.java failed "assert(!lease()) failed: invariant"
mgronlun
parents:
54964
diff
changeset
|
313 |
CheckpointReleaseOperation cro(mspace, Thread::current(), false); |
ca9e3b68a969
8227411: TestTimeMultiple.java failed "assert(!lease()) failed: invariant"
mgronlun
parents:
54964
diff
changeset
|
314 |
CompositeOperation<WriterHost<WriteOperation>, CheckpointReleaseOperation> co(&wh, &cro); |
50113 | 315 |
assert(mspace->is_full_empty(), "invariant"); |
57980
ca9e3b68a969
8227411: TestTimeMultiple.java failed "assert(!lease()) failed: invariant"
mgronlun
parents:
54964
diff
changeset
|
316 |
process_free_list(co, mspace); |
50113 | 317 |
return wo.processed(); |
318 |
} |
|
319 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
320 |
void JfrCheckpointManager::synchronize_epoch() { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
321 |
assert(_checkpoint_epoch_state != JfrTraceIdEpoch::epoch(), "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
322 |
OrderAccess::storestore(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
323 |
_checkpoint_epoch_state = JfrTraceIdEpoch::epoch(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
324 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
325 |
|
50113 | 326 |
size_t JfrCheckpointManager::write() { |
57980
ca9e3b68a969
8227411: TestTimeMultiple.java failed "assert(!lease()) failed: invariant"
mgronlun
parents:
54964
diff
changeset
|
327 |
const size_t processed = write_mspace<MutexedWriteOp, CompositeOperation>(_free_list_mspace, _chunkwriter); |
50113 | 328 |
synchronize_epoch(); |
329 |
return processed; |
|
330 |
} |
|
331 |
||
332 |
size_t JfrCheckpointManager::write_epoch_transition_mspace() { |
|
57980
ca9e3b68a969
8227411: TestTimeMultiple.java failed "assert(!lease()) failed: invariant"
mgronlun
parents:
54964
diff
changeset
|
333 |
return write_mspace<ExclusiveOp, CompositeOperation>(_epoch_transition_mspace, _chunkwriter); |
50113 | 334 |
} |
335 |
||
336 |
typedef DiscardOp<DefaultDiscarder<JfrBuffer> > DiscardOperation; |
|
337 |
size_t JfrCheckpointManager::clear() { |
|
58786
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
338 |
JfrTypeSet::clear(); |
50113 | 339 |
DiscardOperation discarder(mutexed); // mutexed discard mode |
340 |
process_free_list(discarder, _free_list_mspace); |
|
341 |
process_free_list(discarder, _epoch_transition_mspace); |
|
342 |
synchronize_epoch(); |
|
343 |
return discarder.processed(); |
|
344 |
} |
|
345 |
||
346 |
size_t JfrCheckpointManager::write_types() { |
|
347 |
JfrCheckpointWriter writer(false, true, Thread::current()); |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50429
diff
changeset
|
348 |
JfrTypeManager::write_types(writer); |
50113 | 349 |
return writer.used_size(); |
350 |
} |
|
351 |
||
352 |
size_t JfrCheckpointManager::write_safepoint_types() { |
|
353 |
// this is also a "flushpoint" |
|
354 |
JfrCheckpointWriter writer(true, true, Thread::current()); |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50429
diff
changeset
|
355 |
JfrTypeManager::write_safepoint_types(writer); |
50113 | 356 |
return writer.used_size(); |
357 |
} |
|
358 |
||
359 |
void JfrCheckpointManager::write_type_set() { |
|
58786
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
360 |
assert(!SafepointSynchronize::is_at_safepoint(), "invariant"); |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
361 |
// can safepoint here |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
362 |
MutexLocker cld_lock(ClassLoaderDataGraph_lock); |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
363 |
MutexLocker module_lock(Module_lock); |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
364 |
if (!LeakProfiler::is_running()) { |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
365 |
JfrCheckpointWriter writer(true, true, Thread::current()); |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
366 |
JfrTypeSet::serialize(&writer, NULL, false); |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
367 |
return; |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
368 |
} |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
369 |
Thread* const t = Thread::current(); |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
370 |
JfrCheckpointWriter leakp_writer(false, true, t); |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
371 |
JfrCheckpointWriter writer(false, true, t); |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
372 |
JfrTypeSet::serialize(&writer, &leakp_writer, false); |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
373 |
ObjectSampleCheckpoint::on_type_set(leakp_writer); |
50113 | 374 |
} |
375 |
||
376 |
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
|
377 |
assert_locked_or_safepoint(ClassLoaderDataGraph_lock); |
58786
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
378 |
JfrCheckpointWriter writer(false, true, Thread::current()); |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
379 |
const JfrCheckpointContext ctx = writer.context(); |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
380 |
JfrTypeSet::serialize(&writer, NULL, true); |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
381 |
if (LeakProfiler::is_running()) { |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
382 |
ObjectSampleCheckpoint::on_type_set_unload(writer); |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
383 |
} |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
384 |
if (!JfrRecorder::is_recording()) { |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
385 |
// discard by rewind |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
386 |
writer.set_context(ctx); |
7909763ad193
8231081: TestMetadataRetention fails due to missing symbol id
mgronlun
parents:
58132
diff
changeset
|
387 |
} |
50113 | 388 |
} |
389 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
390 |
void JfrCheckpointManager::create_thread_blob(JavaThread* jt) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
391 |
JfrTypeManager::create_thread_blob(jt); |
50113 | 392 |
} |
393 |
||
394 |
void JfrCheckpointManager::write_thread_checkpoint(JavaThread* jt) { |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50429
diff
changeset
|
395 |
JfrTypeManager::write_thread_checkpoint(jt); |
50113 | 396 |
} |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
397 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
398 |
void JfrCheckpointManager::shift_epoch() { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
399 |
debug_only(const u1 current_epoch = JfrTraceIdEpoch::current();) |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
400 |
JfrTraceIdEpoch::shift_epoch(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
401 |
assert(current_epoch != JfrTraceIdEpoch::current(), "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57980
diff
changeset
|
402 |
} |