Bug 1020034. r=bz
authorJeff Walden <jwalden@mit.edu>
Tue, 03 Jun 2014 18:47:59 -0700
changeset 188622 e024afb9f1d955db68965ac3db7d3bfa04530571
parent 188621 c2a6dee2071fe84b73b11b0458000595c4bb85ba
child 188623 f3d006fd5aa5787799813fe8f9bd2754dd663335
push id44885
push userjwalden@mit.edu
push dateFri, 13 Jun 2014 21:51:52 +0000
treeherdermozilla-inbound@e024afb9f1d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1020034
milestone33.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 1020034. r=bz
dom/bindings/TypedArray.h
--- a/dom/bindings/TypedArray.h
+++ b/dom/bindings/TypedArray.h
@@ -19,33 +19,41 @@
 namespace mozilla {
 namespace dom {
 
 /*
  * Class that just handles the JSObject storage and tracing for typed arrays
  */
 struct TypedArrayObjectStorage : AllTypedArraysBase {
 protected:
-  JSObject* mObj;
+  JSObject* mTypedObj;
+  JSObject* mWrappedObj;
 
-  TypedArrayObjectStorage() : mObj(nullptr)
+  TypedArrayObjectStorage()
+    : mTypedObj(nullptr),
+      mWrappedObj(nullptr)
   {
   }
 
   explicit TypedArrayObjectStorage(TypedArrayObjectStorage&& aOther)
-    : mObj(aOther.mObj)
+    : mTypedObj(aOther.mTypedObj),
+      mWrappedObj(aOther.mWrappedObj)
   {
-    aOther.mObj = nullptr;
+    aOther.mTypedObj = nullptr;
+    aOther.mWrappedObj = nullptr;
   }
 
 public:
   inline void TraceSelf(JSTracer* trc)
   {
-    if (mObj) {
-      JS_CallObjectTracer(trc, &mObj, "TypedArray.mObj");
+    if (mTypedObj) {
+      JS_CallObjectTracer(trc, &mTypedObj, "TypedArray.mTypedObj");
+    }
+    if (mWrappedObj) {
+      JS_CallObjectTracer(trc, &mTypedObj, "TypedArray.mWrappedObj");
     }
   }
 
 private:
   TypedArrayObjectStorage(const TypedArrayObjectStorage&) MOZ_DELETE;
 };
 
 /*
@@ -82,62 +90,53 @@ private:
   mutable T* mData;
   mutable uint32_t mLength;
   mutable bool mComputed;
 
 public:
   inline bool Init(JSObject* obj)
   {
     MOZ_ASSERT(!inited());
-    mObj = UnwrapArray(obj);
+    mTypedObj = mWrappedObj = UnwrapArray(obj);
     return inited();
   }
 
   inline bool inited() const {
-    return !!mObj;
+    return !!mTypedObj;
   }
 
   inline T *Data() const {
     MOZ_ASSERT(mComputed);
     return mData;
   }
 
   inline uint32_t Length() const {
     MOZ_ASSERT(mComputed);
     return mLength;
   }
 
   inline JSObject *Obj() const {
     MOZ_ASSERT(inited());
-    return mObj;
+    return mWrappedObj;
   }
 
   inline bool WrapIntoNewCompartment(JSContext* cx)
   {
     return JS_WrapObject(cx,
-      JS::MutableHandle<JSObject*>::fromMarkedLocation(&mObj));
+      JS::MutableHandle<JSObject*>::fromMarkedLocation(&mWrappedObj));
   }
 
   inline void ComputeLengthAndData() const
   {
     MOZ_ASSERT(inited());
     MOZ_ASSERT(!mComputed);
-    GetLengthAndData(mObj, &mLength, &mData);
+    GetLengthAndData(mTypedObj, &mLength, &mData);
     mComputed = true;
   }
 
-protected:
-  inline void ComputeData() const {
-    MOZ_ASSERT(inited());
-    if (!mComputed) {
-      GetLengthAndData(mObj, &mLength, &mData);
-      mComputed = true;
-    }
-  }
-
 private:
   TypedArray_base(const TypedArray_base&) MOZ_DELETE;
 };
 
 
 template<typename T,
          JSObject* UnwrapArray(JSObject*),
          T* GetData(JSObject*),