зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1179315 - part 2 - make it more obvious that typeIDs of typed arrays are constants; r=lth
We need MOZ_CONSTEXPR on {Shared,}TypedArrayObject::ArrayTypeID for some compilers to be able to constant-fold that function. But said compilers didn't seem to understand MOZ_CONSTEXPR annotations on TypeIDOfType, either on the template declaration or the individual specializations. Instead, we convert TypeIDOfType into a traits template, so ArrayTypeID can return a logical constant instead.
This commit is contained in:
Родитель
0569b367da
Коммит
56e2e8ff44
|
@ -98,7 +98,7 @@ class SharedTypedArrayObjectTemplate : public SharedTypedArrayObject
|
|||
typedef SharedTypedArrayObjectTemplate<NativeType> ThisTypedArrayObject;
|
||||
typedef SharedArrayBufferObject BufferType;
|
||||
|
||||
static Scalar::Type ArrayTypeID() { return TypeIDOfType<NativeType>(); }
|
||||
static MOZ_CONSTEXPR Scalar::Type ArrayTypeID() { return TypeIDOfType<NativeType>::id; }
|
||||
static bool ArrayTypeIsUnsigned() { return TypeIsUnsigned<NativeType>(); }
|
||||
static bool ArrayTypeIsFloatingPoint() { return TypeIsFloatingPoint<NativeType>(); }
|
||||
|
||||
|
|
|
@ -56,16 +56,16 @@ ValueIsLength(const Value& v, uint32_t* len)
|
|||
return false;
|
||||
}
|
||||
|
||||
template<typename NativeType> static inline Scalar::Type TypeIDOfType();
|
||||
template<> inline Scalar::Type TypeIDOfType<int8_t>() { return Scalar::Int8; }
|
||||
template<> inline Scalar::Type TypeIDOfType<uint8_t>() { return Scalar::Uint8; }
|
||||
template<> inline Scalar::Type TypeIDOfType<int16_t>() { return Scalar::Int16; }
|
||||
template<> inline Scalar::Type TypeIDOfType<uint16_t>() { return Scalar::Uint16; }
|
||||
template<> inline Scalar::Type TypeIDOfType<int32_t>() { return Scalar::Int32; }
|
||||
template<> inline Scalar::Type TypeIDOfType<uint32_t>() { return Scalar::Uint32; }
|
||||
template<> inline Scalar::Type TypeIDOfType<float>() { return Scalar::Float32; }
|
||||
template<> inline Scalar::Type TypeIDOfType<double>() { return Scalar::Float64; }
|
||||
template<> inline Scalar::Type TypeIDOfType<uint8_clamped>() { return Scalar::Uint8Clamped; }
|
||||
template<typename NativeType> struct TypeIDOfType;
|
||||
template<> struct TypeIDOfType<int8_t> { static const Scalar::Type id = Scalar::Int8; };
|
||||
template<> struct TypeIDOfType<uint8_t> { static const Scalar::Type id = Scalar::Uint8; };
|
||||
template<> struct TypeIDOfType<int16_t> { static const Scalar::Type id = Scalar::Int16; };
|
||||
template<> struct TypeIDOfType<uint16_t> { static const Scalar::Type id = Scalar::Uint16; };
|
||||
template<> struct TypeIDOfType<int32_t> { static const Scalar::Type id = Scalar::Int32; };
|
||||
template<> struct TypeIDOfType<uint32_t> { static const Scalar::Type id = Scalar::Uint32; };
|
||||
template<> struct TypeIDOfType<float> { static const Scalar::Type id = Scalar::Float32; };
|
||||
template<> struct TypeIDOfType<double> { static const Scalar::Type id = Scalar::Float64; };
|
||||
template<> struct TypeIDOfType<uint8_clamped> { static const Scalar::Type id = Scalar::Uint8Clamped; };
|
||||
|
||||
inline bool
|
||||
IsAnyTypedArray(JSObject* obj)
|
||||
|
|
|
@ -197,7 +197,7 @@ class TypedArrayObjectTemplate : public TypedArrayObject
|
|||
public:
|
||||
typedef NativeType ElementType;
|
||||
|
||||
static Scalar::Type ArrayTypeID() { return TypeIDOfType<NativeType>(); }
|
||||
static MOZ_CONSTEXPR Scalar::Type ArrayTypeID() { return TypeIDOfType<NativeType>::id; }
|
||||
static bool ArrayTypeIsUnsigned() { return TypeIsUnsigned<NativeType>(); }
|
||||
static bool ArrayTypeIsFloatingPoint() { return TypeIsFloatingPoint<NativeType>(); }
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче