author | egahlin |
Fri, 17 May 2019 16:02:27 +0200 | |
branch | JEP-349-branch |
changeset 57360 | 5d043a159d5c |
parent 53244 | 9807daeb47c4 |
child 57870 | 00860d9caf4d |
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" |
|
50429
83aec1d357d4
8204301: Make OrderAccess functions available to hpp rather than inline.hpp files
coleenp
parents:
50113
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; |
|
35 |
static const int leakp_offset = low_offset + 1; |
|
36 |
#else |
|
37 |
static const int low_offset = 7; |
|
38 |
static const int leakp_offset = low_offset - 1; |
|
39 |
#endif |
|
40 |
||
41 |
inline void set_bits(jbyte bits, jbyte* const dest) { |
|
42 |
assert(dest != NULL, "invariant"); |
|
57360 | 43 |
const jbyte current = *dest; |
50113 | 44 |
if (bits != (current & bits)) { |
57360 | 45 |
*dest = current | bits; |
50113 | 46 |
|
57360 | 47 |
OrderAccess::storestore(); |
50113 | 48 |
} |
49 |
} |
|
50 |
||
51 |
inline void set_bits_cas(jbyte bits, jbyte* const dest) { |
|
52 |
assert(dest != NULL, "invariant"); |
|
53 |
do { |
|
54 |
const jbyte current = OrderAccess::load_acquire(dest); |
|
55 |
if (bits == (current & bits)) { |
|
56 |
return; |
|
57 |
} |
|
58 |
const jbyte new_value = current | bits; |
|
59 |
if (Atomic::cmpxchg(new_value, dest, current) == current) { |
|
60 |
return; |
|
61 |
} |
|
62 |
} while (true); |
|
63 |
} |
|
64 |
||
65 |
inline void clear_bits_cas(jbyte bits, jbyte* const dest) { |
|
66 |
assert(dest != NULL, "invariant"); |
|
67 |
do { |
|
68 |
const jbyte current = OrderAccess::load_acquire(dest); |
|
69 |
if (bits != (current & bits)) { |
|
70 |
return; |
|
71 |
} |
|
72 |
const jbyte new_value = current ^ bits; |
|
73 |
if (Atomic::cmpxchg(new_value, dest, current) == current) { |
|
74 |
return; |
|
75 |
} |
|
76 |
} while (true); |
|
77 |
} |
|
78 |
||
57360 | 79 |
inline void set_mask(jbyte mask, jbyte* const dest) { |
80 |
assert(dest != NULL, "invariant"); |
|
81 |
const jbyte current = *dest; |
|
82 |
if (mask != (current & mask)) { |
|
83 |
*dest = current & mask; |
|
84 |
OrderAccess::storestore(); |
|
85 |
} |
|
86 |
} |
|
87 |
inline void set_mask_cas(jbyte mask, jbyte* const dest) { |
|
88 |
assert(dest != NULL, "invariant"); |
|
89 |
do { |
|
90 |
const jbyte current = OrderAccess::load_acquire(dest); |
|
91 |
if (mask == (current & mask)) { |
|
92 |
return; |
|
93 |
} |
|
94 |
const jbyte new_value = current & mask; |
|
95 |
if (Atomic::cmpxchg(new_value, dest, current) == current) { |
|
96 |
return; |
|
97 |
} |
|
98 |
} while (true); |
|
99 |
} |
|
50113 | 100 |
inline void set_traceid_bits(jbyte bits, traceid* dest) { |
101 |
set_bits(bits, ((jbyte*)dest) + low_offset); |
|
102 |
} |
|
103 |
||
104 |
inline void set_traceid_bits_cas(jbyte bits, traceid* dest) { |
|
105 |
set_bits_cas(bits, ((jbyte*)dest) + low_offset); |
|
106 |
} |
|
107 |
||
108 |
inline void set_traceid_mask(jbyte mask, traceid* dest) { |
|
109 |
set_mask(mask, ((jbyte*)dest) + low_offset); |
|
110 |
} |
|
111 |
||
112 |
inline void set_leakp_traceid_bits(jbyte bits, traceid* dest) { |
|
113 |
set_bits(bits, ((jbyte*)dest) + leakp_offset); |
|
114 |
} |
|
115 |
||
116 |
inline void set_leakp_traceid_bits_cas(jbyte bits, traceid* dest) { |
|
117 |
set_bits_cas(bits, ((jbyte*)dest) + leakp_offset); |
|
118 |
} |
|
119 |
||
120 |
inline void set_leakp_traceid_mask(jbyte mask, traceid* dest) { |
|
57360 | 121 |
set_mask_cas(mask, ((jbyte*)dest) + leakp_offset); |
50113 | 122 |
} |
123 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50429
diff
changeset
|
124 |
#endif // SHARE_JFR_RECORDER_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDBITS_INLINE_HPP |