Bug 1285833 - Update code comments to latest spec steps. r=sfink
authorJeff Walden <jwalden@mit.edu>
Tue, 06 Dec 2016 17:21:05 -1000
changeset 327586 0728c4ae020f5065f932ed4827ee4f6687e38f78
parent 327585 6f1dd8377713c0eafaeac1ed7f3d76e4ca039dcf
child 327587 63ea9ee0d90232db157bf492f16201b9595376f1
push id85231
push userjwalden@mit.edu
push dateFri, 30 Dec 2016 03:48:56 +0000
treeherdermozilla-inbound@0728c4ae020f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1285833
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1285833 - Update code comments to latest spec steps. r=sfink
js/src/vm/TypedArrayObject.cpp
--- a/js/src/vm/TypedArrayObject.cpp
+++ b/js/src/vm/TypedArrayObject.cpp
@@ -2999,46 +2999,60 @@ js::StringIsTypedArrayIndex(const Latin1
 
 /* ES6 draft rev 34 (2015 Feb 20) 9.4.5.3 [[DefineOwnProperty]] step 3.c. */
 bool
 js::DefineTypedArrayElement(JSContext* cx, HandleObject obj, uint64_t index,
                             Handle<PropertyDescriptor> desc, ObjectOpResult& result)
 {
     MOZ_ASSERT(obj->is<TypedArrayObject>());
 
-    // These are all substeps of 3.c.
-    // Steps i-vi.
+    // These are all substeps of 3.b.
+
+    // Steps i-iii are handled by the caller.
+
+    // Steps iv-v.
     // We (wrongly) ignore out of range defines with a value.
-    if (index >= obj->as<TypedArrayObject>().length())
+    uint32_t length = obj->as<TypedArrayObject>().length();
+    if (index >= length)
         return result.succeed();
 
+    // Step vi.
+    if (desc.isAccessorDescriptor())
+        return result.fail(JSMSG_CANT_REDEFINE_PROP);
+
     // Step vii.
-    if (desc.isAccessorDescriptor())
+    if (desc.hasConfigurable() && desc.configurable())
         return result.fail(JSMSG_CANT_REDEFINE_PROP);
 
     // Step viii.
-    if (desc.hasConfigurable() && desc.configurable())
+    if (desc.hasEnumerable() && !desc.enumerable())
         return result.fail(JSMSG_CANT_REDEFINE_PROP);
 
     // Step ix.
-    if (desc.hasEnumerable() && !desc.enumerable())
+    if (desc.hasWritable() && !desc.writable())
         return result.fail(JSMSG_CANT_REDEFINE_PROP);
 
     // Step x.
-    if (desc.hasWritable() && !desc.writable())
-        return result.fail(JSMSG_CANT_REDEFINE_PROP);
-
-    // Step xi.
     if (desc.hasValue()) {
-        double d;
-        if (!ToNumber(cx, desc.value(), &d))
+        // The following step numbers refer to 9.4.5.9
+        // IntegerIndexedElementSet.
+
+        // Steps 1-2 are enforced by the caller.
+
+        // Step 3.
+        double numValue;
+        if (!ToNumber(cx, desc.value(), &numValue))
             return false;
 
-        if (obj->is<TypedArrayObject>())
-            TypedArrayObject::setElement(obj->as<TypedArrayObject>(), index, d);
+        // Steps 4-5, 8-9.
+        if (obj->as<TypedArrayObject>().hasDetachedBuffer())
+            return result.fail(JSMSG_TYPED_ARRAY_DETACHED);
+
+        // Steps 10-16.
+        TypedArrayObject::setElement(obj->as<TypedArrayObject>(), index, numValue);
     }
 
     // Step xii.
     return result.succeed();
 }
 
 /* JS Friend API */