author | mgronlun |
Sun, 15 Sep 2019 20:23:40 +0200 | |
branch | JEP-349-branch |
changeset 58159 | 892527a70da9 |
parent 58157 | 9dca61a7df19 |
permissions | -rw-r--r-- |
50113 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50113
diff
changeset
|
2 |
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
50113 | 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 |
*/ |
|
24 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50113
diff
changeset
|
25 |
#ifndef SHARE_JFR_RECORDER_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDEPOCH_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50113
diff
changeset
|
26 |
#define SHARE_JFR_RECORDER_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDEPOCH_HPP |
50113 | 27 |
|
58159 | 28 |
#include "jfr/utilities/jfrTypes.hpp" |
50113 | 29 |
#include "memory/allocation.hpp" |
57873 | 30 |
#include "runtime/orderAccess.hpp" |
50113 | 31 |
|
58159 | 32 |
#define USED_BIT 1 |
33 |
#define METHOD_USED_BIT (USED_BIT << 2) |
|
34 |
#define EPOCH_1_SHIFT 0 |
|
35 |
#define EPOCH_2_SHIFT 1 |
|
36 |
#define USED_EPOCH_1_BIT (USED_BIT << EPOCH_1_SHIFT) |
|
37 |
#define USED_EPOCH_2_BIT (USED_BIT << EPOCH_2_SHIFT) |
|
38 |
#define METHOD_USED_EPOCH_1_BIT (METHOD_USED_BIT << EPOCH_1_SHIFT) |
|
39 |
#define METHOD_USED_EPOCH_2_BIT (METHOD_USED_BIT << EPOCH_2_SHIFT) |
|
40 |
#define METHOD_AND_CLASS_IN_USE_BITS (METHOD_USED_BIT | USED_BIT) |
|
50113 | 41 |
#define METHOD_AND_CLASS_IN_USE_EPOCH_1_BITS (METHOD_AND_CLASS_IN_USE_BITS << EPOCH_1_SHIFT) |
42 |
#define METHOD_AND_CLASS_IN_USE_EPOCH_2_BITS (METHOD_AND_CLASS_IN_USE_BITS << EPOCH_2_SHIFT) |
|
43 |
||
44 |
class JfrTraceIdEpoch : AllStatic { |
|
45 |
friend class JfrCheckpointManager; |
|
46 |
private: |
|
47 |
static bool _epoch_state; |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57873
diff
changeset
|
48 |
static bool volatile _tag_state; |
57873 | 49 |
|
50113 | 50 |
static void shift_epoch(); |
51 |
||
52 |
public: |
|
53 |
static bool epoch() { |
|
54 |
return _epoch_state; |
|
55 |
} |
|
56 |
||
57 |
static jlong epoch_address() { |
|
58 |
return (jlong)&_epoch_state; |
|
59 |
} |
|
60 |
||
61 |
static u1 current() { |
|
62 |
return _epoch_state ? (u1)1 : (u1)0; |
|
63 |
} |
|
64 |
||
65 |
static u1 previous() { |
|
66 |
return _epoch_state ? (u1)0 : (u1)1; |
|
67 |
} |
|
68 |
||
69 |
static traceid in_use_this_epoch_bit() { |
|
70 |
return _epoch_state ? USED_EPOCH_2_BIT : USED_EPOCH_1_BIT; |
|
71 |
} |
|
72 |
||
73 |
static traceid in_use_prev_epoch_bit() { |
|
74 |
return _epoch_state ? USED_EPOCH_1_BIT : USED_EPOCH_2_BIT; |
|
75 |
} |
|
76 |
||
77 |
static traceid method_in_use_this_epoch_bit() { |
|
78 |
return _epoch_state ? METHOD_USED_EPOCH_2_BIT : METHOD_USED_EPOCH_1_BIT; |
|
79 |
} |
|
80 |
||
81 |
static traceid method_in_use_prev_epoch_bit() { |
|
82 |
return _epoch_state ? METHOD_USED_EPOCH_1_BIT : METHOD_USED_EPOCH_2_BIT; |
|
83 |
} |
|
84 |
||
85 |
static traceid method_and_class_in_use_this_epoch_bits() { |
|
86 |
return _epoch_state ? METHOD_AND_CLASS_IN_USE_EPOCH_2_BITS : METHOD_AND_CLASS_IN_USE_EPOCH_1_BITS; |
|
87 |
} |
|
88 |
||
89 |
static traceid method_and_class_in_use_prev_epoch_bits() { |
|
90 |
return _epoch_state ? METHOD_AND_CLASS_IN_USE_EPOCH_1_BITS : METHOD_AND_CLASS_IN_USE_EPOCH_2_BITS; |
|
91 |
} |
|
57873 | 92 |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57873
diff
changeset
|
93 |
static bool has_changed_tag_state() { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57873
diff
changeset
|
94 |
if (OrderAccess::load_acquire(&_tag_state)) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57873
diff
changeset
|
95 |
OrderAccess::release_store(&_tag_state, false); |
57873 | 96 |
return true; |
97 |
} |
|
98 |
return false; |
|
99 |
} |
|
100 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57873
diff
changeset
|
101 |
static void set_changed_tag_state() { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57873
diff
changeset
|
102 |
if (!OrderAccess::load_acquire(&_tag_state)) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57873
diff
changeset
|
103 |
OrderAccess::release_store(&_tag_state, true); |
57873 | 104 |
} |
105 |
} |
|
50113 | 106 |
}; |
107 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50113
diff
changeset
|
108 |
#endif // SHARE_JFR_RECORDER_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDEPOCH_HPP |