Bug 889146 (part 1) - Realign the typed array class hierarchy. r=sfink.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 01 Jul 2013 23:15:42 -0700
changeset 137277 9ed886b5122b023b958e1dcbc7fffc388645a514
parent 137276 e10afc0c67e086414aacc38118ab3115d8cb7321
child 137278 0bd37861c48cd49811bdf781db0082d5a45585f3
push id1824
push userryanvm@gmail.com
push dateWed, 03 Jul 2013 18:16:56 +0000
treeherderfx-team@dcbbfcdf7bb4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs889146
milestone25.0a1
Bug 889146 (part 1) - Realign the typed array class hierarchy. r=sfink.
js/src/jstypedarray.h
--- a/js/src/jstypedarray.h
+++ b/js/src/jstypedarray.h
@@ -14,16 +14,32 @@
 #include "gc/Barrier.h"
 
 typedef struct JSProperty JSProperty;
 
 namespace js {
 
 typedef Vector<ArrayBufferObject *, 0, SystemAllocPolicy> ArrayBufferVector;
 
+// The inheritance hierarchy for the various classes relating to typed arrays
+// is as follows.
+//
+// - JSObject
+//   - ArrayBufferObject
+//   - BufferView
+//     - DataViewObject
+//     - TypedArray
+//       - TypedArrayTemplate
+//         - Int8Array
+//         - Uint8Array
+//         - ...
+//
+// Note that |TypedArrayTemplate| is just an implementation detail that makes
+// implementing its various subclasses easier.
+
 /*
  * ArrayBufferObject
  *
  * This class holds the underlying raw buffer that the various ArrayBufferView
  * subclasses (DataView and the TypedArrays) access. It can be created
  * explicitly and passed to an ArrayBufferView subclass, or can be created
  * implicitly by constructing a TypedArray with a size.
  */
@@ -172,17 +188,18 @@ class ArrayBufferObject : public JSObjec
 
 /*
  * BufferView
  *
  * Common definitions shared by all ArrayBufferViews. (The name ArrayBufferView
  * is currently being used for a namespace in jsfriendapi.h.)
  */
 
-struct BufferView {
+class BufferView : public JSObject {
+  public:
     /* Offset of view in underlying ArrayBuffer */
     static const size_t BYTEOFFSET_SLOT  = 0;
 
     /* Byte length of view */
     static const size_t BYTELENGTH_SLOT  = 1;
 
     /* Underlying ArrayBuffer */
     static const size_t BUFFER_SLOT      = 2;
@@ -335,17 +352,17 @@ TypedArrayShift(ArrayBufferView::ViewTyp
         return 2;
       case ArrayBufferView::TYPE_FLOAT64:
         return 3;
       default:;
     }
     MOZ_ASSUME_UNREACHABLE("Unexpected array type");
 }
 
-class DataViewObject : public JSObject, public BufferView
+class DataViewObject : public BufferView
 {
 public:
     static Class class_;
 
 private:
     static Class protoClass;
 
     static inline bool is(const Value &v);