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

mercurial