Bug 1102870: Add Float32x4 and Int32x4 to the list of Scalar::Types; r=sfink,luke

This commit is contained in:
Benjamin Bouvier 2014-12-05 05:01:47 +01:00
Родитель 277bba36b7
Коммит 4f9d6eacd1
20 изменённых файлов: 86 добавлений и 51 удалений

Просмотреть файл

@ -217,7 +217,7 @@ WebGL2Context::TexImage3D(GLenum target, GLint level, GLenum internalformat,
if (pixels.IsNull()) {
data = nullptr;
dataLength = 0;
jsArrayType = js::Scalar::TypeMax;
jsArrayType = js::Scalar::MaxTypedArrayViewType;
} else {
const ArrayBufferView& view = pixels.Value();
view.ComputeLengthAndData();

Просмотреть файл

@ -597,7 +597,7 @@ public:
return TexImage2D_base(texImageTarget, level, internalFormat,
size.width, size.height, data->Stride(), 0,
format, type, data->GetData(), byteLength,
js::Scalar::TypeMax, srcFormat,
js::Scalar::MaxTypedArrayViewType, srcFormat,
mPixelStorePremultiplyAlpha);
}
@ -672,7 +672,7 @@ public:
return TexSubImage2D_base(texImageTarget.get(), level, xoffset, yoffset,
size.width, size.height, data->Stride(),
format, type, data->GetData(), byteLength,
js::Scalar::TypeMax, srcFormat,
js::Scalar::MaxTypedArrayViewType, srcFormat,
mPixelStorePremultiplyAlpha);
}
@ -1255,7 +1255,7 @@ protected:
// helpers
// If `isArrayType is TypeMax, it means no array.
// If jsArrayType is MaxTypedArrayViewType, it means no array.
void TexImage2D_base(TexImageTarget texImageTarget, GLint level,
GLenum internalFormat, GLsizei width,
GLsizei height, GLsizei srcStrideOrZero, GLint border,

Просмотреть файл

@ -4003,7 +4003,7 @@ WebGLContext::TexImage2D(GLenum rawTarget, GLint level,
if (pixels.IsNull()) {
data = nullptr;
length = 0;
jsArrayType = js::Scalar::TypeMax;
jsArrayType = js::Scalar::MaxTypedArrayViewType;
} else {
const ArrayBufferView& view = pixels.Value();
view.ComputeLengthAndData();
@ -4047,7 +4047,7 @@ WebGLContext::TexImage2D(GLenum rawTarget, GLint level,
return TexImage2D_base(rawTarget, level, internalformat, pixels->Width(),
pixels->Height(), 4*pixels->Width(), 0,
format, type, pixelData, pixelDataLength, js::Scalar::TypeMax,
format, type, pixelData, pixelDataLength, js::Scalar::MaxTypedArrayViewType,
WebGLTexelFormat::RGBA8, false);
}
@ -4230,7 +4230,7 @@ WebGLContext::TexSubImage2D(GLenum target, GLint level,
pixels->Width(), pixels->Height(),
4*pixels->Width(), format, type,
arr.Data(), arr.Length(),
js::Scalar::TypeMax,
js::Scalar::MaxTypedArrayViewType,
WebGLTexelFormat::RGBA8, false);
}

Просмотреть файл

@ -1212,9 +1212,9 @@ WebGLContext::ValidateTexInputData(GLenum type, js::Scalar::Type jsArrayType,
WebGLTexImageFunc func,
WebGLTexDimensions dims)
{
// We're using js::Scalar::TypeMax as dummy value for when the tex source
// wasn't a typed array.
if (jsArrayType == js::Scalar::TypeMax)
// We're using js::Scalar::MaxTypedArrayViewType as dummy value for when
// the tex source wasn't a typed array.
if (jsArrayType == js::Scalar::MaxTypedArrayViewType)
return true;
const char invalidTypedArray[] = "%s: Invalid typed array type for given"

Просмотреть файл

@ -277,7 +277,9 @@ ScalarTypeDescr::typeName(Type type)
case constant_: return #name_;
JS_FOR_EACH_SCALAR_TYPE_REPR(NUMERIC_TYPE_TO_STRING)
#undef NUMERIC_TYPE_TO_STRING
case Scalar::TypeMax:
case Scalar::Float32x4:
case Scalar::Int32x4:
case Scalar::MaxTypedArrayViewType:
MOZ_CRASH();
}
MOZ_CRASH("Invalid type");
@ -313,7 +315,9 @@ ScalarTypeDescr::call(JSContext *cx, unsigned argc, Value *vp)
JS_FOR_EACH_SCALAR_TYPE_REPR(SCALARTYPE_CALL)
#undef SCALARTYPE_CALL
case Scalar::TypeMax:
case Scalar::Float32x4:
case Scalar::Int32x4:
case Scalar::MaxTypedArrayViewType:
MOZ_CRASH();
}
return true;

Просмотреть файл

@ -267,6 +267,10 @@ class ScalarTypeDescr : public SimpleTypeDescr
"TypedObjectConstants.h must be consistent with Scalar::Type");
static_assert(Scalar::Uint8Clamped == JS_SCALARTYPEREPR_UINT8_CLAMPED,
"TypedObjectConstants.h must be consistent with Scalar::Type");
static_assert(Scalar::Float32x4 == JS_SCALARTYPEREPR_FLOAT32X4,
"TypedObjectConstants.h must be consistent with Scalar::Type");
static_assert(Scalar::Int32x4 == JS_SCALARTYPEREPR_INT32X4,
"TypedObjectConstants.h must be consistent with Scalar::Type");
return Type(getReservedSlot(JS_DESCR_SLOT_TYPE).toInt32());
}

