src/share/vm/jfr/recorder/checkpoint/types/traceid/jfrTraceId.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) 2011, 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_JFRTRACEID_HPP
    26 #define SHARE_VM_JFR_CHECKPOINT_TYPES_TRACEID_JFRTRACEID_HPP
    28 #include "jni.h"
    29 #include "jfr/utilities/jfrTypes.hpp"
    30 #include "memory/allocation.hpp"
    32 class ClassLoaderData;
    33 class Klass;
    34 class Method;
    35 class Thread;
    37 /*
    38  * JfrTraceId is a means of tagging, e.g. marking, specific instances as being actively in-use.
    39  * The most common situation is a committed event that has a field that is referring to a specific instance.
    40  * Now there exist a relation between an event (field) and an artifact of some kind.
    41  * We track this relation during runtime using the JfrTraceId mechanism in order to reify it into the chunk
    42  * where the event is finally written.
    43  *
    44  * It is the event commit mechanism that tags instances as in-use. The tag routines return the untagged traceid
    45  * as a mapping key, and the commit mechanism writes the key into the event field.
    46  * Consequently, the mechanism is opaque and not something a user needs to know about.
    47  * Indeed, the API promotes using well-known JVM concepts directly in events, such as having a Klass* as an event field.
    48  *
    49  * Tagging allows for many-to-one mappings of constants, lazy evaluation / collection of tags during chunk rotation
    50  * and concurrency (by using an epoch relative tagging scheme).
    51  *
    52  * JfrTraceId(s) have been added to support tagging instances of classes such as:
    53  *
    54  *   Klass (includes Method)
    55  *   ClassLoaderData
    56  *
    57  * These classes have been extended to include a _traceid field (64-bits).
    58  *
    59  * Each instance is uniquely identified by a type-relative monotonic counter that is unique over the VM lifecycle.
    60  * "Tagging an instance" essentially means to set contextually determined (by epoch) marker bits in the _traceid field.
    61  * The constants associated with a tagged instance is a set of which is determined by a constant type definition,
    62  * and these constants are then serialized in an upcoming checkpoint event for the relevant chunk.
    63  *
    64  * Note that a "tagging" is relative to a chunk. Having serialized the tagged instance, the tag bits are reset (for that epoch).
    65  * As mentioned previously, the returned traceid is always the untagged value.
    66  *
    67  * We also use the _traceid field in Klass to quickly identify (bit check) if a newly loaded klass is of type jdk.jfr.Event.
    68  * (see jfr/instrumentation/jfrEventClassTransformer.cpp)
    69  *
    70  *
    71  * _traceid bit layout and description planned to go here
    72  *
    73  *
    74  */
    76 class JfrTraceId : public AllStatic {
    77  public:
    78   static void assign(const Klass* klass);
    79   static void assign(const ClassLoaderData* cld);
    80   static traceid assign_thread_id();
    82   static traceid get(const Klass* klass);
    83   static traceid get(jclass jc);
    84   static traceid get(const Thread* thread);
    86   // tag construct as used, returns pre-tagged traceid
    87   static traceid use(const Klass* klass, bool leakp = false);
    88   static traceid use(jclass jc, bool leakp = false);
    89   static traceid use(const Method* method, bool leakp = false);
    90   static traceid use(const ClassLoaderData* cld, bool leakp = false);
    92   static void remove(const Klass* klass);
    93   static void restore(const Klass* klass);
    95   // set of event classes made visible to java
    96   static bool in_visible_set(const Klass* k);
    97   static bool in_visible_set(const jclass jc);
    99   // jdk.jfr.Event
   100   static bool is_jdk_jfr_event(const Klass* k);
   101   static bool is_jdk_jfr_event(const jclass jc);
   102   static void tag_as_jdk_jfr_event(const Klass* k);
   104   // jdk.jfr.Event subklasses
   105   static bool is_jdk_jfr_event_sub(const Klass* k);
   106   static bool is_jdk_jfr_event_sub(const jclass jc);
   107   static void tag_as_jdk_jfr_event_sub(const Klass* k);
   108   static void tag_as_jdk_jfr_event_sub(const jclass jc);
   110   static bool in_jdk_jfr_event_hierarchy(const Klass* k);
   111   static bool in_jdk_jfr_event_hierarchy(const jclass jc);
   113   // klasses that host an event
   114   static bool is_event_host(const Klass* k);
   115   static bool is_event_host(const jclass jc);
   116   static void tag_as_event_host(const Klass* k);
   117   static void tag_as_event_host(const jclass jc);
   118 };
   120 #endif // SHARE_VM_JFR_CHECKPOINT_TYPES_TRACEID_JFRTRACEID_HPP

mercurial