Bug 1393089 - Part 4: Remove unused context arguments from ElementSpecific and initTypedArraySlots. r=jandem
authorAndré Bargull <andre.bargull@gmail.com>
Wed, 23 Aug 2017 18:14:34 +0200
changeset 429836 3e943b6a9520ca0ae4c9b4d7e0fc8965b5537d76
parent 429835 d5a9cdfcffa6953ee0d7827a569ab95f6be18475
child 429837 4cc7890ba6e3dcad8304e8f9019111cac06de002
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1393089
milestone57.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 1393089 - Part 4: Remove unused context arguments from ElementSpecific and initTypedArraySlots. r=jandem
js/src/vm/TypedArrayObject-inl.h
js/src/vm/TypedArrayObject.cpp
--- a/js/src/vm/TypedArrayObject-inl.h
+++ b/js/src/vm/TypedArrayObject-inl.h
@@ -232,33 +232,32 @@ class ElementSpecific
 {
   public:
     /*
      * Copy |source|'s elements into |target|, starting at |target[offset]|.
      * Act as if the assignments occurred from a fresh copy of |source|, in
      * case the two memory ranges overlap.
      */
     static bool
-    setFromTypedArray(JSContext* cx,
-                      Handle<TypedArrayObject*> target, Handle<TypedArrayObject*> source,
+    setFromTypedArray(Handle<TypedArrayObject*> target, Handle<TypedArrayObject*> source,
                       uint32_t offset)
     {
         // WARNING: |source| may be an unwrapped typed array from a different
         // compartment. Proceed with caution!
 
         MOZ_ASSERT(TypeIDOfType<T>::id == target->type(),
                    "calling wrong setFromTypedArray specialization");
         MOZ_ASSERT(!target->hasDetachedBuffer(), "target isn't detached");
         MOZ_ASSERT(!source->hasDetachedBuffer(), "source isn't detached");
 
         MOZ_ASSERT(offset <= target->length());
         MOZ_ASSERT(source->length() <= target->length() - offset);
 
         if (TypedArrayObject::sameBuffer(target, source))
-            return setFromOverlappingTypedArray(cx, target, source, offset);
+            return setFromOverlappingTypedArray(target, source, offset);
 
         SharedMem<T*> dest = target->viewDataEither().template cast<T*>() + offset;
         uint32_t count = source->length();
 
         if (source->type() == target->type()) {
             Ops::podCopy(dest, source->viewDataEither().template cast<T*>(), count);
             return true;
         }
@@ -443,18 +442,17 @@ class ElementSpecific
             Ops::store(newDest + i, n);
         }
 
         return true;
     }
 
   private:
     static bool
-    setFromOverlappingTypedArray(JSContext* cx,
-                                 Handle<TypedArrayObject*> target,
+    setFromOverlappingTypedArray(Handle<TypedArrayObject*> target,
                                  Handle<TypedArrayObject*> source,
                                  uint32_t offset)
     {
         // WARNING: |source| may be an unwrapped typed array from a different
         // compartment. Proceed with caution!
 
         MOZ_ASSERT(TypeIDOfType<T>::id == target->type(),
                    "calling wrong setFromTypedArray specialization");
--- a/js/src/vm/TypedArrayObject.cpp
+++ b/js/src/vm/TypedArrayObject.cpp
@@ -561,34 +561,34 @@ class TypedArrayObjectTemplate : public 
         RootedScript script(cx, cx->currentScript(&pc));
         if (script && ObjectGroup::useSingletonForAllocationSite(script, pc, clasp))
             newKind = SingletonObject;
         JSObject* tmp = NewBuiltinClassInstance(cx, clasp, allocKind, newKind);
         if (!tmp)
             return nullptr;
 
         Rooted<TypedArrayObject*> tarray(cx, &tmp->as<TypedArrayObject>());
-        initTypedArraySlots(cx, tarray, len);
+        initTypedArraySlots(tarray, len);
 
         // Template objects do not need memory for its elements, since there
         // won't be any elements to store. Therefore, we set the pointer to
         // nullptr and avoid allocating memory that will never be used.
         tarray->initPrivate(nullptr);
 
         if (script && !ObjectGroup::setAllocationSiteObjectGroup(cx, script, pc, tarray,
                                                                  newKind == SingletonObject))
         {
             return nullptr;
         }
 
         return tarray;
     }
 
     static void
-    initTypedArraySlots(JSContext* cx, TypedArrayObject* tarray, int32_t len)
+    initTypedArraySlots(TypedArrayObject* tarray, int32_t len)
     {
         MOZ_ASSERT(len >= 0);
         tarray->setFixedSlot(TypedArrayObject::BUFFER_SLOT, NullValue());
         tarray->setFixedSlot(TypedArrayObject::LENGTH_SLOT, Int32Value(AssertedCast<int32_t>(len)));
         tarray->setFixedSlot(TypedArrayObject::BYTEOFFSET_SLOT, Int32Value(0));
 
         // Verify that the private slot is at the expected place.
         MOZ_ASSERT(tarray->numFixedSlots() == TypedArrayObject::DATA_SLOT);
@@ -661,17 +661,17 @@ class TypedArrayObjectTemplate : public 
 
             memset(buf, 0, nbytes);
         }
 
         TypedArrayObject* obj = NewObjectWithGroup<TypedArrayObject>(cx, group, allocKind, newKind);
         if (!obj)
             return nullptr;
 
-        initTypedArraySlots(cx, obj, len);
+        initTypedArraySlots(obj, len);
         initTypedArrayData(cx, obj, len, buf.forget(), allocKind);
 
         return obj;
     }
 
     // ES2018 draft rev 8340bf9a8427ea81bb0d1459471afbcc91d18add
     // 22.2.4.1 TypedArray ( )
     // 22.2.4.2 TypedArray ( length )
@@ -1251,20 +1251,20 @@ TypedArrayObjectTemplate<T>::fromTypedAr
     // Steps 3-4 (remaining part), 18-21.
     Rooted<TypedArrayObject*> obj(cx, makeInstance(cx, buffer, 0, elementLength, proto));
     if (!obj)
         return nullptr;
 
     // Steps 17.e-h or 24.1.1.4 step 8.
     MOZ_ASSERT(!obj->isSharedMemory());
     if (isShared) {
-        if (!ElementSpecific<T, SharedOps>::setFromTypedArray(cx, obj, srcArray, 0))
+        if (!ElementSpecific<T, SharedOps>::setFromTypedArray(obj, srcArray, 0))
             return nullptr;
     } else {
-        if (!ElementSpecific<T, UnsharedOps>::setFromTypedArray(cx, obj, srcArray, 0))
+        if (!ElementSpecific<T, UnsharedOps>::setFromTypedArray(obj, srcArray, 0))
             return nullptr;
     }
 
     // Step 22.
     return obj;
 }
 
 static MOZ_ALWAYS_INLINE bool
