author | mgronlun |
Wed, 09 Oct 2019 23:21:07 +0200 | |
branch | JEP-349-branch |
changeset 58525 | 2a49d43aaa6a |
parent 58157 | 9dca61a7df19 |
child 58823 | 6a21dba79b81 |
permissions | -rw-r--r-- |
50113 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50429
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:
50429
diff
changeset
|
25 |
#ifndef SHARE_JFR_RECORDER_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDBITS_INLINE_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50429
diff
changeset
|
26 |
#define SHARE_JFR_RECORDER_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDBITS_INLINE_HPP |
50113 | 27 |
|
28 |
#include "jfr/utilities/jfrTypes.hpp" |
|
29 |
#include "runtime/atomic.hpp" |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
30 |
#include "runtime/orderAccess.hpp" |
50113 | 31 |
#include "utilities/macros.hpp" |
32 |
||
33 |
#ifdef VM_LITTLE_ENDIAN |
|
34 |
static const int low_offset = 0; |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
35 |
static const int meta_offset = low_offset + 1; |
50113 | 36 |
#else |
37 |
static const int low_offset = 7; |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
38 |
static const int meta_offset = low_offset - 1; |
50113 | 39 |
#endif |
40 |
||
41 |
inline void set_bits(jbyte bits, jbyte* const dest) { |
|
42 |
assert(dest != NULL, "invariant"); |
|
57617
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
43 |
if (bits != (*dest & bits)) { |
50113 | 44 |
*dest |= bits; |
58525 | 45 |
OrderAccess::storeload(); |
46 |
return; |
|
50113 | 47 |
} |
58525 | 48 |
OrderAccess::loadload(); |
50113 | 49 |
} |
50 |
||
57617
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
51 |
inline jbyte traceid_and(jbyte current, jbyte bits) { |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
52 |
return current & bits; |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
53 |
} |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
54 |
|
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
55 |
inline jbyte traceid_or(jbyte current, jbyte bits) { |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
56 |
return current | bits; |
50113 | 57 |
} |
58 |
||
57617
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
59 |
inline jbyte traceid_xor(jbyte current, jbyte bits) { |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
60 |
return current ^ bits; |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
61 |
} |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
62 |
|
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
63 |
template <jbyte op(jbyte, jbyte)> |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
64 |
inline void set_bits_cas_form(jbyte bits, jbyte* const dest) { |
50113 | 65 |
assert(dest != NULL, "invariant"); |
66 |
do { |
|
57617
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
67 |
const jbyte current = *dest; |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
68 |
const jbyte new_value = op(current, bits); |
50113 | 69 |
if (Atomic::cmpxchg(new_value, dest, current) == current) { |
70 |
return; |
|
71 |
} |
|
72 |
} while (true); |
|
73 |
} |
|
74 |
||
57617
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
75 |
inline void set_bits_cas(jbyte bits, jbyte* const dest) { |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
76 |
set_bits_cas_form<traceid_or>(bits, dest); |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
77 |
} |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
78 |
|
50113 | 79 |
inline void clear_bits_cas(jbyte bits, jbyte* const dest) { |
57617
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
80 |
set_bits_cas_form<traceid_xor>(bits, dest); |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
81 |
} |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
82 |
|
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
83 |
inline void set_mask(jbyte mask, jbyte* const dest) { |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
84 |
set_bits_cas_form<traceid_and>(mask, dest); |
50113 | 85 |
} |
86 |
||
87 |
inline void set_traceid_bits(jbyte bits, traceid* dest) { |
|
88 |
set_bits(bits, ((jbyte*)dest) + low_offset); |
|
89 |
} |
|
90 |
||
91 |
inline void set_traceid_bits_cas(jbyte bits, traceid* dest) { |
|
92 |
set_bits_cas(bits, ((jbyte*)dest) + low_offset); |
|
93 |
} |
|
94 |
||
95 |
inline void set_traceid_mask(jbyte mask, traceid* dest) { |
|
96 |
set_mask(mask, ((jbyte*)dest) + low_offset); |
|
97 |
} |
|
98 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
99 |
inline void set_meta_bits(jbyte bits, jbyte* const dest) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
100 |
assert(dest != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
101 |
*dest |= bits; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
102 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
103 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
104 |
inline void set_traceid_meta_bits(jbyte bits, traceid* dest) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
105 |
set_meta_bits(bits, ((jbyte*)dest) + meta_offset); |
50113 | 106 |
} |
107 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
108 |
inline void set_meta_mask(jbyte mask, jbyte* const dest) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
109 |
assert(dest != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
110 |
*dest &= mask; |
50113 | 111 |
} |
112 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
113 |
inline void set_traceid_meta_mask(jbyte mask, traceid* dest) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
114 |
set_meta_mask(mask, ((jbyte*)dest) + meta_offset); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
115 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
116 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
117 |
// only used by a single thread with no visibility requirements |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
118 |
inline void clear_meta_bits(jbyte bits, jbyte* const dest) { |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
119 |
assert(dest != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
120 |
*dest ^= bits; |
50113 | 121 |
} |
122 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50429
diff
changeset
|
123 |
#endif // SHARE_JFR_RECORDER_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDBITS_INLINE_HPP |