src/share/vm/jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp

Tue, 02 Jun 2020 14:29:43 +0800

author
ddong
date
Tue, 02 Jun 2020 14:29:43 +0800
changeset 9941
45c8de52649c
parent 9858
b985cbb00e68
permissions
-rw-r--r--

8246310: Clean commented-out code about ModuleEntry andPackageEntry in JFR
Reviewed-by: adinn

     1 /*
     2  * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
     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  */
    25 #ifndef SHARE_VM_JFR_CHECKPOINT_TYPES_TRACEID_JFRTYPEIDS_INLINE_HPP
    26 #define SHARE_VM_JFR_CHECKPOINT_TYPES_TRACEID_JFRTYPEIDS_INLINE_HPP
    28 #include "classfile/classLoaderData.hpp"
    29 #include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdMacros.hpp"
    30 #include "jfr/recorder/checkpoint/types/traceid/jfrTraceId.hpp"
    31 #include "oops/arrayKlass.hpp"
    32 #include "oops/klass.hpp"
    33 #include "oops/instanceKlass.hpp"
    34 #include "oops/method.hpp"
    35 #include "runtime/thread.inline.hpp"
    36 #include "utilities/debug.hpp"
    38 template <typename T>
    39 inline traceid set_used_and_get(const T* type, bool leakp) {
    40   assert(type != NULL, "invariant");
    41   if (leakp) {
    42     SET_LEAKP_USED_THIS_EPOCH(type);
    43     assert(LEAKP_USED_THIS_EPOCH(type), "invariant");
    44   }
    45   SET_USED_THIS_EPOCH(type);
    46   assert(USED_THIS_EPOCH(type), "invariant");
    47   return TRACE_ID_MASKED_PTR(type);
    48 }
    50 template <typename T>
    51 inline traceid set_used_and_get_shifted(const T* type, bool leakp) {
    52   assert(type != NULL, "invariant");
    53   return set_used_and_get(type, leakp) >> TRACE_ID_SHIFT;
    54 }
    56 inline traceid JfrTraceId::get(const Klass* klass) {
    57   assert(klass != NULL, "invariant");
    58   return TRACE_ID(klass);
    59 }
    61 inline traceid JfrTraceId::get(const Thread* t) {
    62   assert(t != NULL, "invariant");
    63   return TRACE_ID_RAW(t->jfr_thread_local());
    64 }
    66 inline traceid JfrTraceId::use(const Klass* klass, bool leakp /* false */) {
    67   assert(klass != NULL, "invariant");
    68   return set_used_and_get_shifted(klass, leakp);
    69 }
    71 inline traceid JfrTraceId::use(const Method* method, bool leakp /* false */) {
    72   assert(method != NULL, "invariant");
    73   SET_METHOD_FLAG_USED_THIS_EPOCH(method);
    74   const Klass* const klass = method->method_holder();
    75   assert(klass != NULL, "invariant");
    76   if (leakp) {
    77     SET_LEAKP_USED_THIS_EPOCH(klass);
    78     assert(LEAKP_USED_THIS_EPOCH(klass), "invariant");
    79   }
    80   SET_METHOD_AND_CLASS_USED_THIS_EPOCH(klass);
    81   assert(METHOD_AND_CLASS_USED_THIS_EPOCH(klass), "invariant");
    82   return (METHOD_ID(klass, method));
    83 }
    85 inline traceid JfrTraceId::use(const ClassLoaderData* cld, bool leakp /* false */) {
    86   assert(cld != NULL, "invariant");
    87   return cld->is_anonymous() ? 0 : set_used_and_get_shifted(cld, leakp);
    88 }
    90 inline bool JfrTraceId::in_visible_set(const Klass* klass) {
    91   assert(klass != NULL, "invariant");
    92   assert(((JavaThread*)Thread::current())->thread_state() == _thread_in_vm, "invariant");
    93   return (IS_JDK_JFR_EVENT_SUBKLASS(klass) && !klass->is_abstract()) || IS_EVENT_HOST_KLASS(klass);
    94 }
    96 inline bool JfrTraceId::is_jdk_jfr_event(const Klass* k) {
    97   assert(k != NULL, "invariant");
    98   return IS_JDK_JFR_EVENT_KLASS(k);
    99 }
   101 inline void JfrTraceId::tag_as_jdk_jfr_event(const Klass* klass) {
   102   assert(klass != NULL, "invariant");
   103   assert(IS_NOT_AN_EVENT_KLASS(klass), "invariant");
   104   SET_TAG(klass, JDK_JFR_EVENT_KLASS);
   105   assert(IS_JDK_JFR_EVENT_KLASS(klass), "invariant");
   106   assert(IS_NOT_AN_EVENT_SUB_KLASS(klass), "invariant");
   107 }
   109 inline bool JfrTraceId::is_jdk_jfr_event_sub(const Klass* k) {
   110   assert(k != NULL, "invariant");
   111   return IS_JDK_JFR_EVENT_SUBKLASS(k);
   112 }
   114 inline void JfrTraceId::tag_as_jdk_jfr_event_sub(const Klass* k) {
   115   assert(k != NULL, "invariant");
   116   if (IS_NOT_AN_EVENT_KLASS(k)) {
   117     SET_TAG(k, JDK_JFR_EVENT_SUBKLASS);
   118   }
   119   assert(IS_JDK_JFR_EVENT_SUBKLASS(k), "invariant");
   120 }
   122 inline bool JfrTraceId::in_jdk_jfr_event_hierarchy(const Klass* klass) {
   123   assert(klass != NULL, "invariant");
   124   if (is_jdk_jfr_event(klass)) {
   125     return true;
   126   }
   127   const Klass* const super = klass->super();
   128   return super != NULL ? IS_EVENT_KLASS(super) : false;
   129 }
   131 inline bool JfrTraceId::is_event_host(const Klass* k) {
   132   assert(k != NULL, "invariant");
   133   return IS_EVENT_HOST_KLASS(k);
   134 }
   136 inline void JfrTraceId::tag_as_event_host(const Klass* k) {
   137   assert(k != NULL, "invariant");
   138   SET_TAG(k, EVENT_HOST_KLASS);
   139   assert(IS_EVENT_HOST_KLASS(k), "invariant");
   140 }
   142 #endif // SHARE_VM_JFR_CHECKPOINT_TYPES_TRACEID_JFRTYPEIDS_INLINE_HPP

mercurial