author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 58132 | caa25ab47aca |
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; |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
45 |
OrderAccess::storestore(); |
50113 | 46 |
} |
47 |
} |
|
48 |
||
57617
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
49 |
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
|
50 |
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
|
51 |
} |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
52 |
|
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
53 |
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
|
54 |
return current | bits; |
50113 | 55 |
} |
56 |
||
57617
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
57 |
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
|
58 |
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
|
59 |
} |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
60 |
|
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
61 |
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
|
62 |
inline void set_bits_cas_form(jbyte bits, jbyte* const dest) { |
50113 | 63 |
assert(dest != NULL, "invariant"); |
64 |
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
|
65 |
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
|
66 |
const jbyte new_value = op(current, bits); |
50113 | 67 |
if (Atomic::cmpxchg(new_value, dest, current) == current) { |
68 |
return; |
|
69 |
} |
|
70 |
} while (true); |
|
71 |
} |
|
72 |
||
57617
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
73 |
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
|
74 |
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
|
75 |
} |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
76 |
|
50113 | 77 |
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
|
78 |
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
|
79 |
} |
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
80 |
|
5f3b05a36d61
8227605: Kitchensink fails "assert((((klass)->trace_id() & (JfrTraceIdEpoch::leakp_in_use_this_epoch_bit())) != 0)) failed: invariant"
mgronlun
parents:
53244
diff
changeset
|
81 |
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
|
82 |
set_bits_cas_form<traceid_and>(mask, dest); |
50113 | 83 |
} |
84 |
||
85 |
inline void set_traceid_bits(jbyte bits, traceid* dest) { |
|
86 |
set_bits(bits, ((jbyte*)dest) + low_offset); |
|
87 |
} |
|
88 |
||
89 |
inline void set_traceid_bits_cas(jbyte bits, traceid* dest) { |
|
90 |
set_bits_cas(bits, ((jbyte*)dest) + low_offset); |
|
91 |
} |
|
92 |
||
93 |
inline void set_traceid_mask(jbyte mask, traceid* dest) { |
|
94 |
set_mask(mask, ((jbyte*)dest) + low_offset); |
|
95 |
} |
|
96 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
97 |
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
|
98 |
assert(dest != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
99 |
*dest |= bits; |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
100 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
101 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
102 |
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
|
103 |
set_meta_bits(bits, ((jbyte*)dest) + meta_offset); |
50113 | 104 |
} |
105 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
106 |
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
|
107 |
assert(dest != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
108 |
*dest &= mask; |
50113 | 109 |
} |
110 |
||
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
111 |
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
|
112 |
set_meta_mask(mask, ((jbyte*)dest) + meta_offset); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
113 |
} |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
114 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
115 |
// 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
|
116 |
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
|
117 |
assert(dest != NULL, "invariant"); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
57617
diff
changeset
|
118 |
*dest ^= bits; |
50113 | 119 |
} |
120 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50429
diff
changeset
|
121 |
#endif // SHARE_JFR_RECORDER_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDBITS_INLINE_HPP |