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

Unified Diff: src/builtins/builtins-sharedarraybuffer.cc

Issue 2698813004: [SAB] Move Atomics builtins to C++ (Closed)
Patch Set: [SAB] Remove unreachable Uint8Clamped atomics paths Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/builtins-sharedarraybuffer.cc
diff --git a/src/builtins/builtins-sharedarraybuffer.cc b/src/builtins/builtins-sharedarraybuffer.cc
index 7ee144901e1a074818704e50886065439ee1234f..85d08bbcee1c4e6be013bcdbaa31abbe964b000c 100644
--- a/src/builtins/builtins-sharedarraybuffer.cc
+++ b/src/builtins/builtins-sharedarraybuffer.cc
@@ -638,61 +638,6 @@ inline Object* DoExchange(Isolate* isolate, void* buffer, size_t index,
return ToObject(isolate, result);
}
-// Uint8Clamped functions
-
-uint8_t ClampToUint8(int32_t value) {
- if (value < 0) return 0;
- if (value > 255) return 255;
- return value;
-}
-
-inline Object* DoCompareExchangeUint8Clamped(Isolate* isolate, void* buffer,
- size_t index,
- Handle<Object> oldobj,
- Handle<Object> newobj) {
- typedef int32_t convert_type;
- uint8_t oldval = ClampToUint8(FromObject<convert_type>(oldobj));
- uint8_t newval = ClampToUint8(FromObject<convert_type>(newobj));
- uint8_t result = CompareExchangeSeqCst(static_cast<uint8_t*>(buffer) + index,
- oldval, newval);
- return ToObject(isolate, result);
-}
-
-#define DO_UINT8_CLAMPED_OP(name, op) \
- inline Object* Do##name##Uint8Clamped(Isolate* isolate, void* buffer, \
- size_t index, Handle<Object> obj) { \
- typedef int32_t convert_type; \
- uint8_t* p = static_cast<uint8_t*>(buffer) + index; \
- convert_type operand = FromObject<convert_type>(obj); \
- uint8_t expected; \
- uint8_t result; \
- do { \
- expected = *p; \
- result = ClampToUint8(static_cast<convert_type>(expected) op operand); \
- } while (CompareExchangeSeqCst(p, expected, result) != expected); \
- return ToObject(isolate, expected); \
- }
-
-DO_UINT8_CLAMPED_OP(Add, +)
-DO_UINT8_CLAMPED_OP(Sub, -)
-DO_UINT8_CLAMPED_OP(And, &)
-DO_UINT8_CLAMPED_OP(Or, |)
-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
@@ -741,8 +686,7 @@ BUILTIN(AtomicsCompareExchange) {
#undef TYPED_ARRAY_CASE
case kExternalUint8ClampedArray:
- return DoCompareExchangeUint8Clamped(isolate, source, i, expectedValue,
- replacementValue);
+ UNREACHABLE();
default:
break;
@@ -783,7 +727,7 @@ BUILTIN(AtomicsAdd) {
#undef TYPED_ARRAY_CASE
case kExternalUint8ClampedArray:
- return DoAddUint8Clamped(isolate, source, i, value);
+ UNREACHABLE();
default:
break;
@@ -824,7 +768,7 @@ BUILTIN(AtomicsSub) {
#undef TYPED_ARRAY_CASE
case kExternalUint8ClampedArray:
- return DoSubUint8Clamped(isolate, source, i, value);
+ UNREACHABLE();
default:
break;
@@ -865,7 +809,7 @@ BUILTIN(AtomicsAnd) {
#undef TYPED_ARRAY_CASE
case kExternalUint8ClampedArray:
- return DoAndUint8Clamped(isolate, source, i, value);
+ UNREACHABLE();
default:
break;
@@ -906,7 +850,7 @@ BUILTIN(AtomicsOr) {
#undef TYPED_ARRAY_CASE
case kExternalUint8ClampedArray:
- return DoOrUint8Clamped(isolate, source, i, value);
+ UNREACHABLE();
default:
break;
@@ -947,7 +891,7 @@ BUILTIN(AtomicsXor) {
#undef TYPED_ARRAY_CASE
case kExternalUint8ClampedArray:
- return DoXorUint8Clamped(isolate, source, i, value);
+ UNREACHABLE();
default:
break;
@@ -988,7 +932,7 @@ BUILTIN(AtomicsExchange) {
#undef TYPED_ARRAY_CASE
case kExternalUint8ClampedArray:
- return DoExchangeUint8Clamped(isolate, source, i, value);
+ UNREACHABLE();
default:
break;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698