Changeset 211129 in webkit
- Timestamp:
- Jan 24, 2017, 6:52:51 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/atomics-add-uint32.js (added)
-
JSTests/stress/atomics-store-return.js (modified) (1 diff)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/runtime/AtomicsObject.cpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r211128 r211129 1 2017-01-24 Filip Pizlo <fpizlo@apple.com> 2 3 Atomics.store should return the int-converted value according to toInteger 4 https://bugs.webkit.org/show_bug.cgi?id=167399 5 6 Reviewed by Saam Barati. 7 8 * stress/atomics-add-uint32.js: Added. 9 * stress/atomics-store-return.js: Fix the test to match what the spec wants. 10 1 11 2017-01-24 Yusuke Suzuki <utatane.tea@gmail.com> 2 12 -
trunk/JSTests/stress/atomics-store-return.js
r211122 r211129 3 3 var result = Atomics.store(a, 0, 1000); 4 4 if (result != 1000) 5 throw "Error: bad result: " + result;5 throw new Error("bad result: " + result); 6 6 7 7 sab = new SharedArrayBuffer(4); 8 8 a = new Uint32Array(sab); 9 varresult = Atomics.store(a, 0, 4000000000);9 result = Atomics.store(a, 0, 4000000000); 10 10 if (result != 4000000000) 11 throw "Error: bad result: " + result; 11 throw new Error("bad result: " + result); 12 if (a[0] != 4000000000) 13 throw new Error("bad value read back: " + a[0]); 14 result = Atomics.store(a, 0, -4000000000); 15 if (result != -4000000000) 16 throw new Error("bad result: " + result); 17 if (a[0] != 294967296) 18 throw new Error("bad value read back: " + a[0]); 19 20 var count = 0; 21 result = Atomics.store(a, 0, { valueOf() { count++; return 42; } }); 22 if (result != 42) 23 throw new Error("bad result: " + result); 24 if (count != 1) 25 throw new Error("bad count: " + count); 26 -
trunk/Source/JavaScriptCore/ChangeLog
r211128 r211129 1 2017-01-24 Filip Pizlo <fpizlo@apple.com> 2 3 Atomics.store should return the int-converted value according to toInteger 4 https://bugs.webkit.org/show_bug.cgi?id=167399 5 6 Reviewed by Saam Barati. 7 8 I keep getting this wrong, but I think I've finally done it right. What we want is for 9 Atomics.store to return the value it was passed after toInteger, which doesn't clip the value to 10 any kind of range. It does get truncated to double. 11 12 This changes the code to pass those "integers" as doubles. It doesn't matter that this is slow, 13 since all of these code paths are slow due to their need to check everything. We'll take care of 14 that by making them intrinsic later. 15 16 * runtime/AtomicsObject.cpp: 17 (JSC::atomicsFuncAdd): 18 (JSC::atomicsFuncAnd): 19 (JSC::atomicsFuncCompareExchange): 20 (JSC::atomicsFuncExchange): 21 (JSC::atomicsFuncLoad): 22 (JSC::atomicsFuncOr): 23 (JSC::atomicsFuncStore): 24 (JSC::atomicsFuncSub): 25 (JSC::atomicsFuncXor): 26 1 27 2017-01-24 Yusuke Suzuki <utatane.tea@gmail.com> 2 28 -
trunk/Source/JavaScriptCore/runtime/AtomicsObject.cpp
r211122 r211129 93 93 JSGenericTypedArrayView<Adaptor>* typedArray = jsCast<JSGenericTypedArrayView<Adaptor>*>(typedArrayView); 94 94 95 int32_textraArgs[numExtraArgs + 1]; // Add 1 to avoid 0 size array error in VS.95 double extraArgs[numExtraArgs + 1]; // Add 1 to avoid 0 size array error in VS. 96 96 for (unsigned i = 0; i < numExtraArgs; ++i) { 97 int32_t value = exec->argument(2 + i).toInt32(exec);97 double value = exec->argument(2 + i).toInteger(exec); 98 98 RETURN_IF_EXCEPTION(scope, JSValue::encode(jsUndefined())); 99 99 extraArgs[i] = value; … … 192 192 { 193 193 return atomicOperationWithArgs<1>( 194 exec, [&] (auto* ptr, const int32_t* args) {195 return jsNumber(WTF::atomicExchangeAdd(ptr, args[0]));194 exec, [&] (auto* ptr, const double* args) { 195 return jsNumber(WTF::atomicExchangeAdd(ptr, toInt32(args[0]))); 196 196 }); 197 197 } … … 200 200 { 201 201 return atomicOperationWithArgs<1>( 202 exec, [&] (auto* ptr, const int32_t* args) {203 return jsNumber(WTF::atomicExchangeAnd(ptr, args[0]));202 exec, [&] (auto* ptr, const double* args) { 203 return jsNumber(WTF::atomicExchangeAnd(ptr, toInt32(args[0]))); 204 204 }); 205 205 } … … 208 208 { 209 209 return atomicOperationWithArgs<2>( 210 exec, [&] (auto* ptr, const int32_t* args) {210 exec, [&] (auto* ptr, const double* args) { 211 211 typedef typename std::remove_pointer<decltype(ptr)>::type T; 212 212 T expected = static_cast<T>(args[0]); … … 219 219 { 220 220 return atomicOperationWithArgs<1>( 221 exec, [&] (auto* ptr, const int32_t* args) {221 exec, [&] (auto* ptr, const double* args) { 222 222 typedef typename std::remove_pointer<decltype(ptr)>::type T; 223 223 return jsNumber(WTF::atomicExchange(ptr, static_cast<T>(args[0]))); … … 250 250 { 251 251 return atomicOperationWithArgs<0>( 252 exec, [&] (auto* ptr, const int32_t*) {252 exec, [&] (auto* ptr, const double*) { 253 253 return jsNumber(WTF::atomicLoad(ptr)); 254 254 }); … … 258 258 { 259 259 return atomicOperationWithArgs<1>( 260 exec, [&] (auto* ptr, const int32_t* args) {261 return jsNumber(WTF::atomicExchangeOr(ptr, args[0]));260 exec, [&] (auto* ptr, const double* args) { 261 return jsNumber(WTF::atomicExchangeOr(ptr, toInt32(args[0]))); 262 262 }); 263 263 } … … 266 266 { 267 267 return atomicOperationWithArgs<1>( 268 exec, [&] (auto* ptr, const int32_t* args) {268 exec, [&] (auto* ptr, const double* args) { 269 269 typedef typename std::remove_pointer<decltype(ptr)>::type T; 270 int32_tvalueAsInt = args[0];270 double valueAsInt = args[0]; 271 271 T valueAsT = static_cast<T>(valueAsInt); 272 272 WTF::atomicStore(ptr, valueAsT); 273 274 if (static_cast<int32_t>(valueAsT) == valueAsInt)275 return jsNumber(valueAsT);276 273 return jsNumber(valueAsInt); 277 274 }); … … 281 278 { 282 279 return atomicOperationWithArgs<1>( 283 exec, [&] (auto* ptr, const int32_t* args) {284 return jsNumber(WTF::atomicExchangeSub(ptr, args[0]));280 exec, [&] (auto* ptr, const double* args) { 281 return jsNumber(WTF::atomicExchangeSub(ptr, toInt32(args[0]))); 285 282 }); 286 283 } … … 391 388 { 392 389 return atomicOperationWithArgs<1>( 393 exec, [&] (auto* ptr, const int32_t* args) {394 return jsNumber(WTF::atomicExchangeXor(ptr, args[0]));390 exec, [&] (auto* ptr, const double* args) { 391 return jsNumber(WTF::atomicExchangeXor(ptr, toInt32(args[0]))); 395 392 }); 396 393 }
Note:
See TracChangeset
for help on using the changeset viewer.