33 using namespace v8::internal;
36 #define CHECK_EQU(v1, v2) \
37 CHECK_EQ(static_cast<int64_t>(v1), static_cast<int64_t>(v2))
39 #define NUM_BITS(T) (sizeof(T) * 8)
42 template <
class AtomicType>
43 static void TestAtomicIncrement() {
56 AtomicType prev_word_value, next_word_value;
57 memset(&prev_word_value, 0xFF,
sizeof(AtomicType));
58 memset(&next_word_value, 0xEE,
sizeof(AtomicType));
60 s.prev_word = prev_word_value;
62 s.next_word = next_word_value;
111 template <
class AtomicType>
112 static void TestCompareAndSwap() {
113 AtomicType value = 0;
120 const AtomicType k_test_val =
121 (
static_cast<AtomicType
>(1) << (
NUM_BITS(AtomicType) - 2)) + 11;
134 template <
class AtomicType>
135 static void TestAtomicExchange() {
136 AtomicType value = 0;
143 const AtomicType k_test_val =
144 (
static_cast<AtomicType
>(1) << (
NUM_BITS(AtomicType) - 2)) + 11;
157 template <
class AtomicType>
158 static void TestAtomicIncrementBounds() {
160 AtomicType test_val =
161 static_cast<AtomicType
>(1) << (
NUM_BITS(AtomicType) - 1);
162 AtomicType value = -1 ^ test_val;
171 test_val =
static_cast<AtomicType
>(1) << (
NUM_BITS(AtomicType) / 2);
172 value = test_val - 1;
183 template <
class AtomicType>
184 static AtomicType TestFillValue() {
186 memset(&val, 0xa5,
sizeof(AtomicType));
193 template <
class AtomicType>
194 static void TestStore() {
195 const AtomicType kVal1 = TestFillValue<AtomicType>();
196 const AtomicType kVal2 =
static_cast<AtomicType
>(-1);
219 template <
class AtomicType>
220 static void TestLoad() {
221 const AtomicType kVal1 = TestFillValue<AtomicType>();
222 const AtomicType kVal2 =
static_cast<AtomicType
>(-1);
244 TestAtomicIncrement<Atomic32>();
245 TestAtomicIncrement<AtomicWord>();
250 TestCompareAndSwap<Atomic32>();
251 TestCompareAndSwap<AtomicWord>();
256 TestAtomicExchange<Atomic32>();
257 TestAtomicExchange<AtomicWord>();
262 TestAtomicIncrementBounds<Atomic32>();
263 TestAtomicIncrementBounds<AtomicWord>();
268 TestStore<Atomic32>();
269 TestStore<AtomicWord>();
274 TestLoad<Atomic32>();
275 TestLoad<AtomicWord>();
void Acquire_Store(volatile Atomic32 *ptr, Atomic32 value)
Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32 *ptr, Atomic32 old_value, Atomic32 new_value)
#define CHECK_EQU(v1, v2)
void NoBarrier_Store(volatile Atomic32 *ptr, Atomic32 value)
Atomic32 NoBarrier_AtomicExchange(volatile Atomic32 *ptr, Atomic32 new_value)
Atomic32 Release_Load(volatile const Atomic32 *ptr)
Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32 *ptr, Atomic32 increment)
void Release_Store(volatile Atomic32 *ptr, Atomic32 value)
Atomic32 NoBarrier_Load(volatile const Atomic32 *ptr)
void Load(const v8::FunctionCallbackInfo< v8::Value > &args)
Atomic32 Acquire_Load(volatile const Atomic32 *ptr)