author | stefank |
Mon, 25 Nov 2019 12:33:15 +0100 | |
changeset 59252 | 623722a6aeb9 |
parent 58966 | 6c6cce0f149d |
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 |
||
58836
31ec3e55fa3d
8230400: Missing constant pool entry for a method in stacktrace
mgronlun
parents:
58132
diff
changeset
|
41 |
inline void set_bits(jbyte bits, jbyte volatile* const dest) { |
50113 | 42 |
assert(dest != NULL, "invariant"); |
58966
6c6cce0f149d
8233416: JFR: assert((((((klass)->trace_id()) & (((1 << 1) << 8) | (JfrTraceIdEpoch::in_use_this_epoch_bit()))) != 0))) failed: invariant
mgronlun
parents:
58836
diff
changeset
|
43 |
*dest |= bits; |
6c6cce0f149d
8233416: JFR: assert((((((klass)->trace_id()) & (((1 << 1) << 8) | (JfrTraceIdEpoch::in_use_this_epoch_bit()))) != 0))) failed: invariant
mgronlun
parents:
58836
diff
changeset
|
44 |
OrderAccess::storestore(); |
50113 | 45 |
} |
46 |
||
57617
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
47 |
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
|
48 |
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
|
49 |
} |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
50 |
|
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_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
|
52 |
return current | bits; |
50113 | 53 |
} |
54 |
||
57617
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_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
|
56 |
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
|
57 |
} |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
58 |
|
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
59 |
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
|
60 |
inline void set_bits_cas_form(jbyte bits, jbyte* const dest) { |
50113 | 61 |
assert(dest != NULL, "invariant"); |
62 |
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
|
63 |
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
|
64 |
const jbyte new_value = op(current, bits); |
59252
623722a6aeb9
8234740: Harmonize parameter order in Atomic - cmpxchg
stefank
parents:
58966
diff
changeset
|
65 |
if (Atomic::cmpxchg(dest, current, new_value) == current) { |
50113 | 66 |
return; |
67 |
} |
|
68 |
} while (true); |
|
69 |
} |
|
70 |
||
57617
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
71 |
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
|
72 |
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
|
73 |
} |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
74 |
|
50113 | 75 |
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
|
76 |
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
|
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 |
|
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
79 |
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
|
80 |
set_bits_cas_form<traceid_and>(mask, dest); |
50113 | 81 |
} |
82 |
||
83 |
inline void set_traceid_bits(jbyte bits, traceid* dest) { |
|
84 |
set_bits(bits, ((jbyte*)dest) + low_offset); |
|
85 |
} |
|
86 |
||
87 |
inline void set_traceid_bits_cas(jbyte bits, traceid* dest) { |
|
88 |
set_bits_cas(bits, ((jbyte*)dest) + low_offset); |
|
89 |
} |
|
90 |
||
91 |
inline void set_traceid_mask(jbyte mask, traceid* dest) { |
|
92 |
set_mask(mask, ((jbyte*)dest) + low_offset); |
|
93 |
} |
|
94 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
95 |
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
|
96 |
assert(dest != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
97 |
*dest |= bits; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
98 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
99 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
100 |
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
|
101 |
set_meta_bits(bits, ((jbyte*)dest) + meta_offset); |
50113 | 102 |
} |
103 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
104 |
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
|
105 |
assert(dest != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
106 |
*dest &= mask; |
50113 | 107 |
} |
108 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
109 |
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
|
110 |
set_meta_mask(mask, ((jbyte*)dest) + meta_offset); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
111 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
112 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
113 |
// 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
|
114 |
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
|
115 |
assert(dest != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
116 |
*dest ^= bits; |
50113 | 117 |
} |
118 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50429
diff
changeset
|
119 |
#endif // SHARE_JFR_RECORDER_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDBITS_INLINE_HPP |