src/share/vm/jfr/support/jfrThreadLocal.hpp

Mon, 19 Aug 2019 10:11:31 +0200

author
neugens
date
Mon, 19 Aug 2019 10:11:31 +0200
changeset 9861
a248d0be1309
parent 9858
b985cbb00e68
child 9868
69fb91513217
permissions
-rw-r--r--

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) 2012, 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 #ifndef SHARE_VM_JFR_SUPPORT_JFRTHREADLOCAL_HPP
apetushkov@9858 26 #define SHARE_VM_JFR_SUPPORT_JFRTHREADLOCAL_HPP
apetushkov@9858 27
apetushkov@9858 28 #include "jfr/recorder/checkpoint/jfrCheckpointBlob.hpp"
apetushkov@9858 29 #include "jfr/utilities/jfrTypes.hpp"
apetushkov@9858 30 #include "utilities/sizes.hpp"
apetushkov@9858 31
apetushkov@9858 32 class JavaThread;
apetushkov@9858 33 class JfrBuffer;
apetushkov@9858 34 class JfrStackFrame;
apetushkov@9858 35
apetushkov@9858 36 class JfrThreadLocal {
apetushkov@9858 37 private:
apetushkov@9858 38 jobject _java_event_writer;
apetushkov@9858 39 mutable JfrBuffer* _java_buffer;
apetushkov@9858 40 mutable JfrBuffer* _native_buffer;
apetushkov@9858 41 JfrBuffer* _shelved_buffer;
apetushkov@9858 42 mutable JfrStackFrame* _stackframes;
apetushkov@9858 43 mutable traceid _trace_id;
apetushkov@9858 44 JfrCheckpointBlobHandle _thread_cp;
apetushkov@9858 45 u8 _data_lost;
apetushkov@9858 46 traceid _stack_trace_id;
apetushkov@9858 47 jlong _user_time;
apetushkov@9858 48 jlong _cpu_time;
apetushkov@9858 49 jlong _wallclock_time;
apetushkov@9858 50 unsigned int _stack_trace_hash;
apetushkov@9858 51 mutable u4 _stackdepth;
apetushkov@9858 52 volatile jint _entering_suspend_flag;
apetushkov@9858 53 bool _dead;
apetushkov@9858 54
apetushkov@9858 55 JfrBuffer* install_native_buffer() const;
apetushkov@9858 56 JfrBuffer* install_java_buffer() const;
apetushkov@9858 57 JfrStackFrame* install_stackframes() const;
apetushkov@9858 58
apetushkov@9858 59 void set_dead();
apetushkov@9858 60
apetushkov@9858 61 public:
apetushkov@9858 62 JfrThreadLocal();
apetushkov@9858 63
apetushkov@9858 64 JfrBuffer* native_buffer() const {
apetushkov@9858 65 return _native_buffer != NULL ? _native_buffer : install_native_buffer();
apetushkov@9858 66 }
apetushkov@9858 67
apetushkov@9858 68 bool has_native_buffer() const {
apetushkov@9858 69 return _native_buffer != NULL;
apetushkov@9858 70 }
apetushkov@9858 71
apetushkov@9858 72 void set_native_buffer(JfrBuffer* buffer) {
apetushkov@9858 73 _native_buffer = buffer;
apetushkov@9858 74 }
apetushkov@9858 75
apetushkov@9858 76 JfrBuffer* java_buffer() const {
apetushkov@9858 77 return _java_buffer != NULL ? _java_buffer : install_java_buffer();
apetushkov@9858 78 }
apetushkov@9858 79
apetushkov@9858 80 bool has_java_buffer() const {
apetushkov@9858 81 return _java_buffer != NULL;
apetushkov@9858 82 }
apetushkov@9858 83
apetushkov@9858 84 void set_java_buffer(JfrBuffer* buffer) {
apetushkov@9858 85 _java_buffer = buffer;
apetushkov@9858 86 }
apetushkov@9858 87
apetushkov@9858 88 JfrBuffer* shelved_buffer() const {
apetushkov@9858 89 return _shelved_buffer;
apetushkov@9858 90 }
apetushkov@9858 91
apetushkov@9858 92 void shelve_buffer(JfrBuffer* buffer) {
apetushkov@9858 93 _shelved_buffer = buffer;
apetushkov@9858 94 }
apetushkov@9858 95
apetushkov@9858 96 bool has_java_event_writer() const {
apetushkov@9858 97 return _java_event_writer != NULL;
apetushkov@9858 98 }
apetushkov@9858 99
apetushkov@9858 100 jobject java_event_writer() {
apetushkov@9858 101 return _java_event_writer;
apetushkov@9858 102 }
apetushkov@9858 103
apetushkov@9858 104 void set_java_event_writer(jobject java_event_writer) {
apetushkov@9858 105 _java_event_writer = java_event_writer;
apetushkov@9858 106 }
apetushkov@9858 107
apetushkov@9858 108 JfrStackFrame* stackframes() const {
apetushkov@9858 109 return _stackframes != NULL ? _stackframes : install_stackframes();
apetushkov@9858 110 }
apetushkov@9858 111
apetushkov@9858 112 void set_stackframes(JfrStackFrame* frames) {
apetushkov@9858 113 _stackframes = frames;
apetushkov@9858 114 }
apetushkov@9858 115
apetushkov@9858 116 u4 stackdepth() const {
apetushkov@9858 117 return _stackdepth;
apetushkov@9858 118 }
apetushkov@9858 119
apetushkov@9858 120 void set_stackdepth(u4 depth) {
apetushkov@9858 121 _stackdepth = depth;
apetushkov@9858 122 }
apetushkov@9858 123
apetushkov@9858 124 traceid thread_id() const {
apetushkov@9858 125 return _trace_id;
apetushkov@9858 126 }
apetushkov@9858 127
apetushkov@9858 128 void set_thread_id(traceid thread_id) {
apetushkov@9858 129 _trace_id = thread_id;
apetushkov@9858 130 }
apetushkov@9858 131
apetushkov@9858 132 void set_cached_stack_trace_id(traceid id, unsigned int hash = 0) {
apetushkov@9858 133 _stack_trace_id = id;
apetushkov@9858 134 _stack_trace_hash = hash;
apetushkov@9858 135 }
apetushkov@9858 136
apetushkov@9858 137 bool has_cached_stack_trace() const {
apetushkov@9858 138 return _stack_trace_id != max_julong;
apetushkov@9858 139 }
apetushkov@9858 140
apetushkov@9858 141 void clear_cached_stack_trace() {
apetushkov@9858 142 _stack_trace_id = max_julong;
apetushkov@9858 143 _stack_trace_hash = 0;
apetushkov@9858 144 }
apetushkov@9858 145
apetushkov@9858 146 traceid cached_stack_trace_id() const {
apetushkov@9858 147 return _stack_trace_id;
apetushkov@9858 148 }
apetushkov@9858 149
apetushkov@9858 150 unsigned int cached_stack_trace_hash() const {
apetushkov@9858 151 return _stack_trace_hash;
apetushkov@9858 152 }
apetushkov@9858 153
apetushkov@9858 154 void set_trace_block() {
apetushkov@9858 155 _entering_suspend_flag = 1;
apetushkov@9858 156 }
apetushkov@9858 157
apetushkov@9858 158 void clear_trace_block() {
apetushkov@9858 159 _entering_suspend_flag = 0;
apetushkov@9858 160 }
apetushkov@9858 161
apetushkov@9858 162 bool is_trace_block() const {
apetushkov@9858 163 return _entering_suspend_flag != 0;
apetushkov@9858 164 }
apetushkov@9858 165
apetushkov@9858 166 u8 data_lost() const {
apetushkov@9858 167 return _data_lost;
apetushkov@9858 168 }
apetushkov@9858 169
apetushkov@9858 170 u8 add_data_lost(u8 value);
apetushkov@9858 171
apetushkov@9858 172 jlong get_user_time() const {
apetushkov@9858 173 return _user_time;
apetushkov@9858 174 }
apetushkov@9858 175
apetushkov@9858 176 void set_user_time(jlong user_time) {
apetushkov@9858 177 _user_time = user_time;
apetushkov@9858 178 }
apetushkov@9858 179
apetushkov@9858 180 jlong get_cpu_time() const {
apetushkov@9858 181 return _cpu_time;
apetushkov@9858 182 }
apetushkov@9858 183
apetushkov@9858 184 void set_cpu_time(jlong cpu_time) {
apetushkov@9858 185 _cpu_time = cpu_time;
apetushkov@9858 186 }
apetushkov@9858 187
apetushkov@9858 188 jlong get_wallclock_time() const {
apetushkov@9858 189 return _wallclock_time;
apetushkov@9858 190 }
apetushkov@9858 191
apetushkov@9858 192 void set_wallclock_time(jlong wallclock_time) {
apetushkov@9858 193 _wallclock_time = wallclock_time;
apetushkov@9858 194 }
apetushkov@9858 195
apetushkov@9858 196 traceid trace_id() const {
apetushkov@9858 197 return _trace_id;
apetushkov@9858 198 }
apetushkov@9858 199
apetushkov@9858 200 traceid* const trace_id_addr() const {
apetushkov@9858 201 return &_trace_id;
apetushkov@9858 202 }
apetushkov@9858 203
apetushkov@9858 204 void set_trace_id(traceid id) const {
apetushkov@9858 205 _trace_id = id;
apetushkov@9858 206 }
apetushkov@9858 207
apetushkov@9858 208 bool is_dead() const {
apetushkov@9858 209 return _dead;
apetushkov@9858 210 }
apetushkov@9858 211
apetushkov@9858 212 bool has_thread_checkpoint() const;
apetushkov@9858 213 void set_thread_checkpoint(const JfrCheckpointBlobHandle& handle);
apetushkov@9858 214 const JfrCheckpointBlobHandle& thread_checkpoint() const;
apetushkov@9858 215
apetushkov@9858 216 static JfrBuffer* acquire(Thread* t, size_t size = 0);
apetushkov@9858 217 static void release(JfrBuffer* buffer, Thread* t);
apetushkov@9858 218 static void destroy_stackframes(Thread* t);
apetushkov@9858 219 static void on_exit(JavaThread* t);
apetushkov@9858 220 static void on_destruct(Thread* t);
apetushkov@9858 221
apetushkov@9858 222 // Code generation
apetushkov@9858 223 static ByteSize trace_id_offset() {
apetushkov@9858 224 return in_ByteSize(offset_of(JfrThreadLocal, _trace_id));
apetushkov@9858 225 }
apetushkov@9858 226
apetushkov@9858 227 static ByteSize java_event_writer_offset() {
apetushkov@9858 228 return in_ByteSize(offset_of(JfrThreadLocal, _java_event_writer));
apetushkov@9858 229 }
apetushkov@9858 230 };
apetushkov@9858 231
apetushkov@9858 232 #endif // SHARE_VM_JFR_SUPPORT_JFRTHREADLOCAL_HPP

mercurial