Просмотреть файл

@ -68,6 +68,8 @@
#define JS_SCALARTYPEREPR_FLOAT32 6
#define JS_SCALARTYPEREPR_FLOAT64 7
#define JS_SCALARTYPEREPR_UINT8_CLAMPED 8
#define JS_SCALARTYPEREPR_FLOAT32X4 10
#define JS_SCALARTYPEREPR_INT32X4 11
// These constants are for use exclusively in JS code. In C++ code,
// prefer ReferenceTypeRepresentation::TYPE_ANY etc, which allows

Просмотреть файл

@ -260,14 +260,18 @@ IonBuilder::inlineNativeGetter(CallInfo &callInfo, JSFunction *target)
Scalar::Type type;
type = thisTypes->getTypedArrayType();
if (type != Scalar::TypeMax && TypedArrayObject::isOriginalLengthGetter(native)) {
if (type != Scalar::MaxTypedArrayViewType &&
TypedArrayObject::isOriginalLengthGetter(native))
{
MInstruction *length = addTypedArrayLength(callInfo.thisArg());
current->push(length);
return InliningStatus_Inlined;
}
type = thisTypes->getSharedTypedArrayType();
if (type != Scalar::TypeMax && SharedTypedArrayObject::isOriginalLengthGetter(type, native)) {
if (type != Scalar::MaxTypedArrayViewType &&
SharedTypedArrayObject::isOriginalLengthGetter(type, native))
{
MInstruction *length = addTypedArrayLength(callInfo.thisArg());
current->push(length);
return InliningStatus_Inlined;

Просмотреть файл

@ -3977,10 +3977,10 @@ jit::ElementAccessIsAnyTypedArray(MDefinition *obj, MDefinition *id,
return false;
*arrayType = types->getTypedArrayType();
if (*arrayType != Scalar::TypeMax)
if (*arrayType != Scalar::MaxTypedArrayViewType)
return true;
*arrayType = types->getSharedTypedArrayType();
return *arrayType != Scalar::TypeMax;
return *arrayType != Scalar::MaxTypedArrayViewType;
}
bool

Просмотреть файл

@ -8487,7 +8487,7 @@ class MLoadTypedArrayElement
setMovable();
MOZ_ASSERT(IsValidElementsType(elements, offsetAdjustment));
MOZ_ASSERT(index->type() == MIRType_Int32);
MOZ_ASSERT(arrayType >= 0 && arrayType < Scalar::TypeMax);
MOZ_ASSERT(arrayType >= 0 && arrayType < Scalar::MaxTypedArrayViewType);
}
public:
@ -8565,7 +8565,7 @@ class MLoadTypedArrayElementHole
setResultType(MIRType_Value);
setMovable();
MOZ_ASSERT(index->type() == MIRType_Int32);
MOZ_ASSERT(arrayType >= 0 && arrayType < Scalar::TypeMax);
MOZ_ASSERT(arrayType >= 0 && arrayType < Scalar::MaxTypedArrayViewType);
}
public:
@ -8689,7 +8689,7 @@ class MStoreTypedArrayElement
setMovable();
MOZ_ASSERT(IsValidElementsType(elements, offsetAdjustment));
MOZ_ASSERT(index->type() == MIRType_Int32);
MOZ_ASSERT(arrayType >= 0 && arrayType < Scalar::TypeMax);
MOZ_ASSERT(arrayType >= 0 && arrayType < Scalar::MaxTypedArrayViewType);
}
public:
@ -8767,7 +8767,7 @@ class MStoreTypedArrayElementHole
MOZ_ASSERT(elements->type() == MIRType_Elements);
MOZ_ASSERT(length->type() == MIRType_Int32);
MOZ_ASSERT(index->type() == MIRType_Int32);
MOZ_ASSERT(arrayType >= 0 && arrayType < Scalar::TypeMax);
MOZ_ASSERT(arrayType >= 0 && arrayType < Scalar::MaxTypedArrayViewType);
}
public:

