Added: branches/safari-603-branch/JSTests/stress/atomics-add-uint32.js (0 => 211184)
--- branches/safari-603-branch/JSTests/stress/atomics-add-uint32.js (rev 0)
+++ branches/safari-603-branch/JSTests/stress/atomics-add-uint32.js 2017-01-26 01:40:48 UTC (rev 211184)
@@ -0,0 +1,13 @@
+var sab = new SharedArrayBuffer(4);
+var a = new Uint32Array(sab);
+var result = Atomics.add(a, 0, 4000000000);
+if (result != 0)
+ throw new Error("bad result: " + result);
+if (a[0] != 4000000000)
+ throw new Error("bad value read back: " + a[0]);
+result = Atomics.sub(a, 0, 4000000000);
+if (result != 4000000000)
+ throw new Error("bad result: " + result);
+if (a[0] != 0)
+ throw new Error("bad value read back: " + a[0]);
+
Modified: branches/safari-603-branch/JSTests/stress/atomics-store-return.js (211183 => 211184)
--- branches/safari-603-branch/JSTests/stress/atomics-store-return.js 2017-01-26 01:40:45 UTC (rev 211183)
+++ branches/safari-603-branch/JSTests/stress/atomics-store-return.js 2017-01-26 01:40:48 UTC (rev 211184)
@@ -2,10 +2,25 @@
var a = new Int8Array(sab);
var result = Atomics.store(a, 0, 1000);
if (result != 1000)
- throw "Error: bad result: " + result;
+ throw new Error("bad result: " + result);
sab = new SharedArrayBuffer(4);
a = new Uint32Array(sab);
-var result = Atomics.store(a, 0, 4000000000);
+result = Atomics.store(a, 0, 4000000000);
if (result != 4000000000)
- throw "Error: bad result: " + result;
+ throw new Error("bad result: " + result);
+if (a[0] != 4000000000)
+ throw new Error("bad value read back: " + a[0]);
+result = Atomics.store(a, 0, -4000000000);
+if (result != -4000000000)
+ throw new Error("bad result: " + result);
+if (a[0] != 294967296)
+ throw new Error("bad value read back: " + a[0]);
+
+var count = 0;
+result = Atomics.store(a, 0, { valueOf() { count++; return 42; } });
+if (result != 42)
+ throw new Error("bad result: " + result);
+if (count != 1)
+ throw new Error("bad count: " + count);
+
Modified: branches/safari-603-branch/Source/_javascript_Core/runtime/AtomicsObject.cpp (211183 => 211184)
--- branches/safari-603-branch/Source/_javascript_Core/runtime/AtomicsObject.cpp 2017-01-26 01:40:45 UTC (rev 211183)
+++ branches/safari-603-branch/Source/_javascript_Core/runtime/AtomicsObject.cpp 2017-01-26 01:40:48 UTC (rev 211184)
@@ -92,9 +92,9 @@
{
JSGenericTypedArrayView<Adaptor>* typedArray = jsCast<JSGenericTypedArrayView<Adaptor>*>(typedArrayView);
- int32_t extraArgs[numExtraArgs + 1]; // Add 1 to avoid 0 size array error in VS.
+ double extraArgs[numExtraArgs + 1]; // Add 1 to avoid 0 size array error in VS.
for (unsigned i = 0; i < numExtraArgs; ++i) {
- int32_t value = exec->argument(2 + i).toInt32(exec);
+ double value = exec->argument(2 + i).toInteger(exec);
RETURN_IF_EXCEPTION(scope, JSValue::encode(jsUndefined()));
extraArgs[i] = value;
}
@@ -191,8 +191,8 @@
EncodedJSValue JSC_HOST_CALL atomicsFuncAdd(ExecState* exec)
{
return atomicOperationWithArgs<1>(
- exec, [&] (auto* ptr, const int32_t* args) {
- return jsNumber(WTF::atomicExchangeAdd(ptr, args[0]));
+ exec, [&] (auto* ptr, const double* args) {
+ return jsNumber(WTF::atomicExchangeAdd(ptr, toInt32(args[0])));
});
}
@@ -199,8 +199,8 @@
EncodedJSValue JSC_HOST_CALL atomicsFuncAnd(ExecState* exec)
{
return atomicOperationWithArgs<1>(
- exec, [&] (auto* ptr, const int32_t* args) {
- return jsNumber(WTF::atomicExchangeAnd(ptr, args[0]));
+ exec, [&] (auto* ptr, const double* args) {
+ return jsNumber(WTF::atomicExchangeAnd(ptr, toInt32(args[0])));
});
}
@@ -207,7 +207,7 @@
EncodedJSValue JSC_HOST_CALL atomicsFuncCompareExchange(ExecState* exec)
{
return atomicOperationWithArgs<2>(
- exec, [&] (auto* ptr, const int32_t* args) {
+ exec, [&] (auto* ptr, const double* args) {
typedef typename std::remove_pointer<decltype(ptr)>::type T;
T expected = static_cast<T>(args[0]);
T newValue = static_cast<T>(args[1]);
@@ -218,7 +218,7 @@
EncodedJSValue JSC_HOST_CALL atomicsFuncExchange(ExecState* exec)
{
return atomicOperationWithArgs<1>(
- exec, [&] (auto* ptr, const int32_t* args) {
+ exec, [&] (auto* ptr, const double* args) {
typedef typename std::remove_pointer<decltype(ptr)>::type T;
return jsNumber(WTF::atomicExchange(ptr, static_cast<T>(args[0])));
});
@@ -249,7 +249,7 @@
EncodedJSValue JSC_HOST_CALL atomicsFuncLoad(ExecState* exec)
{
return atomicOperationWithArgs<0>(
- exec, [&] (auto* ptr, const int32_t*) {
+ exec, [&] (auto* ptr, const double*) {
return jsNumber(WTF::atomicLoad(ptr));
});
}
@@ -257,8 +257,8 @@
EncodedJSValue JSC_HOST_CALL atomicsFuncOr(ExecState* exec)
{
return atomicOperationWithArgs<1>(
- exec, [&] (auto* ptr, const int32_t* args) {
- return jsNumber(WTF::atomicExchangeOr(ptr, args[0]));
+ exec, [&] (auto* ptr, const double* args) {
+ return jsNumber(WTF::atomicExchangeOr(ptr, toInt32(args[0])));
});
}
@@ -265,14 +265,11 @@
EncodedJSValue JSC_HOST_CALL atomicsFuncStore(ExecState* exec)
{
return atomicOperationWithArgs<1>(
- exec, [&] (auto* ptr, const int32_t* args) {
+ exec, [&] (auto* ptr, const double* args) {
typedef typename std::remove_pointer<decltype(ptr)>::type T;
- int32_t valueAsInt = args[0];
+ double valueAsInt = args[0];
T valueAsT = static_cast<T>(valueAsInt);
WTF::atomicStore(ptr, valueAsT);
-
- if (static_cast<int32_t>(valueAsT) == valueAsInt)
- return jsNumber(valueAsT);
return jsNumber(valueAsInt);
});
}
@@ -280,8 +277,8 @@
EncodedJSValue JSC_HOST_CALL atomicsFuncSub(ExecState* exec)
{
return atomicOperationWithArgs<1>(
- exec, [&] (auto* ptr, const int32_t* args) {
- return jsNumber(WTF::atomicExchangeSub(ptr, args[0]));
+ exec, [&] (auto* ptr, const double* args) {
+ return jsNumber(WTF::atomicExchangeSub(ptr, toInt32(args[0])));
});
}
@@ -390,8 +387,8 @@
EncodedJSValue JSC_HOST_CALL atomicsFuncXor(ExecState* exec)
{
return atomicOperationWithArgs<1>(
- exec, [&] (auto* ptr, const int32_t* args) {
- return jsNumber(WTF::atomicExchangeXor(ptr, args[0]));
+ exec, [&] (auto* ptr, const double* args) {
+ return jsNumber(WTF::atomicExchangeXor(ptr, toInt32(args[0])));
});
}