Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Unified Diff: src/runtime/runtime-atomics.cc

Issue 2623633003: [Atomics] Make Atomics.exchange a builtin using TF (Closed)
Patch Set: [Atomics] Make Atomics.exchange a builtin using TF Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/runtime/runtime-atomics.cc
diff --git a/src/runtime/runtime-atomics.cc b/src/runtime/runtime-atomics.cc
index ff7ded9b090e365dced25ce8a3a6ce6f6ba4f0cb..4cc5b6f1f08f65016105565d23ab87c3335b11bd 100644
--- a/src/runtime/runtime-atomics.cc
+++ b/src/runtime/runtime-atomics.cc
@@ -57,15 +57,9 @@ inline T XorSeqCst(T* p, T value) {
return __atomic_fetch_xor(p, value, __ATOMIC_SEQ_CST);
}
-template <typename T>
-inline T ExchangeSeqCst(T* p, T value) {
- return __atomic_exchange_n(p, value, __ATOMIC_SEQ_CST);
-}
-
#elif V8_CC_MSVC
#define InterlockedCompareExchange32 _InterlockedCompareExchange
-#define InterlockedExchange32 _InterlockedExchange
#define InterlockedExchangeAdd32 _InterlockedExchangeAdd
#define InterlockedAnd32 _InterlockedAnd
#define InterlockedOr32 _InterlockedOr
@@ -95,10 +89,6 @@ inline T ExchangeSeqCst(T* p, T value) {
return InterlockedXor##suffix(reinterpret_cast<vctype*>(p), \
bit_cast<vctype>(value)); \
} \
- inline type ExchangeSeqCst(type* p, type value) { \
- return InterlockedExchange##suffix(reinterpret_cast<vctype*>(p), \
- bit_cast<vctype>(value)); \
- } \
\
inline type CompareExchangeSeqCst(type* p, type oldval, type newval) { \
return InterlockedCompareExchange##suffix(reinterpret_cast<vctype*>(p), \
@@ -117,7 +107,6 @@ ATOMIC_OPS(uint32_t, 32, long) /* NOLINT(runtime/int) */
#undef ATOMIC_OPS
#undef InterlockedCompareExchange32
-#undef InterlockedExchange32
#undef InterlockedExchangeAdd32
#undef InterlockedAnd32
#undef InterlockedOr32
@@ -243,15 +232,6 @@ inline Object* DoXor(Isolate* isolate, void* buffer, size_t index,
}
-template <typename T>
-inline Object* DoExchange(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);
-}
-
-
// Uint8Clamped functions
uint8_t ClampToUint8(int32_t value) {
@@ -298,19 +278,6 @@ DO_UINT8_CLAMPED_OP(Xor, ^)
#undef DO_UINT8_CLAMPED_OP
-inline Object* DoExchangeUint8Clamped(Isolate* isolate, void* buffer,
- size_t index, Handle<Object> obj) {
- typedef int32_t convert_type;
- uint8_t* p = static_cast<uint8_t*>(buffer) + index;
- uint8_t result = ClampToUint8(FromObject<convert_type>(obj));
- uint8_t expected;
- do {
- expected = *p;
- } while (CompareExchangeSeqCst(p, expected, result) != expected);
- return ToObject(isolate, expected);
-}
-
-
} // anonymous namespace
// Duplicated from objects.h
@@ -541,38 +508,6 @@ RUNTIME_FUNCTION(Runtime_AtomicsXor) {
}
-RUNTIME_FUNCTION(Runtime_AtomicsExchange) {
- HandleScope scope(isolate);
- DCHECK_EQ(3, args.length());
- CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0);
- CONVERT_SIZE_ARG_CHECKED(index, 1);
- CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2);
- CHECK(sta->GetBuffer()->is_shared());
- CHECK_LT(index, NumberToSize(sta->length()));
-
- uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
- NumberToSize(sta->byte_offset());
-
- switch (sta->type()) {
-#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
- case kExternal##Type##Array: \
- return DoExchange<ctype>(isolate, source, index, value);
-
- INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE)
-#undef TYPED_ARRAY_CASE
-
- case kExternalUint8ClampedArray:
- return DoExchangeUint8Clamped(isolate, source, index, value);
-
- default:
- break;
- }
-
- UNREACHABLE();
- return isolate->heap()->undefined_value();
-}
-
-
RUNTIME_FUNCTION(Runtime_AtomicsIsLockFree) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());

Powered by Google App Engine
This is Rietveld 408576698