Bug 1107365 - Rename AnyTypedArray as SomeTypedArray to reduce name confusion. r=waldo
authorLars T Hansen <lhansen@mozilla.com>
Tue, 16 Dec 2014 04:43:26 +0100
changeset 219875 389db774250d96f25a80567880395b33a64a786c
parent 219874 8f22366d54357d14a7d57bf61416f8081a35194a
child 219876 4b1566e6f3d0c0c21726657323a1355b4eea4637
push id10419
push usercbook@mozilla.com
push dateTue, 16 Dec 2014 12:45:27 +0000
treeherderfx-team@ec87657146eb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswaldo
bugs1107365
milestone37.0a1
Bug 1107365 - Rename AnyTypedArray as SomeTypedArray to reduce name confusion. r=waldo
js/src/vm/SharedTypedArrayObject.h
js/src/vm/TypedArrayCommon.h
js/src/vm/TypedArrayObject.h
--- a/js/src/vm/SharedTypedArrayObject.h
+++ b/js/src/vm/SharedTypedArrayObject.h
@@ -29,17 +29,17 @@ class SharedTypedArrayObject : public Na
   protected:
     static const size_t BUFFER_SLOT      = TypedArrayLayout::BUFFER_SLOT;
     static const size_t BYTEOFFSET_SLOT  = TypedArrayLayout::BYTEOFFSET_SLOT;
     static const size_t LENGTH_SLOT      = TypedArrayLayout::LENGTH_SLOT;
     static const size_t RESERVED_SLOTS   = TypedArrayLayout::RESERVED_SLOTS;
     static const size_t DATA_SLOT        = TypedArrayLayout::DATA_SLOT;
 
   public:
-    typedef SharedTypedArrayObject AnyTypedArray;
+    typedef SharedTypedArrayObject SomeTypedArray;
     typedef SharedArrayBufferObject BufferType;
 
     template<typename T> struct OfType;
 
     static bool ensureHasBuffer(JSContext *cx, Handle<SharedTypedArrayObject*> tarray) {
         return true;
     }
 
