Bug 1179315 - part 1 - make TypedArrayLayout's constructor inline and MOZ_CONSTEXPR; r=lth
authorNathan Froyd <froydnj@mozilla.com>
Tue, 30 Jun 2015 10:15:05 -0400
changeset 275870 1c0f1468c3d9d31b87a10496ed86be1d42f53be7
parent 275869 44fff46837cc15843069c21f01c79389ca21ad53
child 275871 2ad242267d9e49ea1652bc256e1d6db19cdb5dee
push id3246
push usergijskruitbosch@gmail.com
push dateTue, 07 Jul 2015 09:06:38 +0000
reviewerslth
bugs1179315
milestone42.0a1
Bug 1179315 - part 1 - make TypedArrayLayout's constructor inline and MOZ_CONSTEXPR; r=lth The definitions of {Shared,}TypedArrayObject::layout_ require static constructors on some compilers because they can't see the full definition of TypedArrayLayout's constructor. We can address this by moving the constructor to a point where it can be easily inlined, and marking it as MOZ_CONSTEXPR.
js/src/vm/SharedTypedArrayObject.cpp
js/src/vm/TypedArrayObject.cpp
js/src/vm/TypedArrayObject.h
--- a/js/src/vm/SharedTypedArrayObject.cpp
+++ b/js/src/vm/SharedTypedArrayObject.cpp
@@ -2,16 +2,17 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "vm/SharedTypedArrayObject.h"
 
 #include "mozilla/Alignment.h"
+#include "mozilla/Attributes.h"
 #include "mozilla/PodOperations.h"
 
 #include <string.h>
 #ifndef XP_WIN
 # include <sys/mman.h>
 #endif
 
 #include "jsapi.h"
--- a/js/src/vm/TypedArrayObject.cpp
+++ b/js/src/vm/TypedArrayObject.cpp
@@ -63,25 +63,16 @@ using JS::ToUint32;
  * the subclasses.
  */
 
 TypedArrayLayout TypedArrayObject::layout_(false, // shared
                                            true,  // neuterable
                                            &TypedArrayObject::classes[0],
                                            &TypedArrayObject::classes[Scalar::MaxTypedArrayViewType]);
 
-TypedArrayLayout::TypedArrayLayout(bool isShared, bool isNeuterable, const Class* firstClass,
-                                   const Class* maxClass)
-    : isShared_(isShared)
-    , isNeuterable_(isNeuterable)
-    , firstClass_(firstClass)
-    , maxClass_(maxClass)
-{
-}
-
 /* static */ int
 TypedArrayLayout::lengthOffset()
 {
     return NativeObject::getFixedSlotOffset(LENGTH_SLOT);
 }
 
 /* static */ int
 TypedArrayLayout::dataOffset()
--- a/js/src/vm/TypedArrayObject.h
+++ b/js/src/vm/TypedArrayObject.h
@@ -2,16 +2,18 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef vm_TypedArrayObject_h
 #define vm_TypedArrayObject_h
 
+#include "mozilla/Attributes.h"
+
 #include "jsobj.h"
 
 #include "gc/Barrier.h"
 #include "js/Class.h"
 #include "vm/ArrayBufferObject.h"
 
 typedef struct JSProperty JSProperty;
 
@@ -38,17 +40,23 @@ namespace js {
 class TypedArrayLayout
 {
     const bool isShared_;
     const bool isNeuterable_;
     const Class* firstClass_;
     const Class* maxClass_;
 
   public:
-    TypedArrayLayout(bool isShared, bool isNeuterable, const Class* firstClass, const Class* maxClass);
+    MOZ_CONSTEXPR TypedArrayLayout(bool isShared, bool isNeuterable,
+                                   const Class* firstClass, const Class* maxClass)
+        : isShared_(isShared)
+        , isNeuterable_(isNeuterable)
+        , firstClass_(firstClass)
+        , maxClass_(maxClass)
+    {}
 
     // Underlying (Shared)ArrayBufferObject.
     static const size_t BUFFER_SLOT = 0;
     static_assert(BUFFER_SLOT == JS_TYPEDARRAYLAYOUT_BUFFER_SLOT,
                   "self-hosted code with burned-in constants must get the "
                   "right buffer slot");
 
     // Slot containing length of the view in number of typed elements.