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

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

Issue 1422533009: Support SAB atomics for offset-TypedArray (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add a test case Created 5 years, 1 month 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 | test/mjsunit/asm/atomics-add.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-atomics.cc
diff --git a/src/runtime/runtime-atomics.cc b/src/runtime/runtime-atomics.cc
index 636371c134334eaad5736afc6316d778d562cc36..ba869148b8fbfd11e16b05de452b34bbcae638ea 100644
--- a/src/runtime/runtime-atomics.cc
+++ b/src/runtime/runtime-atomics.cc
@@ -444,18 +444,19 @@ RUNTIME_FUNCTION(Runtime_AtomicsCompareExchange) {
RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
- void* buffer = sta->GetBuffer()->backing_store();
+ uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
+ NumberToSize(isolate, sta->byte_offset());
switch (sta->type()) {
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
case kExternal##Type##Array: \
- return DoCompareExchange<ctype>(isolate, buffer, index, oldobj, newobj);
+ return DoCompareExchange<ctype>(isolate, source, index, oldobj, newobj);
INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
case kExternalUint8ClampedArray:
- return DoCompareExchangeUint8Clamped(isolate, buffer, index, oldobj,
+ return DoCompareExchangeUint8Clamped(isolate, source, index, oldobj,
newobj);
default:
@@ -475,18 +476,19 @@ RUNTIME_FUNCTION(Runtime_AtomicsLoad) {
RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
- void* buffer = sta->GetBuffer()->backing_store();
+ uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
+ NumberToSize(isolate, sta->byte_offset());
switch (sta->type()) {
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
case kExternal##Type##Array: \
- return DoLoad<ctype>(isolate, buffer, index);
+ return DoLoad<ctype>(isolate, source, index);
INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
case kExternalUint8ClampedArray:
- return DoLoad<uint8_t>(isolate, buffer, index);
+ return DoLoad<uint8_t>(isolate, source, index);
default:
break;
@@ -506,18 +508,19 @@ RUNTIME_FUNCTION(Runtime_AtomicsStore) {
RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
- void* buffer = sta->GetBuffer()->backing_store();
+ uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
+ NumberToSize(isolate, sta->byte_offset());
switch (sta->type()) {
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
case kExternal##Type##Array: \
- return DoStore<ctype>(isolate, buffer, index, value);
+ return DoStore<ctype>(isolate, source, index, value);
INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
case kExternalUint8ClampedArray:
- return DoStoreUint8Clamped(isolate, buffer, index, value);
+ return DoStoreUint8Clamped(isolate, source, index, value);
default:
break;
@@ -537,18 +540,19 @@ RUNTIME_FUNCTION(Runtime_AtomicsAdd) {
RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
- void* buffer = sta->GetBuffer()->backing_store();
+ uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
+ NumberToSize(isolate, sta->byte_offset());
switch (sta->type()) {
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
case kExternal##Type##Array: \
- return DoAdd<ctype>(isolate, buffer, index, value);
+ return DoAdd<ctype>(isolate, source, index, value);
INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
case kExternalUint8ClampedArray:
- return DoAddUint8Clamped(isolate, buffer, index, value);
+ return DoAddUint8Clamped(isolate, source, index, value);
default:
break;
@@ -568,18 +572,19 @@ RUNTIME_FUNCTION(Runtime_AtomicsSub) {
RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
- void* buffer = sta->GetBuffer()->backing_store();
+ uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
+ NumberToSize(isolate, sta->byte_offset());
switch (sta->type()) {
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
case kExternal##Type##Array: \
- return DoSub<ctype>(isolate, buffer, index, value);
+ return DoSub<ctype>(isolate, source, index, value);
INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
case kExternalUint8ClampedArray:
- return DoSubUint8Clamped(isolate, buffer, index, value);
+ return DoSubUint8Clamped(isolate, source, index, value);
default:
break;
@@ -599,18 +604,19 @@ RUNTIME_FUNCTION(Runtime_AtomicsAnd) {
RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
- void* buffer = sta->GetBuffer()->backing_store();
+ uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
+ NumberToSize(isolate, sta->byte_offset());
switch (sta->type()) {
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
case kExternal##Type##Array: \
- return DoAnd<ctype>(isolate, buffer, index, value);
+ return DoAnd<ctype>(isolate, source, index, value);
INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
case kExternalUint8ClampedArray:
- return DoAndUint8Clamped(isolate, buffer, index, value);
+ return DoAndUint8Clamped(isolate, source, index, value);
default:
break;
@@ -630,18 +636,19 @@ RUNTIME_FUNCTION(Runtime_AtomicsOr) {
RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
- void* buffer = sta->GetBuffer()->backing_store();
+ uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
+ NumberToSize(isolate, sta->byte_offset());
switch (sta->type()) {
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
case kExternal##Type##Array: \
- return DoOr<ctype>(isolate, buffer, index, value);
+ return DoOr<ctype>(isolate, source, index, value);
INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
case kExternalUint8ClampedArray:
- return DoOrUint8Clamped(isolate, buffer, index, value);
+ return DoOrUint8Clamped(isolate, source, index, value);
default:
break;
@@ -661,18 +668,19 @@ RUNTIME_FUNCTION(Runtime_AtomicsXor) {
RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
- void* buffer = sta->GetBuffer()->backing_store();
+ uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
+ NumberToSize(isolate, sta->byte_offset());
switch (sta->type()) {
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
case kExternal##Type##Array: \
- return DoXor<ctype>(isolate, buffer, index, value);
+ return DoXor<ctype>(isolate, source, index, value);
INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
case kExternalUint8ClampedArray:
- return DoXorUint8Clamped(isolate, buffer, index, value);
+ return DoXorUint8Clamped(isolate, source, index, value);
default:
break;
@@ -692,18 +700,19 @@ RUNTIME_FUNCTION(Runtime_AtomicsExchange) {
RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
- void* buffer = sta->GetBuffer()->backing_store();
+ uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
+ NumberToSize(isolate, sta->byte_offset());
switch (sta->type()) {
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
case kExternal##Type##Array: \
- return DoExchange<ctype>(isolate, buffer, index, value);
+ return DoExchange<ctype>(isolate, source, index, value);
INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
case kExternalUint8ClampedArray:
- return DoExchangeUint8Clamped(isolate, buffer, index, value);
+ return DoExchangeUint8Clamped(isolate, source, index, value);
default:
break;
« no previous file with comments | « no previous file | test/mjsunit/asm/atomics-add.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698