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.
--- 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.