Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/jfr/support/jfrThreadLocal.hpp
38920 views
/*1* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_JFR_SUPPORT_JFRTHREADLOCAL_HPP25#define SHARE_VM_JFR_SUPPORT_JFRTHREADLOCAL_HPP2627#include "jfr/recorder/checkpoint/jfrCheckpointBlob.hpp"28#include "jfr/utilities/jfrTypes.hpp"2930class JavaThread;31class JfrBuffer;32class JfrStackFrame;33class Thread;3435class JfrThreadLocal {36private:37jobject _java_event_writer;38mutable JfrBuffer* _java_buffer;39mutable JfrBuffer* _native_buffer;40JfrBuffer* _shelved_buffer;41mutable JfrStackFrame* _stackframes;42mutable traceid _trace_id;43JfrCheckpointBlobHandle _thread_cp;44u8 _data_lost;45traceid _stack_trace_id;46jlong _user_time;47jlong _cpu_time;48jlong _wallclock_time;49unsigned int _stack_trace_hash;50mutable u4 _stackdepth;51volatile jint _entering_suspend_flag;52bool _dead;5354JfrBuffer* install_native_buffer() const;55JfrBuffer* install_java_buffer() const;56JfrStackFrame* install_stackframes() const;5758static void release(JfrThreadLocal* tl, Thread* t);5960public:61JfrThreadLocal();6263JfrBuffer* native_buffer() const {64return _native_buffer != NULL ? _native_buffer : install_native_buffer();65}6667bool has_native_buffer() const {68return _native_buffer != NULL;69}7071void set_native_buffer(JfrBuffer* buffer) {72_native_buffer = buffer;73}7475JfrBuffer* java_buffer() const {76return _java_buffer != NULL ? _java_buffer : install_java_buffer();77}7879bool has_java_buffer() const {80return _java_buffer != NULL;81}8283void set_java_buffer(JfrBuffer* buffer) {84_java_buffer = buffer;85}8687JfrBuffer* shelved_buffer() const {88return _shelved_buffer;89}9091void shelve_buffer(JfrBuffer* buffer) {92_shelved_buffer = buffer;93}9495bool has_java_event_writer() const {96return _java_event_writer != NULL;97}9899jobject java_event_writer() {100return _java_event_writer;101}102103void set_java_event_writer(jobject java_event_writer) {104_java_event_writer = java_event_writer;105}106107JfrStackFrame* stackframes() const {108return _stackframes != NULL ? _stackframes : install_stackframes();109}110111void set_stackframes(JfrStackFrame* frames) {112_stackframes = frames;113}114115u4 stackdepth() const;116117void set_stackdepth(u4 depth) {118_stackdepth = depth;119}120121traceid thread_id() const {122return _trace_id;123}124125void set_thread_id(traceid thread_id) {126_trace_id = thread_id;127}128129void set_cached_stack_trace_id(traceid id, unsigned int hash = 0) {130_stack_trace_id = id;131_stack_trace_hash = hash;132}133134bool has_cached_stack_trace() const {135return _stack_trace_id != max_julong;136}137138void clear_cached_stack_trace() {139_stack_trace_id = max_julong;140_stack_trace_hash = 0;141}142143traceid cached_stack_trace_id() const {144return _stack_trace_id;145}146147unsigned int cached_stack_trace_hash() const {148return _stack_trace_hash;149}150151void set_trace_block() {152_entering_suspend_flag = 1;153}154155void clear_trace_block() {156_entering_suspend_flag = 0;157}158159bool is_trace_block() const {160return _entering_suspend_flag != 0;161}162163u8 data_lost() const {164return _data_lost;165}166167u8 add_data_lost(u8 value);168169jlong get_user_time() const {170return _user_time;171}172173void set_user_time(jlong user_time) {174_user_time = user_time;175}176177jlong get_cpu_time() const {178return _cpu_time;179}180181void set_cpu_time(jlong cpu_time) {182_cpu_time = cpu_time;183}184185jlong get_wallclock_time() const {186return _wallclock_time;187}188189void set_wallclock_time(jlong wallclock_time) {190_wallclock_time = wallclock_time;191}192193traceid trace_id() const {194return _trace_id;195}196197traceid* const trace_id_addr() const {198return &_trace_id;199}200201void set_trace_id(traceid id) const {202_trace_id = id;203}204205bool is_dead() const {206return _dead;207}208209bool has_thread_checkpoint() const;210void set_thread_checkpoint(const JfrCheckpointBlobHandle& handle);211const JfrCheckpointBlobHandle& thread_checkpoint() const;212213static void on_start(Thread* t);214static void on_exit(Thread* t);215216// Code generation217static ByteSize trace_id_offset();218static ByteSize java_event_writer_offset();219};220221#endif // SHARE_VM_JFR_SUPPORT_JFRTHREADLOCAL_HPP222223224