@@ -1474,25 +1474,25 @@ TypedArrayObject::protoAccessors[] = {
     JS_PSG("byteLength", TypedArray_byteLengthGetter, 0),
     JS_PSG("byteOffset", TypedArray_byteOffsetGetter, 0),
     JS_SELF_HOSTED_SYM_GET(toStringTag, "TypedArrayToStringTag", 0),
     JS_PS_END
 };
 
 template<typename T>
 static inline bool
-SetFromTypedArray(JSContext* cx, Handle<TypedArrayObject*> target,
-                  Handle<TypedArrayObject*> source, uint32_t offset)
+SetFromTypedArray(Handle<TypedArrayObject*> target, Handle<TypedArrayObject*> source,
+                  uint32_t offset)
 {
     // WARNING: |source| may be an unwrapped typed array from a different
     // compartment. Proceed with caution!
 
     if (target->isSharedMemory() || source->isSharedMemory())
-        return ElementSpecific<T, SharedOps>::setFromTypedArray(cx, target, source, offset);
-    return ElementSpecific<T, UnsharedOps>::setFromTypedArray(cx, target, source, offset);
+        return ElementSpecific<T, SharedOps>::setFromTypedArray(target, source, offset);
+    return ElementSpecific<T, UnsharedOps>::setFromTypedArray(target, source, offset);
 }
 
 template<typename T>
 static inline bool
 SetFromNonTypedArray(JSContext* cx, Handle<TypedArrayObject*> target, HandleObject source,
                      uint32_t len, uint32_t offset)
 {
     MOZ_ASSERT(!source->is<TypedArrayObject>(), "use SetFromTypedArray");
@@ -1579,17 +1579,17 @@ TypedArrayObject::set_impl(JSContext* cx
             JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH);
             return false;
         }
 
         // Steps 13-21, 23-28.
         switch (target->type()) {
 #define SET_FROM_TYPED_ARRAY(T, N) \
           case Scalar::N: \
-            if (!SetFromTypedArray<T>(cx, target, srcTypedArray, offset)) \
+            if (!SetFromTypedArray<T>(target, srcTypedArray, offset)) \
                 return false; \
             break;
 JS_FOR_EACH_TYPED_ARRAY(SET_FROM_TYPED_ARRAY)
 #undef SET_FROM_TYPED_ARRAY
           default:
             MOZ_CRASH("Unsupported TypedArray type");
         }
     } else {