Mercurial > hg > truffle
comparison src/share/vm/runtime/atomic.cpp @ 11198:1e6d5dec4a4e
Merge.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 05 Aug 2013 13:20:06 +0200 |
parents | d9eed26d638a |
children | de6a9e811145 bdd155477289 |
comparison
equal
deleted
inserted
replaced
11197:3479ab380552 | 11198:1e6d5dec4a4e |
---|---|
78 old = load(dest); | 78 old = load(dest); |
79 new_value = old + add_value; | 79 new_value = old + add_value; |
80 } | 80 } |
81 return old; | 81 return old; |
82 } | 82 } |
83 | |
84 void Atomic::inc(volatile short* dest) { | |
85 // Most platforms do not support atomic increment on a 2-byte value. However, | |
86 // if the value occupies the most significant 16 bits of an aligned 32-bit | |
87 // word, then we can do this with an atomic add of 0x10000 to the 32-bit word. | |
88 // | |
89 // The least significant parts of this 32-bit word will never be affected, even | |
90 // in case of overflow/underflow. | |
91 // | |
92 // Use the ATOMIC_SHORT_PAIR macro to get the desired alignment. | |
93 #ifdef VM_LITTLE_ENDIAN | |
94 assert((intx(dest) & 0x03) == 0x02, "wrong alignment"); | |
95 (void)Atomic::add(0x10000, (volatile int*)(dest-1)); | |
96 #else | |
97 assert((intx(dest) & 0x03) == 0x00, "wrong alignment"); | |
98 (void)Atomic::add(0x10000, (volatile int*)(dest)); | |
99 #endif | |
100 } | |
101 | |
102 void Atomic::dec(volatile short* dest) { | |
103 #ifdef VM_LITTLE_ENDIAN | |
104 assert((intx(dest) & 0x03) == 0x02, "wrong alignment"); | |
105 (void)Atomic::add(-0x10000, (volatile int*)(dest-1)); | |
106 #else | |
107 assert((intx(dest) & 0x03) == 0x00, "wrong alignment"); | |
108 (void)Atomic::add(-0x10000, (volatile int*)(dest)); | |
109 #endif | |
110 } | |
111 |