Mon, 19 Aug 2019 10:11:31 +0200
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
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_JFRTRACEIDEPOCH_HPP
26 #define SHARE_VM_JFR_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDEPOCH_HPP
28 #include "memory/allocation.hpp"
29 #include "jfr/utilities/jfrTypes.hpp"
31 #define USED_BIT 1
32 #define METHOD_USED_BIT (USED_BIT << 2)
33 #define EPOCH_1_SHIFT 0
34 #define EPOCH_2_SHIFT 1
35 #define LEAKP_SHIFT 8
37 #define USED_EPOCH_1_BIT (USED_BIT << EPOCH_1_SHIFT)
38 #define USED_EPOCH_2_BIT (USED_BIT << EPOCH_2_SHIFT)
39 #define LEAKP_USED_EPOCH_1_BIT (USED_EPOCH_1_BIT << LEAKP_SHIFT)
40 #define LEAKP_USED_EPOCH_2_BIT (USED_EPOCH_2_BIT << LEAKP_SHIFT)
41 #define METHOD_USED_EPOCH_1_BIT (METHOD_USED_BIT << EPOCH_1_SHIFT)
42 #define METHOD_USED_EPOCH_2_BIT (METHOD_USED_BIT << EPOCH_2_SHIFT)
43 #define METHOD_AND_CLASS_IN_USE_BITS (METHOD_USED_BIT | USED_BIT)
44 #define METHOD_AND_CLASS_IN_USE_EPOCH_1_BITS (METHOD_AND_CLASS_IN_USE_BITS << EPOCH_1_SHIFT)
45 #define METHOD_AND_CLASS_IN_USE_EPOCH_2_BITS (METHOD_AND_CLASS_IN_USE_BITS << EPOCH_2_SHIFT)
47 class JfrTraceIdEpoch : AllStatic {
48 friend class JfrCheckpointManager;
49 private:
50 static bool _epoch_state;
51 static void shift_epoch();
53 public:
54 static u1 epoch() {
55 return _epoch_state;
56 }
58 static jlong epoch_address() {
59 return (jlong)&_epoch_state;
60 }
62 static u1 current() {
63 return _epoch_state ? (u1)1 : (u1)0;
64 }
66 static u1 previous() {
67 return _epoch_state ? (u1)0 : (u1)1;
68 }
70 static traceid in_use_this_epoch_bit() {
71 return _epoch_state ? USED_EPOCH_2_BIT : USED_EPOCH_1_BIT;
72 }
74 static traceid in_use_prev_epoch_bit() {
75 return _epoch_state ? USED_EPOCH_1_BIT : USED_EPOCH_2_BIT;
76 }
78 static traceid leakp_in_use_this_epoch_bit() {
79 return _epoch_state ? LEAKP_USED_EPOCH_2_BIT : LEAKP_USED_EPOCH_1_BIT;
80 }
82 static traceid leakp_in_use_prev_epoch_bit() {
83 return _epoch_state ? LEAKP_USED_EPOCH_1_BIT : LEAKP_USED_EPOCH_2_BIT;
84 }
86 static traceid method_in_use_this_epoch_bit() {
87 return _epoch_state ? METHOD_USED_EPOCH_2_BIT : METHOD_USED_EPOCH_1_BIT;
88 }
90 static traceid method_in_use_prev_epoch_bit() {
91 return _epoch_state ? METHOD_USED_EPOCH_1_BIT : METHOD_USED_EPOCH_2_BIT;
92 }
94 static traceid method_and_class_in_use_this_epoch_bits() {
95 return _epoch_state ? METHOD_AND_CLASS_IN_USE_EPOCH_2_BITS : METHOD_AND_CLASS_IN_USE_EPOCH_1_BITS;
96 }
98 static traceid method_and_class_in_use_prev_epoch_bits() {
99 return _epoch_state ? METHOD_AND_CLASS_IN_USE_EPOCH_1_BITS : METHOD_AND_CLASS_IN_USE_EPOCH_2_BITS;
100 }
101 };
103 #endif // SHARE_VM_JFR_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDEPOCH_HPP