45 }
46
47 inline jbyte traceid_and(jbyte current, jbyte bits) {
48 return current & bits;
49 }
50
51 inline jbyte traceid_or(jbyte current, jbyte bits) {
52 return current | bits;
53 }
54
55 inline jbyte traceid_xor(jbyte current, jbyte bits) {
56 return current ^ bits;
57 }
58
59 template <jbyte op(jbyte, jbyte)>
60 inline void set_bits_cas_form(jbyte bits, jbyte* const dest) {
61 assert(dest != NULL, "invariant");
62 do {
63 const jbyte current = *dest;
64 const jbyte new_value = op(current, bits);
65 if (Atomic::cmpxchg(new_value, dest, current) == current) {
66 return;
67 }
68 } while (true);
69 }
70
71 inline void set_bits_cas(jbyte bits, jbyte* const dest) {
72 set_bits_cas_form<traceid_or>(bits, dest);
73 }
74
75 inline void clear_bits_cas(jbyte bits, jbyte* const dest) {
76 set_bits_cas_form<traceid_xor>(bits, dest);
77 }
78
79 inline void set_mask(jbyte mask, jbyte* const dest) {
80 set_bits_cas_form<traceid_and>(mask, dest);
81 }
82
83 inline void set_traceid_bits(jbyte bits, traceid* dest) {
84 set_bits(bits, ((jbyte*)dest) + low_offset);
85 }
|
45 }
46
47 inline jbyte traceid_and(jbyte current, jbyte bits) {
48 return current & bits;
49 }
50
51 inline jbyte traceid_or(jbyte current, jbyte bits) {
52 return current | bits;
53 }
54
55 inline jbyte traceid_xor(jbyte current, jbyte bits) {
56 return current ^ bits;
57 }
58
59 template <jbyte op(jbyte, jbyte)>
60 inline void set_bits_cas_form(jbyte bits, jbyte* const dest) {
61 assert(dest != NULL, "invariant");
62 do {
63 const jbyte current = *dest;
64 const jbyte new_value = op(current, bits);
65 if (Atomic::cmpxchg(dest, current, new_value) == current) {
66 return;
67 }
68 } while (true);
69 }
70
71 inline void set_bits_cas(jbyte bits, jbyte* const dest) {
72 set_bits_cas_form<traceid_or>(bits, dest);
73 }
74
75 inline void clear_bits_cas(jbyte bits, jbyte* const dest) {
76 set_bits_cas_form<traceid_xor>(bits, dest);
77 }
78
79 inline void set_mask(jbyte mask, jbyte* const dest) {
80 set_bits_cas_form<traceid_and>(mask, dest);
81 }
82
83 inline void set_traceid_bits(jbyte bits, traceid* dest) {
84 set_bits(bits, ((jbyte*)dest) + low_offset);
85 }
|