diff options
Diffstat (limited to 'deps/v8/src/runtime/runtime-atomics.cc')
-rw-r--r-- | deps/v8/src/runtime/runtime-atomics.cc | 71 |
1 files changed, 39 insertions, 32 deletions
diff --git a/deps/v8/src/runtime/runtime-atomics.cc b/deps/v8/src/runtime/runtime-atomics.cc index 3fd07af255..3fcb9934f9 100644 --- a/deps/v8/src/runtime/runtime-atomics.cc +++ b/deps/v8/src/runtime/runtime-atomics.cc @@ -6,6 +6,7 @@ #include "src/base/macros.h" #include "src/base/platform/mutex.h" #include "src/conversions-inl.h" +#include "src/counters.h" #include "src/heap/factory.h" #include "src/objects/js-array-buffer-inl.h" #include "src/runtime/runtime-utils.h" @@ -97,6 +98,10 @@ inline T XorSeqCst(T* p, T value) { #define InterlockedOr32 _InterlockedOr #define InterlockedXor32 _InterlockedXor +#if defined(V8_HOST_ARCH_ARM64) +#define InterlockedExchange8 _InterlockedExchange8 +#endif + #define ATOMIC_OPS(type, suffix, vctype) \ inline type ExchangeSeqCst(type* p, type value) { \ return InterlockedExchange##suffix(reinterpret_cast<vctype*>(p), \ @@ -160,6 +165,10 @@ inline void StoreSeqCst(T* p, T value) { #undef InterlockedOr32 #undef InterlockedXor32 +#if defined(V8_HOST_ARCH_ARM64) +#undef InterlockedExchange8 +#endif + #else #error Unsupported platform! @@ -209,35 +218,33 @@ inline int64_t FromObject<int64_t>(Handle<Object> bigint) { return Handle<BigInt>::cast(bigint)->AsInt64(); } -inline Object* ToObject(Isolate* isolate, int8_t t) { return Smi::FromInt(t); } +inline Object ToObject(Isolate* isolate, int8_t t) { return Smi::FromInt(t); } -inline Object* ToObject(Isolate* isolate, uint8_t t) { return Smi::FromInt(t); } +inline Object ToObject(Isolate* isolate, uint8_t t) { return Smi::FromInt(t); } -inline Object* ToObject(Isolate* isolate, int16_t t) { return Smi::FromInt(t); } +inline Object ToObject(Isolate* isolate, int16_t t) { return Smi::FromInt(t); } -inline Object* ToObject(Isolate* isolate, uint16_t t) { - return Smi::FromInt(t); -} +inline Object ToObject(Isolate* isolate, uint16_t t) { return Smi::FromInt(t); } -inline Object* ToObject(Isolate* isolate, int32_t t) { +inline Object ToObject(Isolate* isolate, int32_t t) { return *isolate->factory()->NewNumber(t); } -inline Object* ToObject(Isolate* isolate, uint32_t t) { +inline Object ToObject(Isolate* isolate, uint32_t t) { return *isolate->factory()->NewNumber(t); } -inline Object* ToObject(Isolate* isolate, int64_t t) { +inline Object ToObject(Isolate* isolate, int64_t t) { return *BigInt::FromInt64(isolate, t); } -inline Object* ToObject(Isolate* isolate, uint64_t t) { +inline Object ToObject(Isolate* isolate, uint64_t t) { return *BigInt::FromUint64(isolate, t); } template <typename T> struct Load { - static inline Object* Do(Isolate* isolate, void* buffer, size_t index) { + static inline Object Do(Isolate* isolate, void* buffer, size_t index) { T result = LoadSeqCst(static_cast<T*>(buffer) + index); return ToObject(isolate, result); } @@ -254,8 +261,8 @@ struct Store { template <typename T> struct Exchange { - static inline Object* Do(Isolate* isolate, void* buffer, size_t index, - Handle<Object> obj) { + static inline Object Do(Isolate* isolate, void* buffer, size_t index, + Handle<Object> obj) { T value = FromObject<T>(obj); T result = ExchangeSeqCst(static_cast<T*>(buffer) + index, value); return ToObject(isolate, result); @@ -263,8 +270,8 @@ struct Exchange { }; template <typename T> -inline Object* DoCompareExchange(Isolate* isolate, void* buffer, size_t index, - Handle<Object> oldobj, Handle<Object> newobj) { +inline Object DoCompareExchange(Isolate* isolate, void* buffer, size_t index, + Handle<Object> oldobj, Handle<Object> newobj) { T oldval = FromObject<T>(oldobj); T newval = FromObject<T>(newobj); T result = @@ -274,8 +281,8 @@ inline Object* DoCompareExchange(Isolate* isolate, void* buffer, size_t index, template <typename T> struct Add { - static inline Object* Do(Isolate* isolate, void* buffer, size_t index, - Handle<Object> obj) { + static inline Object Do(Isolate* isolate, void* buffer, size_t index, + Handle<Object> obj) { T value = FromObject<T>(obj); T result = AddSeqCst(static_cast<T*>(buffer) + index, value); return ToObject(isolate, result); @@ -284,8 +291,8 @@ struct Add { template <typename T> struct Sub { - static inline Object* Do(Isolate* isolate, void* buffer, size_t index, - Handle<Object> obj) { + static inline Object Do(Isolate* isolate, void* buffer, size_t index, + Handle<Object> obj) { T value = FromObject<T>(obj); T result = SubSeqCst(static_cast<T*>(buffer) + index, value); return ToObject(isolate, result); @@ -294,8 +301,8 @@ struct Sub { template <typename T> struct And { - static inline Object* Do(Isolate* isolate, void* buffer, size_t index, - Handle<Object> obj) { + static inline Object Do(Isolate* isolate, void* buffer, size_t index, + Handle<Object> obj) { T value = FromObject<T>(obj); T result = AndSeqCst(static_cast<T*>(buffer) + index, value); return ToObject(isolate, result); @@ -304,8 +311,8 @@ struct And { template <typename T> struct Or { - static inline Object* Do(Isolate* isolate, void* buffer, size_t index, - Handle<Object> obj) { + static inline Object Do(Isolate* isolate, void* buffer, size_t index, + Handle<Object> obj) { T value = FromObject<T>(obj); T result = OrSeqCst(static_cast<T*>(buffer) + index, value); return ToObject(isolate, result); @@ -314,8 +321,8 @@ struct Or { template <typename T> struct Xor { - static inline Object* Do(Isolate* isolate, void* buffer, size_t index, - Handle<Object> obj) { + static inline Object Do(Isolate* isolate, void* buffer, size_t index, + Handle<Object> obj) { T value = FromObject<T>(obj); T result = XorSeqCst(static_cast<T*>(buffer) + index, value); return ToObject(isolate, result); @@ -338,7 +345,7 @@ struct Xor { // but also includes the ToInteger/ToBigInt conversion that's part of // https://tc39.github.io/ecma262/#sec-atomicreadmodifywrite template <template <typename> class Op> -Object* GetModifySetValueInBuffer(Arguments args, Isolate* isolate) { +Object GetModifySetValueInBuffer(Arguments args, Isolate* isolate) { HandleScope scope(isolate); DCHECK_EQ(3, args.length()); CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); @@ -353,7 +360,7 @@ Object* GetModifySetValueInBuffer(Arguments args, Isolate* isolate) { Handle<BigInt> bigint; ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, bigint, BigInt::FromObject(isolate, value_obj)); - // SharedArrayBuffers are not neuterable. + // SharedArrayBuffers are not detachable. CHECK_LT(index, NumberToSize(sta->length())); if (sta->type() == kExternalBigInt64Array) { return Op<int64_t>::Do(isolate, source, index, bigint); @@ -365,7 +372,7 @@ Object* GetModifySetValueInBuffer(Arguments args, Isolate* isolate) { Handle<Object> value; ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, Object::ToInteger(isolate, value_obj)); - // SharedArrayBuffers are not neuterable. + // SharedArrayBuffers are not detachable. CHECK_LT(index, NumberToSize(sta->length())); switch (sta->type()) { @@ -395,7 +402,7 @@ RUNTIME_FUNCTION(Runtime_AtomicsLoad64) { DCHECK(sta->type() == kExternalBigInt64Array || sta->type() == kExternalBigUint64Array); - // SharedArrayBuffers are not neuterable. + // SharedArrayBuffers are not detachable. CHECK_LT(index, NumberToSize(sta->length())); if (sta->type() == kExternalBigInt64Array) { return Load<int64_t>::Do(isolate, source, index); @@ -421,7 +428,7 @@ RUNTIME_FUNCTION(Runtime_AtomicsStore64) { DCHECK(sta->type() == kExternalBigInt64Array || sta->type() == kExternalBigUint64Array); - // SharedArrayBuffers are not neuterable. + // SharedArrayBuffers are not detachable. CHECK_LT(index, NumberToSize(sta->length())); if (sta->type() == kExternalBigInt64Array) { Store<int64_t>::Do(isolate, source, index, bigint); @@ -456,7 +463,7 @@ RUNTIME_FUNCTION(Runtime_AtomicsCompareExchange) { isolate, old_bigint, BigInt::FromObject(isolate, old_value_obj)); ASSIGN_RETURN_FAILURE_ON_EXCEPTION( isolate, new_bigint, BigInt::FromObject(isolate, new_value_obj)); - // SharedArrayBuffers are not neuterable. + // SharedArrayBuffers are not detachable. CHECK_LT(index, NumberToSize(sta->length())); if (sta->type() == kExternalBigInt64Array) { return DoCompareExchange<int64_t>(isolate, source, index, old_bigint, @@ -473,7 +480,7 @@ RUNTIME_FUNCTION(Runtime_AtomicsCompareExchange) { Object::ToInteger(isolate, old_value_obj)); ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, new_value, Object::ToInteger(isolate, new_value_obj)); - // SharedArrayBuffers are not neuterable. + // SharedArrayBuffers are not detachable. CHECK_LT(index, NumberToSize(sta->length())); switch (sta->type()) { |