Changeset 211122 in webkit
- Timestamp:
- Jan 24, 2017, 4:53:48 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/atomics-store-return.js (added)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/runtime/AtomicsObject.cpp (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r211113 r211122 1 2017-01-24 Filip Pizlo <fpizlo@apple.com> 2 3 Atomics.store should return the int-converted value, not the value that it stored 4 https://bugs.webkit.org/show_bug.cgi?id=167395 5 6 Reviewed by Saam Barati. 7 8 * stress/atomics-store-return.js: Added. 9 1 10 2017-01-24 Filip Pizlo <fpizlo@apple.com> 2 11 -
trunk/Source/JavaScriptCore/ChangeLog
r211113 r211122 1 2017-01-24 Filip Pizlo <fpizlo@apple.com> 2 3 Atomics.store should return the int-converted value, not the value that it stored 4 https://bugs.webkit.org/show_bug.cgi?id=167395 5 6 Reviewed by Saam Barati. 7 8 Previously the code was based around passing a lambda that operated over the native type of the 9 operation (so for example int8_t if we were doing things to Int8Arrays). But to support this 10 behavior of store, we need it to be able to control how it converts its result to JSValue and it 11 needs to see its argument as an int32_t. It turns out that it's easy for all of the functions in 12 AtomicsObject.cpp to also adopt this protocol since the conversion to JSValue is just jsNumber() 13 from the native type in those cases, and the conversion from int32_t is done for free in 14 std::atomic. 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 Filip Pizlo <fpizlo@apple.com> 2 28 -
trunk/Source/JavaScriptCore/runtime/AtomicsObject.cpp
r211113 r211122 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 93 93 JSGenericTypedArrayView<Adaptor>* typedArray = jsCast<JSGenericTypedArrayView<Adaptor>*>(typedArrayView); 94 94 95 typename Adaptor::TypeextraArgs[numExtraArgs + 1]; // Add 1 to avoid 0 size array error in VS.95 int32_t extraArgs[numExtraArgs + 1]; // Add 1 to avoid 0 size array error in VS. 96 96 for (unsigned i = 0; i < numExtraArgs; ++i) { 97 97 int32_t value = exec->argument(2 + i).toInt32(exec); 98 98 RETURN_IF_EXCEPTION(scope, JSValue::encode(jsUndefined())); 99 extraArgs[i] = Adaptor::toNativeFromInt32(value); 100 } 101 102 typename Adaptor::Type result = func(typedArray->typedVector() + accessIndex, extraArgs); 103 return JSValue::encode(Adaptor::toJSValue(result)); 99 extraArgs[i] = value; 100 } 101 102 return JSValue::encode(func(typedArray->typedVector() + accessIndex, extraArgs)); 104 103 } 105 104 … … 193 192 { 194 193 return atomicOperationWithArgs<1>( 195 exec, [&] (auto* ptr, const auto* args) {196 return WTF::atomicExchangeAdd(ptr, args[0]);194 exec, [&] (auto* ptr, const int32_t* args) { 195 return jsNumber(WTF::atomicExchangeAdd(ptr, args[0])); 197 196 }); 198 197 } … … 201 200 { 202 201 return atomicOperationWithArgs<1>( 203 exec, [&] (auto* ptr, const auto* args) {204 return WTF::atomicExchangeAnd(ptr, args[0]);202 exec, [&] (auto* ptr, const int32_t* args) { 203 return jsNumber(WTF::atomicExchangeAnd(ptr, args[0])); 205 204 }); 206 205 } … … 209 208 { 210 209 return atomicOperationWithArgs<2>( 211 exec, [&] (auto* ptr, const auto* args) { 212 return WTF::atomicCompareExchangeStrong(ptr, args[0], args[1]); 210 exec, [&] (auto* ptr, const int32_t* args) { 211 typedef typename std::remove_pointer<decltype(ptr)>::type T; 212 T expected = static_cast<T>(args[0]); 213 T newValue = static_cast<T>(args[1]); 214 return jsNumber(WTF::atomicCompareExchangeStrong(ptr, expected, newValue)); 213 215 }); 214 216 } … … 217 219 { 218 220 return atomicOperationWithArgs<1>( 219 exec, [&] (auto* ptr, const auto* args) { 220 return WTF::atomicExchange(ptr, args[0]); 221 exec, [&] (auto* ptr, const int32_t* args) { 222 typedef typename std::remove_pointer<decltype(ptr)>::type T; 223 return jsNumber(WTF::atomicExchange(ptr, static_cast<T>(args[0]))); 221 224 }); 222 225 } … … 247 250 { 248 251 return atomicOperationWithArgs<0>( 249 exec, [&] (auto* ptr, const auto*) {250 return WTF::atomicLoad(ptr);252 exec, [&] (auto* ptr, const int32_t*) { 253 return jsNumber(WTF::atomicLoad(ptr)); 251 254 }); 252 255 } … … 255 258 { 256 259 return atomicOperationWithArgs<1>( 257 exec, [&] (auto* ptr, const auto* args) {258 return WTF::atomicExchangeOr(ptr, args[0]);260 exec, [&] (auto* ptr, const int32_t* args) { 261 return jsNumber(WTF::atomicExchangeOr(ptr, args[0])); 259 262 }); 260 263 } … … 263 266 { 264 267 return atomicOperationWithArgs<1>( 265 exec, [&] (auto* ptr, const auto* args) { 266 auto value = args[0]; 267 WTF::atomicStore(ptr, value); 268 return value; 268 exec, [&] (auto* ptr, const int32_t* args) { 269 typedef typename std::remove_pointer<decltype(ptr)>::type T; 270 int32_t valueAsInt = args[0]; 271 T valueAsT = static_cast<T>(valueAsInt); 272 WTF::atomicStore(ptr, valueAsT); 273 274 if (static_cast<int32_t>(valueAsT) == valueAsInt) 275 return jsNumber(valueAsT); 276 return jsNumber(valueAsInt); 269 277 }); 270 278 } … … 273 281 { 274 282 return atomicOperationWithArgs<1>( 275 exec, [&] (auto* ptr, const auto* args) {276 return WTF::atomicExchangeSub(ptr, args[0]);283 exec, [&] (auto* ptr, const int32_t* args) { 284 return jsNumber(WTF::atomicExchangeSub(ptr, args[0])); 277 285 }); 278 286 } … … 383 391 { 384 392 return atomicOperationWithArgs<1>( 385 exec, [&] (auto* ptr, const auto* args) {386 return WTF::atomicExchangeXor(ptr, args[0]);393 exec, [&] (auto* ptr, const int32_t* args) { 394 return jsNumber(WTF::atomicExchangeXor(ptr, args[0])); 387 395 }); 388 396 }
Note:
See TracChangeset
for help on using the changeset viewer.