Bug 1246140 - Return correct value from Atomics.store (interpreter implementation). r=h4writer
authorLars T Hansen <lhansen@mozilla.com>
Thu, 03 Nov 2016 17:52:54 +0100
changeset 351426 e66184c7eb45ae566a7e2bce62c9b109e945d405
parent 351425 f7fe9d1a41f3ae291e4926de88559411ea0f0cd1
child 351427 1e287fe4214720717b3def013366494fddd1e8ed
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersh4writer
bugs1246140
milestone52.0a1
Bug 1246140 - Return correct value from Atomics.store (interpreter implementation). r=h4writer
js/src/builtin/AtomicsObject.cpp
--- a/js/src/builtin/AtomicsObject.cpp
+++ b/js/src/builtin/AtomicsObject.cpp
@@ -334,28 +334,30 @@ ExchangeOrStore(JSContext* cx, unsigned 
     MutableHandleValue r = args.rval();
 
     Rooted<TypedArrayObject*> view(cx, nullptr);
     if (!GetSharedTypedArray(cx, objv, &view))
         return false;
     uint32_t offset;
     if (!GetTypedArrayIndex(cx, idxv, view, &offset))
         return false;
-    int32_t numberValue;
-    if (!ToInt32(cx, valv, &numberValue))
+    double integerValue;
+    if (!ToInteger(cx, valv, &integerValue))
         return false;
 
     bool badType = false;
-    int32_t result = ExchangeOrStore<op>(view->type(), numberValue, view->viewDataShared(), offset,
-                                         &badType);
+    int32_t result = ExchangeOrStore<op>(view->type(), JS::ToInt32(integerValue),
+                                         view->viewDataShared(), offset, &badType);
 
     if (badType)
         return ReportBadArrayType(cx);
 
-    if (view->type() == Scalar::Uint32)
+    if (op == DoStore)
+        r.setNumber(integerValue);
+    else if (view->type() == Scalar::Uint32)
         r.setNumber((double)(uint32_t)result);
     else
         r.setInt32(result);
     return true;
 }
 
 bool
 js::atomics_store(JSContext* cx, unsigned argc, Value* vp)