--- a/js/src/vm/TypedArrayCommon.h
+++ b/js/src/vm/TypedArrayCommon.h
@@ -125,36 +125,36 @@ IsAnyTypedArrayClass(const Class *clasp)
 {
     return IsTypedArrayClass(clasp) || IsSharedTypedArrayClass(clasp);
 }
 
 template<class SpecificArray>
 class ElementSpecific
 {
     typedef typename SpecificArray::ElementType T;
-    typedef typename SpecificArray::AnyTypedArray AnyTypedArray;
+    typedef typename SpecificArray::SomeTypedArray SomeTypedArray;
 
   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<AnyTypedArray*> target, Handle<AnyTypedArray*> source,
+                       Handle<SomeTypedArray*> target, Handle<SomeTypedArray*> source,
                        uint32_t offset)
     {
         MOZ_ASSERT(SpecificArray::ArrayTypeID() == target->type(),
                    "calling wrong setFromTypedArray specialization");
 
         MOZ_ASSERT(offset <= target->length());
         MOZ_ASSERT(source->length() <= target->length() - offset);
 
-        if (AnyTypedArray::sameBuffer(target, source))
+        if (SomeTypedArray::sameBuffer(target, source))
             return setFromOverlappingTypedArray(cx, target, source, offset);
 
         T *dest = static_cast<T*>(target->viewData()) + offset;
         uint32_t count = source->length();
 
         if (source->type() == target->type()) {
             mozilla::PodCopy(dest, static_cast<T*>(source->viewData()), count);
             return true;
@@ -236,22 +236,22 @@ class ElementSpecific
     }
 
     /*
      * Copy |source[0]| to |source[len]| (exclusive) elements into the typed
      * array |target|, starting at index |offset|.  |source| must not be a
      * typed array.
      */
     static bool
-    setFromNonTypedArray(JSContext *cx, Handle<AnyTypedArray*> target, HandleObject source,
+    setFromNonTypedArray(JSContext *cx, Handle<SomeTypedArray*> target, HandleObject source,
                          uint32_t len, uint32_t offset = 0)
     {
         MOZ_ASSERT(target->type() == SpecificArray::ArrayTypeID(),
                    "target type and NativeType must match");
-        MOZ_ASSERT(!source->is<AnyTypedArray>(),
+        MOZ_ASSERT(!source->is<SomeTypedArray>(),
                    "use setFromTypedArray instead of this method");
 
         uint32_t i = 0;
         if (source->isNative()) {
             // Attempt fast-path infallible conversion of dense elements up to
             // the first potentially side-effectful lookup or conversion.
             uint32_t bound = Min(source->as<NativeObject>().getDenseInitializedLength(), len);
 
@@ -290,23 +290,23 @@ class ElementSpecific
         }
 
         return true;
     }
 
   private:
     static bool
     setFromOverlappingTypedArray(JSContext *cx,
-                                 Handle<AnyTypedArray*> target,
-                                 Handle<AnyTypedArray*> source,
+                                 Handle<SomeTypedArray*> target,
+                                 Handle<SomeTypedArray*> source,
                                  uint32_t offset)
     {
         MOZ_ASSERT(SpecificArray::ArrayTypeID() == target->type(),
                    "calling wrong setFromTypedArray specialization");
-        MOZ_ASSERT(AnyTypedArray::sameBuffer(target, source),
+        MOZ_ASSERT(SomeTypedArray::sameBuffer(target, source),
                    "provided arrays don't actually overlap, so it's "
                    "undesirable to use this method");
 
         MOZ_ASSERT(offset <= target->length());
         MOZ_ASSERT(source->length() <= target->length() - offset);
 
         T *dest = static_cast<T*>(target->viewData()) + offset;
         uint32_t len = source->length();
@@ -441,44 +441,44 @@ class ElementSpecific
         if (MOZ_UNLIKELY(mozilla::IsNaN(d)))
             return T(0);
         if (TypeIsUnsigned<T>())
             return T(ToUint32(d));
         return T(ToInt32(d));
     }
 };
 
-template<typename AnyTypedArray>
+template<typename SomeTypedArray>
 class TypedArrayMethods
 {
-    static_assert(mozilla::IsSame<AnyTypedArray, TypedArrayObject>::value ||
-                  mozilla::IsSame<AnyTypedArray, SharedTypedArrayObject>::value,
+    static_assert(mozilla::IsSame<SomeTypedArray, TypedArrayObject>::value ||
+                  mozilla::IsSame<SomeTypedArray, SharedTypedArrayObject>::value,
                   "methods must be shared/unshared-specific, not "
                   "element-type-specific");
 
-    typedef typename AnyTypedArray::BufferType BufferType;
+    typedef typename SomeTypedArray::BufferType BufferType;
 
-    typedef typename AnyTypedArray::template OfType<int8_t>::Type Int8ArrayType;
-    typedef typename AnyTypedArray::template OfType<uint8_t>::Type Uint8ArrayType;
-    typedef typename AnyTypedArray::template OfType<int16_t>::Type Int16ArrayType;
-    typedef typename AnyTypedArray::template OfType<uint16_t>::Type Uint16ArrayType;
-    typedef typename AnyTypedArray::template OfType<int32_t>::Type Int32ArrayType;
-    typedef typename AnyTypedArray::template OfType<uint32_t>::Type Uint32ArrayType;
-    typedef typename AnyTypedArray::template OfType<float>::Type Float32ArrayType;
-    typedef typename AnyTypedArray::template OfType<double>::Type Float64ArrayType;
-    typedef typename AnyTypedArray::template OfType<uint8_clamped>::Type Uint8ClampedArrayType;
+    typedef typename SomeTypedArray::template OfType<int8_t>::Type Int8ArrayType;
+    typedef typename SomeTypedArray::template OfType<uint8_t>::Type Uint8ArrayType;
+    typedef typename SomeTypedArray::template OfType<int16_t>::Type Int16ArrayType;
+    typedef typename SomeTypedArray::template OfType<uint16_t>::Type Uint16ArrayType;
+    typedef typename SomeTypedArray::template OfType<int32_t>::Type Int32ArrayType;
+    typedef typename SomeTypedArray::template OfType<uint32_t>::Type Uint32ArrayType;
+    typedef typename SomeTypedArray::template OfType<float>::Type Float32ArrayType;
+    typedef typename SomeTypedArray::template OfType<double>::Type Float64ArrayType;
+    typedef typename SomeTypedArray::template OfType<uint8_clamped>::Type Uint8ClampedArrayType;
 
   public:
     /* subarray(start[, end]) */
     static bool
     subarray(JSContext *cx, CallArgs args)
     {
-        MOZ_ASSERT(AnyTypedArray::is(args.thisv()));
+        MOZ_ASSERT(SomeTypedArray::is(args.thisv()));
 
-        Rooted<AnyTypedArray*> tarray(cx, &args.thisv().toObject().as<AnyTypedArray>());
+        Rooted<SomeTypedArray*> tarray(cx, &args.thisv().toObject().as<SomeTypedArray>());
 
         // These are the default values.
         uint32_t initialLength = tarray->length();
         uint32_t begin = 0, end = initialLength;
 
         if (args.length() > 0) {
             if (!ToClampedIndex(cx, args[0], initialLength, &begin))
                 return false;
@@ -492,17 +492,17 @@ class TypedArrayMethods
         if (begin > end)
             begin = end;
 
         if (begin > tarray->length() || end > tarray->length() || begin > end) {
             JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_INDEX);
             return false;
         }
 
-        if (!AnyTypedArray::ensureHasBuffer(cx, tarray))
+        if (!SomeTypedArray::ensureHasBuffer(cx, tarray))
             return false;
 
         Rooted<BufferType*> bufobj(cx, tarray->buffer());
         MOZ_ASSERT(bufobj);
 
         uint32_t length = end - begin;
 
         size_t elementSize = tarray->bytesPerElement();
@@ -553,20 +553,20 @@ class TypedArrayMethods
         return true;
     }
 
     /* copyWithin(target, start[, end]) */
     // ES6 draft rev 26, 22.2.3.5
     static bool
     copyWithin(JSContext *cx, CallArgs args)
     {
-        MOZ_ASSERT(AnyTypedArray::is(args.thisv()));
+        MOZ_ASSERT(SomeTypedArray::is(args.thisv()));
 
         // Steps 1-2.
-        Rooted<AnyTypedArray*> obj(cx, &args.thisv().toObject().as<AnyTypedArray>());
+        Rooted<SomeTypedArray*> obj(cx, &args.thisv().toObject().as<SomeTypedArray>());
 
         // Steps 3-4.
         uint32_t len = obj->length();
 
         // Steps 6-8.
         uint32_t to;
         if (!ToClampedIndex(cx, args.get(0), len, &to))
             return false;
@@ -640,19 +640,19 @@ class TypedArrayMethods
         args.rval().set(args.thisv());
         return true;
     }
 
     /* set(array[, offset]) */
     static bool
     set(JSContext *cx, CallArgs args)
     {
-        MOZ_ASSERT(AnyTypedArray::is(args.thisv()));
+        MOZ_ASSERT(SomeTypedArray::is(args.thisv()));
 
-        Rooted<AnyTypedArray*> target(cx, &args.thisv().toObject().as<AnyTypedArray>());
+        Rooted<SomeTypedArray*> target(cx, &args.thisv().toObject().as<SomeTypedArray>());
 
         // The first argument must be either a typed array or arraylike.
         if (args.length() == 0 || !args[0].isObject()) {
             JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS);
             return false;
         }
 
         int32_t offset = 0;
@@ -664,18 +664,18 @@ class TypedArrayMethods
                 // the given offset is bogus
                 JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr,
                                      JSMSG_TYPED_ARRAY_BAD_INDEX, "2");
                 return false;
             }
         }
 
         RootedObject arg0(cx, &args[0].toObject());
-        if (arg0->is<AnyTypedArray>()) {
-            Rooted<AnyTypedArray*> source(cx, &arg0->as<AnyTypedArray>());
+        if (arg0->is<SomeTypedArray>()) {
+            Rooted<SomeTypedArray*> source(cx, &arg0->as<SomeTypedArray>());
             if (source->length() > target->length() - offset) {
                 JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH);
                 return false;
             }
 
             if (!setFromTypedArray(cx, target, source, offset))
                 return false;
         } else {
@@ -692,33 +692,33 @@ class TypedArrayMethods
                 return false;
         }
 
         args.rval().setUndefined();
         return true;
     }
 
     static bool
-    setFromArrayLike(JSContext *cx, Handle<AnyTypedArray*> target, HandleObject source, uint32_t len,
+    setFromArrayLike(JSContext *cx, Handle<SomeTypedArray*> target, HandleObject source, uint32_t len,
                      uint32_t offset = 0)
     {
         MOZ_ASSERT(offset <= target->length());
         MOZ_ASSERT(len <= target->length() - offset);
 
-        if (source->is<AnyTypedArray>()) {
-            Rooted<AnyTypedArray*> src(cx, &source->as<AnyTypedArray>());
+        if (source->is<SomeTypedArray>()) {
+            Rooted<SomeTypedArray*> src(cx, &source->as<SomeTypedArray>());
             return setFromTypedArray(cx, target, src, offset);
         }
 
         return setFromNonTypedArray(cx, target, source, len, offset);
     }
 
   private:
     static bool
-    setFromTypedArray(JSContext *cx, Handle<AnyTypedArray*> target, Handle<AnyTypedArray*> source,
+    setFromTypedArray(JSContext *cx, Handle<SomeTypedArray*> target, Handle<SomeTypedArray*> source,
                       uint32_t offset)
     {
         switch (target->type()) {
           case Scalar::Int8:
             return ElementSpecific<Int8ArrayType>::setFromTypedArray(cx, target, source, offset);
           case Scalar::Uint8:
             return ElementSpecific<Uint8ArrayType>::setFromTypedArray(cx, target, source, offset);
           case Scalar::Int16:
@@ -740,20 +740,20 @@ class TypedArrayMethods
           case Scalar::MaxTypedArrayViewType:
             break;
         }
 
         MOZ_CRASH("nonsense target element type");
     }
 
     static bool
-    setFromNonTypedArray(JSContext *cx, Handle<AnyTypedArray*> target, HandleObject source,
+    setFromNonTypedArray(JSContext *cx, Handle<SomeTypedArray*> target, HandleObject source,
                          uint32_t len, uint32_t offset)
     {
-        MOZ_ASSERT(!source->is<AnyTypedArray>(), "use setFromTypedArray");
+        MOZ_ASSERT(!source->is<SomeTypedArray>(), "use setFromTypedArray");
 
         switch (target->type()) {
           case Scalar::Int8:
             return ElementSpecific<Int8ArrayType>::setFromNonTypedArray(cx, target, source, len, offset);
           case Scalar::Uint8:
             return ElementSpecific<Uint8ArrayType>::setFromNonTypedArray(cx, target, source, len, offset);
           case Scalar::Int16:
             return ElementSpecific<Int16ArrayType>::setFromNonTypedArray(cx, target, source, len, offset);
--- a/js/src/vm/TypedArrayObject.h
+++ b/js/src/vm/TypedArrayObject.h
@@ -73,17 +73,17 @@ class TypedArrayLayout
   protected:
     static_assert(js::detail::TypedArrayLengthSlot == LENGTH_SLOT,
                   "bad inlined constant in jsfriendapi.h");
 };
 
 class TypedArrayObject : public NativeObject
 {
   public:
-    typedef TypedArrayObject AnyTypedArray;
+    typedef TypedArrayObject SomeTypedArray;
     typedef ArrayBufferObject BufferType;
 
     template<typename T> struct OfType;
 
     static bool sameBuffer(Handle<TypedArrayObject*> a, Handle<TypedArrayObject*> b) {
         return a->buffer() == b->buffer();
     }