Просмотреть файл

@ -65,7 +65,7 @@ BEGIN_TEST(testArrayBufferView_type)
CHECK((TestViewType<uint8_t,
CreateDataView,
JS_GetObjectAsArrayBufferView,
js::Scalar::TypeMax,
js::Scalar::MaxTypedArrayViewType,
8, 8>(cx)));
JS::Rooted<JS::Value> hasTypedObject(cx);

Просмотреть файл

@ -1416,7 +1416,11 @@ js_GetSCOffset(JSStructuredCloneWriter* writer);
namespace js {
namespace Scalar {
/* Scalar types which can appear in typed arrays and typed objects. */
/* Scalar types which can appear in typed arrays and typed objects. The enum
* values need to be kept in sync with the JS_SCALARTYPEREPR_ constants, as
* well as the TypedArrayObject::classes and TypedArrayObject::protoClasses
* definitions.
*/
enum Type {
Int8 = 0,
Uint8,
@ -1433,7 +1437,13 @@ enum Type {
*/
Uint8Clamped,
TypeMax
/*
* SIMD types don't have their own TypedArray equivalent, for now.
*/
MaxTypedArrayViewType,
Float32x4,
Int32x4
};
static inline size_t
@ -1453,6 +1463,9 @@ byteSize(Type atype)
return 4;
case Float64:
return 8;
case Int32x4:
case Float32x4:
return 16;
default:
MOZ_CRASH("invalid scalar type");
}
@ -1815,7 +1828,7 @@ extern JS_FRIEND_API(JSObject *)
JS_GetObjectAsArrayBuffer(JSObject *obj, uint32_t *length, uint8_t **data);
/*
* Get the type of elements in a typed array, or TypeMax if a DataView.
* Get the type of elements in a typed array, or MaxTypedArrayViewType if a DataView.
*
* |obj| must have passed a JS_IsArrayBufferView/JS_Is*Array test, or somehow
* be known that it would pass such a test: it is an ArrayBufferView or a

Просмотреть файл

@ -2066,7 +2066,7 @@ TemporaryTypeSet::getTypedArrayType()
if (clasp && IsTypedArrayClass(clasp))
return (Scalar::Type) (clasp - &TypedArrayObject::classes[0]);
return Scalar::TypeMax;
return Scalar::MaxTypedArrayViewType;
}
Scalar::Type
@ -2076,7 +2076,7 @@ TemporaryTypeSet::getSharedTypedArrayType()
if (clasp && IsSharedTypedArrayClass(clasp))
return (Scalar::Type) (clasp - &SharedTypedArrayObject::classes[0]);
return Scalar::TypeMax;
return Scalar::MaxTypedArrayViewType;
}
bool

Просмотреть файл

@ -798,10 +798,10 @@ class TemporaryTypeSet : public TypeSet
/* Get the prototype shared by all objects in this set, or nullptr. */
JSObject *getCommonPrototype();
/* Get the typed array type of all objects in this set, or Scalar::TypeMax. */
/* Get the typed array type of all objects in this set, or Scalar::MaxTypedArrayViewType. */
Scalar::Type getTypedArrayType();
/* Get the shared typed array type of all objects in this set, or Scalar::TypeMax. */
/* Get the shared typed array type of all objects in this set, or Scalar::MaxTypedArrayViewType. */
Scalar::Type getSharedTypedArrayType();
/* Whether clasp->isCallable() is true for one or more objects in this set. */

Просмотреть файл

@ -59,7 +59,7 @@ using JS::GenericNaN;
TypedArrayLayout SharedTypedArrayObject::layout_(true, // shared
false, // neuterable
&SharedTypedArrayObject::classes[0],
&SharedTypedArrayObject::classes[Scalar::TypeMax]);
&SharedTypedArrayObject::classes[Scalar::MaxTypedArrayViewType]);
inline void
InitSharedArrayBufferViewDataPointer(SharedTypedArrayObject *obj, SharedArrayBufferObject *buffer, size_t byteOffset)
@ -773,7 +773,7 @@ IMPL_SHARED_TYPED_ARRAY_STATICS(Float32Array)
IMPL_SHARED_TYPED_ARRAY_STATICS(Float64Array)
IMPL_SHARED_TYPED_ARRAY_STATICS(Uint8ClampedArray)
const Class SharedTypedArrayObject::classes[Scalar::TypeMax] = {
const Class SharedTypedArrayObject::classes[Scalar::MaxTypedArrayViewType] = {
IMPL_SHARED_TYPED_ARRAY_FAST_CLASS(Int8Array),
IMPL_SHARED_TYPED_ARRAY_FAST_CLASS(Uint8Array),
IMPL_SHARED_TYPED_ARRAY_FAST_CLASS(Int16Array),
@ -785,7 +785,7 @@ const Class SharedTypedArrayObject::classes[Scalar::TypeMax] = {
IMPL_SHARED_TYPED_ARRAY_FAST_CLASS(Uint8ClampedArray)
};
const Class SharedTypedArrayObject::protoClasses[Scalar::TypeMax] = {
const Class SharedTypedArrayObject::protoClasses[Scalar::MaxTypedArrayViewType] = {
IMPL_SHARED_TYPED_ARRAY_PROTO_CLASS(Int8Array),
IMPL_SHARED_TYPED_ARRAY_PROTO_CLASS(Uint8Array),
IMPL_SHARED_TYPED_ARRAY_PROTO_CLASS(Int16Array),

Просмотреть файл

@ -50,8 +50,8 @@ class SharedTypedArrayObject : public NativeObject
static bool is(HandleValue v);
static const Class classes[Scalar::TypeMax];
static const Class protoClasses[Scalar::TypeMax];
static const Class classes[Scalar::MaxTypedArrayViewType];
static const Class protoClasses[Scalar::MaxTypedArrayViewType];
static SharedArrayBufferObject *bufferObject(JSContext *cx, Handle<SharedTypedArrayObject *> obj);
@ -110,14 +110,14 @@ inline bool
IsSharedTypedArrayClass(const Class *clasp)
{
return &SharedTypedArrayObject::classes[0] <= clasp &&
clasp < &SharedTypedArrayObject::classes[Scalar::TypeMax];
clasp < &SharedTypedArrayObject::classes[Scalar::MaxTypedArrayViewType];
}
inline bool
IsSharedTypedArrayProtoClass(const Class *clasp)
{
return &SharedTypedArrayObject::protoClasses[0] <= clasp &&
clasp < &SharedTypedArrayObject::protoClasses[Scalar::TypeMax];
clasp < &SharedTypedArrayObject::protoClasses[Scalar::MaxTypedArrayViewType];
}
bool

Просмотреть файл

@ -100,7 +100,7 @@ enum StructuredDataType MOZ_ENUM_TYPE(uint32_t) {
SCTAG_TYPED_ARRAY_V1_FLOAT32 = SCTAG_TYPED_ARRAY_V1_MIN + Scalar::Float32,
SCTAG_TYPED_ARRAY_V1_FLOAT64 = SCTAG_TYPED_ARRAY_V1_MIN + Scalar::Float64,
SCTAG_TYPED_ARRAY_V1_UINT8_CLAMPED = SCTAG_TYPED_ARRAY_V1_MIN + Scalar::Uint8Clamped,
SCTAG_TYPED_ARRAY_V1_MAX = SCTAG_TYPED_ARRAY_V1_MIN + Scalar::TypeMax - 1,
SCTAG_TYPED_ARRAY_V1_MAX = SCTAG_TYPED_ARRAY_V1_MIN + Scalar::MaxTypedArrayViewType - 1,
/*
* Define a separate range of numbers for Transferable-only tags, since

Просмотреть файл

@ -735,7 +735,9 @@ class TypedArrayMethods
return ElementSpecific<Float64ArrayType>::setFromTypedArray(cx, target, source, offset);
case Scalar::Uint8Clamped:
return ElementSpecific<Uint8ClampedArrayType>::setFromTypedArray(cx, target, source, offset);
case Scalar::TypeMax:
case Scalar::Float32x4:
case Scalar::Int32x4:
case Scalar::MaxTypedArrayViewType:
break;
}
@ -767,7 +769,9 @@ class TypedArrayMethods
return ElementSpecific<Float64ArrayType>::setFromNonTypedArray(cx, target, source, len, offset);
case Scalar::Uint8Clamped:
return ElementSpecific<Uint8ClampedArrayType>::setFromNonTypedArray(cx, target, source, len, offset);
case Scalar::TypeMax:
case Scalar::Float32x4:
case Scalar::Int32x4:
case Scalar::MaxTypedArrayViewType:
break;
}

Просмотреть файл

@ -67,7 +67,7 @@ using JS::GenericNaN;
TypedArrayLayout TypedArrayObject::layout_(false, // shared
true, // neuterable
&TypedArrayObject::classes[0],
&TypedArrayObject::classes[Scalar::TypeMax]);
&TypedArrayObject::classes[Scalar::MaxTypedArrayViewType]);
TypedArrayLayout::TypedArrayLayout(bool isShared, bool isNeuterable, const Class *firstClass,
const Class *maxClass)
@ -1615,7 +1615,9 @@ TypedArrayObject::getElement(uint32_t index)
return Float64Array::getIndexValue(this, index);
case Scalar::Uint8Clamped:
return Uint8ClampedArray::getIndexValue(this, index);
case Scalar::TypeMax:
case Scalar::Float32x4:
case Scalar::Int32x4:
case Scalar::MaxTypedArrayViewType:
break;
}
@ -1655,7 +1657,9 @@ TypedArrayObject::setElement(TypedArrayObject &obj, uint32_t index, double d)
case Scalar::Float64:
Float64Array::setIndexValue(obj, index, d);
return;
case Scalar::TypeMax:
case Scalar::Float32x4:
case Scalar::Int32x4:
case Scalar::MaxTypedArrayViewType:
break;
}
@ -1776,7 +1780,7 @@ IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Float64, double, double)
TYPED_ARRAY_CLASS_SPEC(_typedArray) \
}
const Class TypedArrayObject::classes[Scalar::TypeMax] = {
const Class TypedArrayObject::classes[Scalar::MaxTypedArrayViewType] = {
IMPL_TYPED_ARRAY_CLASS(Int8Array),
IMPL_TYPED_ARRAY_CLASS(Uint8Array),
IMPL_TYPED_ARRAY_CLASS(Int16Array),
@ -1829,7 +1833,7 @@ const Class TypedArrayObject::classes[Scalar::TypeMax] = {
} \
}
const Class TypedArrayObject::protoClasses[Scalar::TypeMax] = {
const Class TypedArrayObject::protoClasses[Scalar::MaxTypedArrayViewType] = {
IMPL_TYPED_ARRAY_PROTO_CLASS(Int8Array),
IMPL_TYPED_ARRAY_PROTO_CLASS(Uint8Array),
IMPL_TYPED_ARRAY_PROTO_CLASS(Int16Array),
@ -2021,7 +2025,7 @@ js::IsTypedArrayConstructor(HandleValue v, uint32_t type)
return IsNativeFunction(v, Float64Array::class_constructor);
case Scalar::Uint8Clamped:
return IsNativeFunction(v, Uint8ClampedArray::class_constructor);
case Scalar::TypeMax:
case Scalar::MaxTypedArrayViewType:
break;
}
MOZ_CRASH("unexpected typed array type");
@ -2122,12 +2126,12 @@ JS_GetArrayBufferViewType(JSObject *obj)
{
obj = CheckedUnwrap(obj);
if (!obj)
return Scalar::TypeMax;
return Scalar::MaxTypedArrayViewType;
if (obj->is<TypedArrayObject>())
return obj->as<TypedArrayObject>().type();
else if (obj->is<DataViewObject>())
return Scalar::TypeMax;
return Scalar::MaxTypedArrayViewType;
MOZ_CRASH("invalid ArrayBufferView type");
}

Просмотреть файл

@ -87,17 +87,17 @@ class TypedArrayObject : public NativeObject
return a->buffer() == b->buffer();
}
static const Class classes[Scalar::TypeMax];
static const Class protoClasses[Scalar::TypeMax];
static const Class classes[Scalar::MaxTypedArrayViewType];
static const Class protoClasses[Scalar::MaxTypedArrayViewType];
static const Class sharedTypedArrayPrototypeClass;
static const Class *classForType(Scalar::Type type) {
MOZ_ASSERT(type < Scalar::TypeMax);
MOZ_ASSERT(type < Scalar::MaxTypedArrayViewType);
return &classes[type];
}
static const Class *protoClassForType(Scalar::Type type) {
MOZ_ASSERT(type < Scalar::TypeMax);
MOZ_ASSERT(type < Scalar::MaxTypedArrayViewType);
return &protoClasses[type];
}
@ -223,7 +223,7 @@ inline bool
IsTypedArrayClass(const Class *clasp)
{
return &TypedArrayObject::classes[0] <= clasp &&
clasp < &TypedArrayObject::classes[Scalar::TypeMax];
clasp < &TypedArrayObject::classes[Scalar::MaxTypedArrayViewType];
}
bool