author | egahlin |
Sun, 24 Nov 2019 01:03:33 +0100 | |
changeset 59239 | 9fe5d0d4e9c5 |
parent 58863 | c16ac7a2eba4 |
permissions | -rw-r--r-- |
55571
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
1 |
/* |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
4 |
* |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
8 |
* |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
13 |
* accompanied this code). |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
14 |
* |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
18 |
* |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
21 |
* questions. |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
22 |
* |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
23 |
*/ |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
24 |
|
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
26 |
#include "jfr/jfrEvents.hpp" |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
27 |
#include "jfr/leakprofiler/chains/edgeStore.hpp" |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
28 |
#include "jfr/leakprofiler/chains/pathToGcRootsOperation.hpp" |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
29 |
#include "jfr/leakprofiler/checkpoint/eventEmitter.hpp" |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
30 |
#include "jfr/leakprofiler/checkpoint/objectSampleCheckpoint.hpp" |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
31 |
#include "jfr/leakprofiler/sampling/objectSample.hpp" |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
32 |
#include "jfr/leakprofiler/sampling/objectSampler.hpp" |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
33 |
#include "logging/log.hpp" |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
34 |
#include "memory/resourceArea.hpp" |
57811 | 35 |
#include "oops/markWord.hpp" |
55571
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
36 |
#include "oops/oop.inline.hpp" |
58863 | 37 |
#include "runtime/mutexLocker.hpp" |
55571
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
38 |
#include "runtime/thread.inline.hpp" |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
39 |
#include "runtime/vmThread.hpp" |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
40 |
|
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
41 |
EventEmitter::EventEmitter(const JfrTicks& start_time, const JfrTicks& end_time) : |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
42 |
_start_time(start_time), |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
43 |
_end_time(end_time), |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
44 |
_thread(Thread::current()), |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
45 |
_jfr_thread_local(_thread->jfr_thread_local()), |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
46 |
_thread_id(_thread->jfr_thread_local()->thread_id()) {} |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
47 |
|
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
48 |
EventEmitter::~EventEmitter() { |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
49 |
// restore / reset thread local stack trace and thread id |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
50 |
_jfr_thread_local->set_thread_id(_thread_id); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
51 |
_jfr_thread_local->clear_cached_stack_trace(); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
52 |
} |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
53 |
|
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
54 |
void EventEmitter::emit(ObjectSampler* sampler, int64_t cutoff_ticks, bool emit_all) { |
58863 | 55 |
assert(JfrStream_lock->owned_by_self(), "invariant"); |
55571
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
56 |
assert(sampler != NULL, "invariant"); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
57 |
ResourceMark rm; |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
58 |
EdgeStore edge_store; |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
59 |
if (cutoff_ticks <= 0) { |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
60 |
// no reference chains |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
61 |
JfrTicks time_stamp = JfrTicks::now(); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
62 |
EventEmitter emitter(time_stamp, time_stamp); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
63 |
emitter.write_events(sampler, &edge_store, emit_all); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
64 |
return; |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
65 |
} |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
66 |
// events emitted with reference chains require a safepoint operation |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
67 |
PathToGcRootsOperation op(sampler, &edge_store, cutoff_ticks, emit_all); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
68 |
VMThread::execute(&op); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
69 |
} |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
70 |
|
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
71 |
size_t EventEmitter::write_events(ObjectSampler* object_sampler, EdgeStore* edge_store, bool emit_all) { |
58863 | 72 |
assert_locked_or_safepoint(JfrStream_lock); |
55571
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
73 |
assert(_thread == Thread::current(), "invariant"); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
74 |
assert(_thread->jfr_thread_local() == _jfr_thread_local, "invariant"); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
75 |
assert(object_sampler != NULL, "invariant"); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
76 |
assert(edge_store != NULL, "invariant"); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
77 |
|
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
78 |
const jlong last_sweep = emit_all ? max_jlong : object_sampler->last_sweep().value(); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
79 |
size_t count = 0; |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
80 |
|
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
81 |
const ObjectSample* current = object_sampler->first(); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
82 |
while (current != NULL) { |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
83 |
ObjectSample* prev = current->prev(); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
84 |
if (current->is_alive_and_older_than(last_sweep)) { |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
85 |
write_event(current, edge_store); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
86 |
++count; |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
87 |
} |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
88 |
current = prev; |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
89 |
} |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
90 |
|
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
91 |
if (count > 0) { |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
92 |
// serialize associated checkpoints and potential chains |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
93 |
ObjectSampleCheckpoint::write(object_sampler, edge_store, emit_all, _thread); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
94 |
} |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
95 |
return count; |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
96 |
} |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
97 |
|
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
98 |
static int array_size(const oop object) { |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
99 |
assert(object != NULL, "invariant"); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
100 |
if (object->is_array()) { |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
101 |
return arrayOop(object)->length(); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
102 |
} |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
103 |
return min_jint; |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
104 |
} |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
105 |
|
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
106 |
void EventEmitter::write_event(const ObjectSample* sample, EdgeStore* edge_store) { |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
107 |
assert(sample != NULL, "invariant"); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
108 |
assert(!sample->is_dead(), "invariant"); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
109 |
assert(edge_store != NULL, "invariant"); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
110 |
assert(_jfr_thread_local != NULL, "invariant"); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
111 |
|
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
112 |
const oop* object_addr = sample->object_addr(); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
113 |
traceid gc_root_id = 0; |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
114 |
const Edge* edge = NULL; |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
115 |
if (SafepointSynchronize::is_at_safepoint()) { |
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
55571
diff
changeset
|
116 |
edge = (const Edge*)(*object_addr)->mark().to_pointer(); |
55571
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
117 |
} |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
118 |
if (edge == NULL) { |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
119 |
// In order to dump out a representation of the event |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
120 |
// even though it was not reachable / too long to reach, |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
121 |
// we need to register a top level edge for this object. |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
122 |
edge = edge_store->put(object_addr); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
123 |
} else { |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
124 |
gc_root_id = edge_store->gc_root_id(edge); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
125 |
} |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
126 |
|
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
127 |
assert(edge != NULL, "invariant"); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
128 |
const traceid object_id = edge_store->get_id(edge); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
129 |
assert(object_id != 0, "invariant"); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
130 |
|
59239
9fe5d0d4e9c5
8226897: Provide object age with JFR OldObjectSample event
egahlin
parents:
58863
diff
changeset
|
131 |
Tickspan object_age = Ticks(_start_time.value()) - sample->allocation_time(); |
9fe5d0d4e9c5
8226897: Provide object age with JFR OldObjectSample event
egahlin
parents:
58863
diff
changeset
|
132 |
|
55571
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
133 |
EventOldObjectSample e(UNTIMED); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
134 |
e.set_starttime(_start_time); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
135 |
e.set_endtime(_end_time); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
136 |
e.set_allocationTime(sample->allocation_time()); |
59239
9fe5d0d4e9c5
8226897: Provide object age with JFR OldObjectSample event
egahlin
parents:
58863
diff
changeset
|
137 |
e.set_objectAge(object_age); |
55571
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
138 |
e.set_lastKnownHeapUsage(sample->heap_used_at_last_gc()); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
139 |
e.set_object(object_id); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
140 |
e.set_arrayElements(array_size(edge->pointee())); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
141 |
e.set_root(gc_root_id); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
142 |
|
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
143 |
// Temporarily assigning both the stack trace id and thread id |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
144 |
// onto the thread local data structure of the emitter thread (for the duration |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
145 |
// of the commit() call). This trick provides a means to override |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
146 |
// the event generation mechanism by injecting externally provided id's. |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
147 |
// At this particular location, it allows us to emit an old object event |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
148 |
// supplying information from where the actual sampling occurred. |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
149 |
_jfr_thread_local->set_cached_stack_trace_id(sample->stack_trace_id()); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
150 |
assert(sample->has_thread(), "invariant"); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
151 |
_jfr_thread_local->set_thread_id(sample->thread_id()); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
152 |
e.commit(); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
diff
changeset
|
153 |
} |