mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1021790 - "Cleanup naming for scalar and typed array types", r=sfink
This commit is contained in:
parent
b7b84eb376
commit
00d8fa7118
@ -2112,14 +2112,14 @@ WebGLContext::ReadPixels(GLint x, GLint y, GLsizei width,
|
||||
case LOCAL_GL_UNSIGNED_BYTE:
|
||||
isReadTypeValid = true;
|
||||
bytesPerPixel = 1*channels;
|
||||
requiredDataType = js::ArrayBufferView::TYPE_UINT8;
|
||||
requiredDataType = js::Scalar::Uint8;
|
||||
break;
|
||||
case LOCAL_GL_UNSIGNED_SHORT_4_4_4_4:
|
||||
case LOCAL_GL_UNSIGNED_SHORT_5_5_5_1:
|
||||
case LOCAL_GL_UNSIGNED_SHORT_5_6_5:
|
||||
isReadTypeValid = true;
|
||||
bytesPerPixel = 2;
|
||||
requiredDataType = js::ArrayBufferView::TYPE_UINT16;
|
||||
requiredDataType = js::Scalar::Uint16;
|
||||
break;
|
||||
case LOCAL_GL_FLOAT:
|
||||
if (IsExtensionEnabled(WebGLExtensionID::WEBGL_color_buffer_float) ||
|
||||
@ -2128,7 +2128,7 @@ WebGLContext::ReadPixels(GLint x, GLint y, GLsizei width,
|
||||
isReadTypeValid = true;
|
||||
isReadTypeFloat = true;
|
||||
bytesPerPixel = 4*channels;
|
||||
requiredDataType = js::ArrayBufferView::TYPE_FLOAT32;
|
||||
requiredDataType = js::Scalar::Float32;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1202,7 +1202,7 @@ WebGLContext::ValidateTexInputData(GLenum type, int jsArrayType, WebGLTexImageFu
|
||||
// First, we check for packed types
|
||||
switch (type) {
|
||||
case LOCAL_GL_UNSIGNED_BYTE:
|
||||
validInput = (jsArrayType == -1 || jsArrayType == js::ArrayBufferView::TYPE_UINT8);
|
||||
validInput = (jsArrayType == -1 || jsArrayType == js::Scalar::Uint8);
|
||||
break;
|
||||
|
||||
case LOCAL_GL_HALF_FLOAT:
|
||||
@ -1211,16 +1211,16 @@ WebGLContext::ValidateTexInputData(GLenum type, int jsArrayType, WebGLTexImageFu
|
||||
case LOCAL_GL_UNSIGNED_SHORT_4_4_4_4:
|
||||
case LOCAL_GL_UNSIGNED_SHORT_5_5_5_1:
|
||||
case LOCAL_GL_UNSIGNED_SHORT_5_6_5:
|
||||
validInput = (jsArrayType == -1 || jsArrayType == js::ArrayBufferView::TYPE_UINT16);
|
||||
validInput = (jsArrayType == -1 || jsArrayType == js::Scalar::Uint16);
|
||||
break;
|
||||
|
||||
case LOCAL_GL_UNSIGNED_INT:
|
||||
case LOCAL_GL_UNSIGNED_INT_24_8:
|
||||
validInput = (jsArrayType == -1 || jsArrayType == js::ArrayBufferView::TYPE_UINT32);
|
||||
validInput = (jsArrayType == -1 || jsArrayType == js::Scalar::Uint32);
|
||||
break;
|
||||
|
||||
case LOCAL_GL_FLOAT:
|
||||
validInput = (jsArrayType == -1 || jsArrayType == js::ArrayBufferView::TYPE_FLOAT32);
|
||||
validInput = (jsArrayType == -1 || jsArrayType == js::Scalar::Float32);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -15,8 +15,6 @@
|
||||
|
||||
using mozilla::dom::ContentChild;
|
||||
|
||||
using namespace js::ArrayBufferView;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
@ -67,13 +65,13 @@ Crypto::GetRandomValues(JSContext* aCx, const ArrayBufferView& aArray,
|
||||
// Throw if the wrong type of ArrayBufferView is passed in
|
||||
// (Part of the Web Crypto API spec)
|
||||
switch (JS_GetArrayBufferViewType(view)) {
|
||||
case TYPE_INT8:
|
||||
case TYPE_UINT8:
|
||||
case TYPE_UINT8_CLAMPED:
|
||||
case TYPE_INT16:
|
||||
case TYPE_UINT16:
|
||||
case TYPE_INT32:
|
||||
case TYPE_UINT32:
|
||||
case js::Scalar::Int8:
|
||||
case js::Scalar::Uint8:
|
||||
case js::Scalar::Uint8Clamped:
|
||||
case js::Scalar::Int16:
|
||||
case js::Scalar::Uint16:
|
||||
case js::Scalar::Int32:
|
||||
case js::Scalar::Uint32:
|
||||
break;
|
||||
default:
|
||||
aRv.Throw(NS_ERROR_DOM_TYPE_MISMATCH_ERR);
|
||||
|
@ -106,9 +106,9 @@ PostToNFC(JSContext* aCx,
|
||||
}
|
||||
|
||||
uint32_t type = JS_GetArrayBufferViewType(obj);
|
||||
if (type != js::ArrayBufferView::TYPE_INT8 &&
|
||||
type != js::ArrayBufferView::TYPE_UINT8 &&
|
||||
type != js::ArrayBufferView::TYPE_UINT8_CLAMPED) {
|
||||
if (type != js::Scalar::Int8 &&
|
||||
type != js::Scalar::Uint8 &&
|
||||
type != js::Scalar::Uint8Clamped) {
|
||||
JS_ReportError(aCx, "Typed array data is not octets");
|
||||
return false;
|
||||
}
|
||||
|
@ -111,9 +111,9 @@ PostToRIL(JSContext *aCx,
|
||||
}
|
||||
|
||||
uint32_t type = JS_GetArrayBufferViewType(obj);
|
||||
if (type != js::ArrayBufferView::TYPE_INT8 &&
|
||||
type != js::ArrayBufferView::TYPE_UINT8 &&
|
||||
type != js::ArrayBufferView::TYPE_UINT8_CLAMPED) {
|
||||
if (type != js::Scalar::Int8 &&
|
||||
type != js::Scalar::Uint8 &&
|
||||
type != js::Scalar::Uint8Clamped) {
|
||||
JS_ReportError(aCx, "Typed array data is not octets");
|
||||
return false;
|
||||
}
|
||||
|
@ -252,23 +252,16 @@ const JSFunctionSpec js::ScalarTypeDescr::typeObjectMethods[] = {
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
static int32_t ScalarSizes[] = {
|
||||
#define SCALAR_SIZE(_kind, _type, _name) \
|
||||
sizeof(_type),
|
||||
JS_FOR_EACH_SCALAR_TYPE_REPR(SCALAR_SIZE) 0
|
||||
#undef SCALAR_SIZE
|
||||
};
|
||||
|
||||
int32_t
|
||||
ScalarTypeDescr::size(Type t)
|
||||
{
|
||||
return ScalarSizes[t];
|
||||
return Scalar::byteSize(t);
|
||||
}
|
||||
|
||||
int32_t
|
||||
ScalarTypeDescr::alignment(Type t)
|
||||
{
|
||||
return ScalarSizes[t];
|
||||
return Scalar::byteSize(t);
|
||||
}
|
||||
|
||||
/*static*/ const char *
|
||||
@ -278,6 +271,9 @@ ScalarTypeDescr::typeName(Type type)
|
||||
#define NUMERIC_TYPE_TO_STRING(constant_, type_, name_) \
|
||||
case constant_: return #name_;
|
||||
JS_FOR_EACH_SCALAR_TYPE_REPR(NUMERIC_TYPE_TO_STRING)
|
||||
#undef NUMERIC_TYPE_TO_STRING
|
||||
case Scalar::TypeMax:
|
||||
MOZ_CRASH();
|
||||
}
|
||||
MOZ_ASSUME_UNREACHABLE("Invalid type");
|
||||
}
|
||||
@ -299,7 +295,7 @@ ScalarTypeDescr::call(JSContext *cx, unsigned argc, Value *vp)
|
||||
if (!ToNumber(cx, args[0], &number))
|
||||
return false;
|
||||
|
||||
if (type == ScalarTypeDescr::TYPE_UINT8_CLAMPED)
|
||||
if (type == Scalar::Uint8Clamped)
|
||||
number = ClampDoubleToUint8(number);
|
||||
|
||||
switch (type) {
|
||||
@ -312,7 +308,8 @@ ScalarTypeDescr::call(JSContext *cx, unsigned argc, Value *vp)
|
||||
|
||||
JS_FOR_EACH_SCALAR_TYPE_REPR(SCALARTYPE_CALL)
|
||||
#undef SCALARTYPE_CALL
|
||||
|
||||
case Scalar::TypeMax:
|
||||
MOZ_CRASH();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -377,6 +374,7 @@ ReferenceTypeDescr::typeName(Type type)
|
||||
#define NUMERIC_TYPE_TO_STRING(constant_, type_, name_) \
|
||||
case constant_: return #name_;
|
||||
JS_FOR_EACH_REFERENCE_TYPE_REPR(NUMERIC_TYPE_TO_STRING)
|
||||
#undef NUMERIC_TYPE_TO_STRING
|
||||
}
|
||||
MOZ_ASSUME_UNREACHABLE("Invalid type");
|
||||
}
|
||||
|
@ -239,24 +239,7 @@ class SimpleTypeDescr : public SizedTypeDescr
|
||||
class ScalarTypeDescr : public SimpleTypeDescr
|
||||
{
|
||||
public:
|
||||
// Must match order of JS_FOR_EACH_SCALAR_TYPE_REPR below
|
||||
enum Type {
|
||||
TYPE_INT8 = JS_SCALARTYPEREPR_INT8,
|
||||
TYPE_UINT8 = JS_SCALARTYPEREPR_UINT8,
|
||||
TYPE_INT16 = JS_SCALARTYPEREPR_INT16,
|
||||
TYPE_UINT16 = JS_SCALARTYPEREPR_UINT16,
|
||||
TYPE_INT32 = JS_SCALARTYPEREPR_INT32,
|
||||
TYPE_UINT32 = JS_SCALARTYPEREPR_UINT32,
|
||||
TYPE_FLOAT32 = JS_SCALARTYPEREPR_FLOAT32,
|
||||
TYPE_FLOAT64 = JS_SCALARTYPEREPR_FLOAT64,
|
||||
|
||||
/*
|
||||
* Special type that's a uint8_t, but assignments are clamped to 0 .. 255.
|
||||
* Treat the raw data type as a uint8_t.
|
||||
*/
|
||||
TYPE_UINT8_CLAMPED = JS_SCALARTYPEREPR_UINT8_CLAMPED,
|
||||
};
|
||||
static const int32_t TYPE_MAX = TYPE_UINT8_CLAMPED + 1;
|
||||
typedef Scalar::Type Type;
|
||||
|
||||
static const type::Kind Kind = type::Scalar;
|
||||
static const bool Opaque = false;
|
||||
@ -267,8 +250,22 @@ class ScalarTypeDescr : public SimpleTypeDescr
|
||||
static const Class class_;
|
||||
static const JSFunctionSpec typeObjectMethods[];
|
||||
|
||||
ScalarTypeDescr::Type type() const {
|
||||
return (ScalarTypeDescr::Type) getReservedSlot(JS_DESCR_SLOT_TYPE).toInt32();
|
||||
Type type() const {
|
||||
// Make sure the values baked into TypedObjectConstants.h line up with
|
||||
// the Scalar::Type enum. We don't define Scalar::Type directly in
|
||||
// terms of these constants to avoid making TypedObjectConstants.h a
|
||||
// public header file.
|
||||
JS_STATIC_ASSERT(Scalar::Int8 == JS_SCALARTYPEREPR_INT8);
|
||||
JS_STATIC_ASSERT(Scalar::Uint8 == JS_SCALARTYPEREPR_UINT8);
|
||||
JS_STATIC_ASSERT(Scalar::Int16 == JS_SCALARTYPEREPR_INT16);
|
||||
JS_STATIC_ASSERT(Scalar::Uint16 == JS_SCALARTYPEREPR_UINT16);
|
||||
JS_STATIC_ASSERT(Scalar::Int32 == JS_SCALARTYPEREPR_INT32);
|
||||
JS_STATIC_ASSERT(Scalar::Uint32 == JS_SCALARTYPEREPR_UINT32);
|
||||
JS_STATIC_ASSERT(Scalar::Float32 == JS_SCALARTYPEREPR_FLOAT32);
|
||||
JS_STATIC_ASSERT(Scalar::Float64 == JS_SCALARTYPEREPR_FLOAT64);
|
||||
JS_STATIC_ASSERT(Scalar::Uint8Clamped == JS_SCALARTYPEREPR_UINT8_CLAMPED);
|
||||
|
||||
return (Type) getReservedSlot(JS_DESCR_SLOT_TYPE).toInt32();
|
||||
}
|
||||
|
||||
static bool call(JSContext *cx, unsigned argc, Value *vp);
|
||||
@ -277,20 +274,20 @@ class ScalarTypeDescr : public SimpleTypeDescr
|
||||
// Enumerates the cases of ScalarTypeDescr::Type which have
|
||||
// unique C representation. In particular, omits Uint8Clamped since it
|
||||
// is just a Uint8.
|
||||
#define JS_FOR_EACH_UNIQUE_SCALAR_TYPE_REPR_CTYPE(macro_) \
|
||||
macro_(ScalarTypeDescr::TYPE_INT8, int8_t, int8) \
|
||||
macro_(ScalarTypeDescr::TYPE_UINT8, uint8_t, uint8) \
|
||||
macro_(ScalarTypeDescr::TYPE_INT16, int16_t, int16) \
|
||||
macro_(ScalarTypeDescr::TYPE_UINT16, uint16_t, uint16) \
|
||||
macro_(ScalarTypeDescr::TYPE_INT32, int32_t, int32) \
|
||||
macro_(ScalarTypeDescr::TYPE_UINT32, uint32_t, uint32) \
|
||||
macro_(ScalarTypeDescr::TYPE_FLOAT32, float, float32) \
|
||||
macro_(ScalarTypeDescr::TYPE_FLOAT64, double, float64)
|
||||
#define JS_FOR_EACH_UNIQUE_SCALAR_TYPE_REPR_CTYPE(macro_) \
|
||||
macro_(Scalar::Int8, int8_t, int8) \
|
||||
macro_(Scalar::Uint8, uint8_t, uint8) \
|
||||
macro_(Scalar::Int16, int16_t, int16) \
|
||||
macro_(Scalar::Uint16, uint16_t, uint16) \
|
||||
macro_(Scalar::Int32, int32_t, int32) \
|
||||
macro_(Scalar::Uint32, uint32_t, uint32) \
|
||||
macro_(Scalar::Float32, float, float32) \
|
||||
macro_(Scalar::Float64, double, float64)
|
||||
|
||||
// Must be in same order as the enum ScalarTypeDescr::Type:
|
||||
#define JS_FOR_EACH_SCALAR_TYPE_REPR(macro_) \
|
||||
JS_FOR_EACH_UNIQUE_SCALAR_TYPE_REPR_CTYPE(macro_) \
|
||||
macro_(ScalarTypeDescr::TYPE_UINT8_CLAMPED, uint8_t, uint8Clamped)
|
||||
#define JS_FOR_EACH_SCALAR_TYPE_REPR(macro_) \
|
||||
JS_FOR_EACH_UNIQUE_SCALAR_TYPE_REPR_CTYPE(macro_) \
|
||||
macro_(Scalar::Uint8Clamped, uint8_t, uint8Clamped)
|
||||
|
||||
// Type for reference type constructors like `Any`, `String`, and
|
||||
// `Object`. All such type constructors share a common js::Class and
|
||||
|
@ -60,9 +60,8 @@
|
||||
#define JS_TYPEREPR_X4_KIND 5
|
||||
|
||||
// These constants are for use exclusively in JS code. In C++ code,
|
||||
// prefer ScalarTypeRepresentation::TYPE_INT8 etc, which allows
|
||||
// you to write a switch which will receive a warning if you omit a
|
||||
// case.
|
||||
// prefer Scalar::Int8 etc, which allows you to write a switch which will
|
||||
// receive a warning if you omit a case.
|
||||
#define JS_SCALARTYPEREPR_INT8 0
|
||||
#define JS_SCALARTYPEREPR_UINT8 1
|
||||
#define JS_SCALARTYPEREPR_INT16 2
|
||||
|
@ -2224,29 +2224,29 @@ bool CanConvertTypedArrayItemTo(JSObject *baseType, JSObject *valObj, JSContext
|
||||
}
|
||||
TypeCode elementTypeCode;
|
||||
switch (JS_GetArrayBufferViewType(valObj)) {
|
||||
case ScalarTypeDescr::TYPE_INT8:
|
||||
case Scalar::Int8:
|
||||
elementTypeCode = TYPE_int8_t;
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT8:
|
||||
case ScalarTypeDescr::TYPE_UINT8_CLAMPED:
|
||||
case Scalar::Uint8:
|
||||
case Scalar::Uint8Clamped:
|
||||
elementTypeCode = TYPE_uint8_t;
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_INT16:
|
||||
case Scalar::Int16:
|
||||
elementTypeCode = TYPE_int16_t;
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT16:
|
||||
case Scalar::Uint16:
|
||||
elementTypeCode = TYPE_uint16_t;
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_INT32:
|
||||
case Scalar::Int32:
|
||||
elementTypeCode = TYPE_int32_t;
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT32:
|
||||
case Scalar::Uint32:
|
||||
elementTypeCode = TYPE_uint32_t;
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_FLOAT32:
|
||||
case Scalar::Float32:
|
||||
elementTypeCode = TYPE_float32_t;
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_FLOAT64:
|
||||
case Scalar::Float64:
|
||||
elementTypeCode = TYPE_float64_t;
|
||||
break;
|
||||
default:
|
||||
|
@ -722,19 +722,19 @@ bool operator!=(const Signature &lhs, const Signature &rhs)
|
||||
// Typed array utilities
|
||||
|
||||
static Type
|
||||
TypedArrayLoadType(ArrayBufferView::ViewType viewType)
|
||||
TypedArrayLoadType(Scalar::Type viewType)
|
||||
{
|
||||
switch (viewType) {
|
||||
case ArrayBufferView::TYPE_INT8:
|
||||
case ArrayBufferView::TYPE_INT16:
|
||||
case ArrayBufferView::TYPE_INT32:
|
||||
case ArrayBufferView::TYPE_UINT8:
|
||||
case ArrayBufferView::TYPE_UINT16:
|
||||
case ArrayBufferView::TYPE_UINT32:
|
||||
case Scalar::Int8:
|
||||
case Scalar::Int16:
|
||||
case Scalar::Int32:
|
||||
case Scalar::Uint8:
|
||||
case Scalar::Uint16:
|
||||
case Scalar::Uint32:
|
||||
return Type::Intish;
|
||||
case ArrayBufferView::TYPE_FLOAT32:
|
||||
case Scalar::Float32:
|
||||
return Type::MaybeFloat;
|
||||
case ArrayBufferView::TYPE_FLOAT64:
|
||||
case Scalar::Float64:
|
||||
return Type::MaybeDouble;
|
||||
default:;
|
||||
}
|
||||
@ -878,7 +878,7 @@ class MOZ_STACK_CLASS ModuleCompiler
|
||||
uint32_t funcIndex_;
|
||||
uint32_t funcPtrTableIndex_;
|
||||
uint32_t ffiIndex_;
|
||||
ArrayBufferView::ViewType viewType_;
|
||||
Scalar::Type viewType_;
|
||||
AsmJSMathBuiltinFunction mathBuiltinFunc_;
|
||||
} u;
|
||||
|
||||
@ -918,7 +918,7 @@ class MOZ_STACK_CLASS ModuleCompiler
|
||||
JS_ASSERT(which_ == FFI);
|
||||
return u.ffiIndex_;
|
||||
}
|
||||
ArrayBufferView::ViewType viewType() const {
|
||||
Scalar::Type viewType() const {
|
||||
JS_ASSERT(which_ == ArrayView);
|
||||
return u.viewType_;
|
||||
}
|
||||
@ -1348,7 +1348,7 @@ class MOZ_STACK_CLASS ModuleCompiler
|
||||
global->u.ffiIndex_ = index;
|
||||
return globals_.putNew(varName, global);
|
||||
}
|
||||
bool addArrayView(PropertyName *varName, ArrayBufferView::ViewType vt, PropertyName *fieldName) {
|
||||
bool addArrayView(PropertyName *varName, Scalar::Type vt, PropertyName *fieldName) {
|
||||
Global *global = moduleLifo_.new_<Global>(Global::ArrayView);
|
||||
if (!global)
|
||||
return false;
|
||||
@ -2119,7 +2119,7 @@ class FunctionCompiler
|
||||
curBlock_->setSlot(info().localSlot(local.slot), def);
|
||||
}
|
||||
|
||||
MDefinition *loadHeap(ArrayBufferView::ViewType vt, MDefinition *ptr, NeedsBoundsCheck chk)
|
||||
MDefinition *loadHeap(Scalar::Type vt, MDefinition *ptr, NeedsBoundsCheck chk)
|
||||
{
|
||||
if (inDeadCode())
|
||||
return nullptr;
|
||||
@ -2130,7 +2130,7 @@ class FunctionCompiler
|
||||
return load;
|
||||
}
|
||||
|
||||
void storeHeap(ArrayBufferView::ViewType vt, MDefinition *ptr, MDefinition *v, NeedsBoundsCheck chk)
|
||||
void storeHeap(Scalar::Type vt, MDefinition *ptr, MDefinition *v, NeedsBoundsCheck chk)
|
||||
{
|
||||
if (inDeadCode())
|
||||
return;
|
||||
@ -2994,23 +2994,23 @@ CheckNewArrayView(ModuleCompiler &m, PropertyName *varName, ParseNode *newExpr)
|
||||
return m.failName(bufArg, "argument to array view constructor must be '%s'", bufferName);
|
||||
|
||||
JSAtomState &names = m.cx()->names();
|
||||
ArrayBufferView::ViewType type;
|
||||
Scalar::Type type;
|
||||
if (field == names.Int8Array)
|
||||
type = ArrayBufferView::TYPE_INT8;
|
||||
type = Scalar::Int8;
|
||||
else if (field == names.Uint8Array)
|
||||
type = ArrayBufferView::TYPE_UINT8;
|
||||
type = Scalar::Uint8;
|
||||
else if (field == names.Int16Array)
|
||||
type = ArrayBufferView::TYPE_INT16;
|
||||
type = Scalar::Int16;
|
||||
else if (field == names.Uint16Array)
|
||||
type = ArrayBufferView::TYPE_UINT16;
|
||||
type = Scalar::Uint16;
|
||||
else if (field == names.Int32Array)
|
||||
type = ArrayBufferView::TYPE_INT32;
|
||||
type = Scalar::Int32;
|
||||
else if (field == names.Uint32Array)
|
||||
type = ArrayBufferView::TYPE_UINT32;
|
||||
type = Scalar::Uint32;
|
||||
else if (field == names.Float32Array)
|
||||
type = ArrayBufferView::TYPE_FLOAT32;
|
||||
type = Scalar::Float32;
|
||||
else if (field == names.Float64Array)
|
||||
type = ArrayBufferView::TYPE_FLOAT64;
|
||||
type = Scalar::Float64;
|
||||
else
|
||||
return m.fail(ctorExpr, "could not match typed array name");
|
||||
|
||||
@ -3356,7 +3356,7 @@ FoldMaskedArrayIndex(FunctionCompiler &f, ParseNode **indexExpr, int32_t *mask,
|
||||
}
|
||||
|
||||
static bool
|
||||
CheckArrayAccess(FunctionCompiler &f, ParseNode *elem, ArrayBufferView::ViewType *viewType,
|
||||
CheckArrayAccess(FunctionCompiler &f, ParseNode *elem, Scalar::Type *viewType,
|
||||
MDefinition **def, NeedsBoundsCheck *needsBoundsCheck)
|
||||
{
|
||||
ParseNode *viewName = ElemBase(elem);
|
||||
@ -3461,7 +3461,7 @@ CheckArrayAccess(FunctionCompiler &f, ParseNode *elem, ArrayBufferView::ViewType
|
||||
static bool
|
||||
CheckLoadArray(FunctionCompiler &f, ParseNode *elem, MDefinition **def, Type *type)
|
||||
{
|
||||
ArrayBufferView::ViewType viewType;
|
||||
Scalar::Type viewType;
|
||||
MDefinition *pointerDef;
|
||||
NeedsBoundsCheck needsBoundsCheck;
|
||||
if (!CheckArrayAccess(f, elem, &viewType, &pointerDef, &needsBoundsCheck))
|
||||
@ -3475,7 +3475,7 @@ CheckLoadArray(FunctionCompiler &f, ParseNode *elem, MDefinition **def, Type *ty
|
||||
static bool
|
||||
CheckStoreArray(FunctionCompiler &f, ParseNode *lhs, ParseNode *rhs, MDefinition **def, Type *type)
|
||||
{
|
||||
ArrayBufferView::ViewType viewType;
|
||||
Scalar::Type viewType;
|
||||
MDefinition *pointerDef;
|
||||
NeedsBoundsCheck needsBoundsCheck;
|
||||
if (!CheckArrayAccess(f, lhs, &viewType, &pointerDef, &needsBoundsCheck))
|
||||
@ -3487,22 +3487,22 @@ CheckStoreArray(FunctionCompiler &f, ParseNode *lhs, ParseNode *rhs, MDefinition
|
||||
return false;
|
||||
|
||||
switch (viewType) {
|
||||
case ArrayBufferView::TYPE_INT8:
|
||||
case ArrayBufferView::TYPE_INT16:
|
||||
case ArrayBufferView::TYPE_INT32:
|
||||
case ArrayBufferView::TYPE_UINT8:
|
||||
case ArrayBufferView::TYPE_UINT16:
|
||||
case ArrayBufferView::TYPE_UINT32:
|
||||
case Scalar::Int8:
|
||||
case Scalar::Int16:
|
||||
case Scalar::Int32:
|
||||
case Scalar::Uint8:
|
||||
case Scalar::Uint16:
|
||||
case Scalar::Uint32:
|
||||
if (!rhsType.isIntish())
|
||||
return f.failf(lhs, "%s is not a subtype of intish", rhsType.toChars());
|
||||
break;
|
||||
case ArrayBufferView::TYPE_FLOAT32:
|
||||
case Scalar::Float32:
|
||||
if (rhsType.isMaybeDouble())
|
||||
rhsDef = f.unary<MToFloat32>(rhsDef);
|
||||
else if (!rhsType.isFloatish())
|
||||
return f.failf(lhs, "%s is not a subtype of double? or floatish", rhsType.toChars());
|
||||
break;
|
||||
case ArrayBufferView::TYPE_FLOAT64:
|
||||
case Scalar::Float64:
|
||||
if (rhsType.isMaybeFloat())
|
||||
rhsDef = f.unary<MToDouble>(rhsDef);
|
||||
else if (!rhsType.isMaybeDouble())
|
||||
|
@ -79,7 +79,7 @@ class AsmJSModule
|
||||
} init;
|
||||
} var;
|
||||
uint32_t ffiIndex_;
|
||||
ArrayBufferView::ViewType viewType_;
|
||||
Scalar::Type viewType_;
|
||||
AsmJSMathBuiltinFunction mathBuiltinFunc_;
|
||||
struct {
|
||||
ConstantKind kind_;
|
||||
@ -143,7 +143,7 @@ class AsmJSModule
|
||||
JS_ASSERT(pod.which_ == ArrayView);
|
||||
return name_;
|
||||
}
|
||||
ArrayBufferView::ViewType viewType() const {
|
||||
Scalar::Type viewType() const {
|
||||
JS_ASSERT(pod.which_ == ArrayView);
|
||||
return pod.u.viewType_;
|
||||
}
|
||||
@ -645,7 +645,7 @@ class AsmJSModule
|
||||
g.pod.u.ffiIndex_ = *ffiIndex = pod.numFFIs_++;
|
||||
return globals_.append(g);
|
||||
}
|
||||
bool addArrayView(ArrayBufferView::ViewType vt, PropertyName *field) {
|
||||
bool addArrayView(Scalar::Type vt, PropertyName *field) {
|
||||
JS_ASSERT(!isFinishedWithModulePrologue());
|
||||
pod.hasArrayView_ = true;
|
||||
Global g(Global::ArrayView, field);
|
||||
|
@ -3888,9 +3888,9 @@ static bool
|
||||
TypedArrayRequiresFloatingPoint(TypedArrayObject *tarr)
|
||||
{
|
||||
uint32_t type = tarr->type();
|
||||
return (type == ScalarTypeDescr::TYPE_UINT32 ||
|
||||
type == ScalarTypeDescr::TYPE_FLOAT32 ||
|
||||
type == ScalarTypeDescr::TYPE_FLOAT64);
|
||||
return (type == Scalar::Uint32 ||
|
||||
type == Scalar::Float32 ||
|
||||
type == Scalar::Float64);
|
||||
}
|
||||
|
||||
static bool
|
||||
@ -4646,7 +4646,7 @@ ICGetElem_TypedArray::Compiler::generateStubCode(MacroAssembler &masm)
|
||||
masm.loadPtr(Address(obj, TypedArrayObject::dataOffset()), scratchReg);
|
||||
|
||||
// Load the value.
|
||||
BaseIndex source(scratchReg, key, ScaleFromElemWidth(TypedArrayObject::slotWidth(type_)));
|
||||
BaseIndex source(scratchReg, key, ScaleFromElemWidth(Scalar::byteSize(type_)));
|
||||
masm.loadFromTypedArray(type_, source, R0, false, scratchReg, &failure);
|
||||
|
||||
// Todo: Allow loading doubles from uint32 arrays, but this requires monitoring.
|
||||
@ -5535,7 +5535,7 @@ ICSetElem_TypedArray::Compiler::generateStubCode(MacroAssembler &masm)
|
||||
// Load the elements vector.
|
||||
masm.loadPtr(Address(obj, TypedArrayObject::dataOffset()), scratchReg);
|
||||
|
||||
BaseIndex dest(scratchReg, key, ScaleFromElemWidth(TypedArrayObject::slotWidth(type_)));
|
||||
BaseIndex dest(scratchReg, key, ScaleFromElemWidth(Scalar::byteSize(type_)));
|
||||
Address value(BaselineStackReg, ICStackValueOffset);
|
||||
|
||||
// We need a second scratch register. It's okay to clobber the type tag of
|
||||
@ -5546,10 +5546,10 @@ ICSetElem_TypedArray::Compiler::generateStubCode(MacroAssembler &masm)
|
||||
regs.take(scratchReg);
|
||||
Register secondScratch = regs.takeAny();
|
||||
|
||||
if (type_ == ScalarTypeDescr::TYPE_FLOAT32 || type_ == ScalarTypeDescr::TYPE_FLOAT64) {
|
||||
if (type_ == Scalar::Float32 || type_ == Scalar::Float64) {
|
||||
masm.ensureDouble(value, FloatReg0, &failure);
|
||||
if (LIRGenerator::allowFloat32Optimizations() &&
|
||||
type_ == ScalarTypeDescr::TYPE_FLOAT32)
|
||||
type_ == Scalar::Float32)
|
||||
{
|
||||
masm.convertDoubleToFloat32(FloatReg0, ScratchFloat32Reg);
|
||||
masm.storeToTypedFloatArray(type_, ScratchFloat32Reg, dest);
|
||||
@ -5557,7 +5557,7 @@ ICSetElem_TypedArray::Compiler::generateStubCode(MacroAssembler &masm)
|
||||
masm.storeToTypedFloatArray(type_, FloatReg0, dest);
|
||||
}
|
||||
EmitReturnFromIC(masm);
|
||||
} else if (type_ == ScalarTypeDescr::TYPE_UINT8_CLAMPED) {
|
||||
} else if (type_ == Scalar::Uint8Clamped) {
|
||||
Label notInt32;
|
||||
masm.branchTestInt32(Assembler::NotEqual, value, ¬Int32);
|
||||
masm.unboxInt32(value, secondScratch);
|
||||
@ -10262,7 +10262,7 @@ ICGetElem_Dense::Clone(JSContext *cx, ICStubSpace *space, ICStub *firstMonitorSt
|
||||
return New(space, other.jitCode(), firstMonitorStub, shape);
|
||||
}
|
||||
|
||||
ICGetElem_TypedArray::ICGetElem_TypedArray(JitCode *stubCode, HandleShape shape, uint32_t type)
|
||||
ICGetElem_TypedArray::ICGetElem_TypedArray(JitCode *stubCode, HandleShape shape, Scalar::Type type)
|
||||
: ICStub(GetElem_TypedArray, stubCode),
|
||||
shape_(shape)
|
||||
{
|
||||
@ -10303,7 +10303,7 @@ ICSetElemDenseAddCompiler::getStubSpecific(ICStubSpace *space, const AutoShapeVe
|
||||
return ICSetElem_DenseAddImpl<ProtoChainDepth>::New(space, stubCode, objType, shapes);
|
||||
}
|
||||
|
||||
ICSetElem_TypedArray::ICSetElem_TypedArray(JitCode *stubCode, HandleShape shape, uint32_t type,
|
||||
ICSetElem_TypedArray::ICSetElem_TypedArray(JitCode *stubCode, HandleShape shape, Scalar::Type type,
|
||||
bool expectOutOfBounds)
|
||||
: ICStub(SetElem_TypedArray, stubCode),
|
||||
shape_(shape)
|
||||
|
@ -3407,11 +3407,11 @@ class ICGetElem_TypedArray : public ICStub
|
||||
protected: // Protected to silence Clang warning.
|
||||
HeapPtrShape shape_;
|
||||
|
||||
ICGetElem_TypedArray(JitCode *stubCode, HandleShape shape, uint32_t type);
|
||||
ICGetElem_TypedArray(JitCode *stubCode, HandleShape shape, Scalar::Type type);
|
||||
|
||||
public:
|
||||
static inline ICGetElem_TypedArray *New(ICStubSpace *space, JitCode *code,
|
||||
HandleShape shape, uint32_t type)
|
||||
HandleShape shape, Scalar::Type type)
|
||||
{
|
||||
if (!code)
|
||||
return nullptr;
|
||||
@ -3428,7 +3428,7 @@ class ICGetElem_TypedArray : public ICStub
|
||||
|
||||
class Compiler : public ICStubCompiler {
|
||||
RootedShape shape_;
|
||||
uint32_t type_;
|
||||
Scalar::Type type_;
|
||||
|
||||
protected:
|
||||
bool generateStubCode(MacroAssembler &masm);
|
||||
@ -3438,7 +3438,7 @@ class ICGetElem_TypedArray : public ICStub
|
||||
}
|
||||
|
||||
public:
|
||||
Compiler(JSContext *cx, Shape *shape, uint32_t type)
|
||||
Compiler(JSContext *cx, Shape *shape, Scalar::Type type)
|
||||
: ICStubCompiler(cx, ICStub::GetElem_TypedArray),
|
||||
shape_(cx, shape),
|
||||
type_(type)
|
||||
@ -3722,12 +3722,12 @@ class ICSetElem_TypedArray : public ICStub
|
||||
protected: // Protected to silence Clang warning.
|
||||
HeapPtrShape shape_;
|
||||
|
||||
ICSetElem_TypedArray(JitCode *stubCode, HandleShape shape, uint32_t type,
|
||||
ICSetElem_TypedArray(JitCode *stubCode, HandleShape shape, Scalar::Type type,
|
||||
bool expectOutOfBounds);
|
||||
|
||||
public:
|
||||
static inline ICSetElem_TypedArray *New(ICStubSpace *space, JitCode *code,
|
||||
HandleShape shape, uint32_t type,
|
||||
HandleShape shape, Scalar::Type type,
|
||||
bool expectOutOfBounds)
|
||||
{
|
||||
if (!code)
|
||||
@ -3735,8 +3735,8 @@ class ICSetElem_TypedArray : public ICStub
|
||||
return space->allocate<ICSetElem_TypedArray>(code, shape, type, expectOutOfBounds);
|
||||
}
|
||||
|
||||
uint32_t type() const {
|
||||
return extra_ & 0xff;
|
||||
Scalar::Type type() const {
|
||||
return (Scalar::Type) (extra_ & 0xff);
|
||||
}
|
||||
|
||||
bool expectOutOfBounds() const {
|
||||
@ -3753,7 +3753,7 @@ class ICSetElem_TypedArray : public ICStub
|
||||
|
||||
class Compiler : public ICStubCompiler {
|
||||
RootedShape shape_;
|
||||
uint32_t type_;
|
||||
Scalar::Type type_;
|
||||
bool expectOutOfBounds_;
|
||||
|
||||
protected:
|
||||
@ -3765,7 +3765,7 @@ class ICSetElem_TypedArray : public ICStub
|
||||
}
|
||||
|
||||
public:
|
||||
Compiler(JSContext *cx, Shape *shape, uint32_t type, bool expectOutOfBounds)
|
||||
Compiler(JSContext *cx, Shape *shape, Scalar::Type type, bool expectOutOfBounds)
|
||||
: ICStubCompiler(cx, ICStub::SetElem_TypedArray),
|
||||
shape_(cx, shape),
|
||||
type_(type),
|
||||
|
@ -7870,8 +7870,8 @@ CodeGenerator::visitLoadTypedArrayElement(LLoadTypedArrayElement *lir)
|
||||
Register temp = lir->temp()->isBogusTemp() ? InvalidReg : ToRegister(lir->temp());
|
||||
AnyRegister out = ToAnyRegister(lir->output());
|
||||
|
||||
int arrayType = lir->mir()->arrayType();
|
||||
int width = TypedArrayObject::slotWidth(arrayType);
|
||||
Scalar::Type arrayType = lir->mir()->arrayType();
|
||||
int width = Scalar::byteSize(arrayType);
|
||||
|
||||
Label fail;
|
||||
if (lir->index()->isConstant()) {
|
||||
@ -7909,8 +7909,8 @@ CodeGenerator::visitLoadTypedArrayElementHole(LLoadTypedArrayElementHole *lir)
|
||||
masm.bind(&inbounds);
|
||||
masm.loadPtr(Address(object, TypedArrayObject::dataOffset()), scratch);
|
||||
|
||||
int arrayType = lir->mir()->arrayType();
|
||||
int width = TypedArrayObject::slotWidth(arrayType);
|
||||
Scalar::Type arrayType = lir->mir()->arrayType();
|
||||
int width = Scalar::byteSize(arrayType);
|
||||
|
||||
Label fail;
|
||||
if (key.isConstant()) {
|
||||
@ -7932,11 +7932,9 @@ CodeGenerator::visitLoadTypedArrayElementHole(LLoadTypedArrayElementHole *lir)
|
||||
|
||||
template <typename T>
|
||||
static inline void
|
||||
StoreToTypedArray(MacroAssembler &masm, int arrayType, const LAllocation *value, const T &dest)
|
||||
StoreToTypedArray(MacroAssembler &masm, Scalar::Type arrayType, const LAllocation *value, const T &dest)
|
||||
{
|
||||
if (arrayType == ScalarTypeDescr::TYPE_FLOAT32 ||
|
||||
arrayType == ScalarTypeDescr::TYPE_FLOAT64)
|
||||
{
|
||||
if (arrayType == Scalar::Float32 || arrayType == Scalar::Float64) {
|
||||
masm.storeToTypedFloatArray(arrayType, ToFloatRegister(value), dest);
|
||||
} else {
|
||||
if (value->isConstant())
|
||||
@ -7952,8 +7950,8 @@ CodeGenerator::visitStoreTypedArrayElement(LStoreTypedArrayElement *lir)
|
||||
Register elements = ToRegister(lir->elements());
|
||||
const LAllocation *value = lir->value();
|
||||
|
||||
int arrayType = lir->mir()->arrayType();
|
||||
int width = TypedArrayObject::slotWidth(arrayType);
|
||||
Scalar::Type arrayType = lir->mir()->arrayType();
|
||||
int width = Scalar::byteSize(arrayType);
|
||||
|
||||
if (lir->index()->isConstant()) {
|
||||
Address dest(elements, ToInt32(lir->index()) * width);
|
||||
@ -7972,8 +7970,8 @@ CodeGenerator::visitStoreTypedArrayElementHole(LStoreTypedArrayElementHole *lir)
|
||||
Register elements = ToRegister(lir->elements());
|
||||
const LAllocation *value = lir->value();
|
||||
|
||||
int arrayType = lir->mir()->arrayType();
|
||||
int width = TypedArrayObject::slotWidth(arrayType);
|
||||
Scalar::Type arrayType = lir->mir()->arrayType();
|
||||
int width = Scalar::byteSize(arrayType);
|
||||
|
||||
bool guardLength = true;
|
||||
if (lir->index()->isConstant() && lir->length()->isConstant()) {
|
||||
|
@ -6823,8 +6823,7 @@ IonBuilder::getElemTryTypedObject(bool *emitted, MDefinition *obj, MDefinition *
|
||||
}
|
||||
|
||||
static MIRType
|
||||
MIRTypeForTypedArrayRead(ScalarTypeDescr::Type arrayType,
|
||||
bool observedDouble);
|
||||
MIRTypeForTypedArrayRead(Scalar::Type arrayType, bool observedDouble);
|
||||
|
||||
bool
|
||||
IonBuilder::checkTypedObjectIndexInBounds(int32_t elemSize,
|
||||
@ -7067,7 +7066,7 @@ IonBuilder::getElemTryTypedStatic(bool *emitted, MDefinition *obj, MDefinition *
|
||||
{
|
||||
JS_ASSERT(*emitted == false);
|
||||
|
||||
ScalarTypeDescr::Type arrayType;
|
||||
Scalar::Type arrayType;
|
||||
if (!ElementAccessIsTypedArray(obj, index, &arrayType))
|
||||
return true;
|
||||
|
||||
@ -7091,8 +7090,8 @@ IonBuilder::getElemTryTypedStatic(bool *emitted, MDefinition *obj, MDefinition *
|
||||
return true;
|
||||
|
||||
// LoadTypedArrayElementStatic currently treats uint32 arrays as int32.
|
||||
ArrayBufferView::ViewType viewType = (ArrayBufferView::ViewType) tarr->type();
|
||||
if (viewType == ArrayBufferView::TYPE_UINT32)
|
||||
Scalar::Type viewType = tarr->type();
|
||||
if (viewType == Scalar::Uint32)
|
||||
return true;
|
||||
|
||||
MDefinition *ptr = convertShiftToMaskForStaticTypedArray(index, viewType);
|
||||
@ -7114,7 +7113,7 @@ IonBuilder::getElemTryTypedStatic(bool *emitted, MDefinition *obj, MDefinition *
|
||||
// analysis picks up some of these cases, but is incomplete with respect
|
||||
// to others. For now, sniff the bytecode for simple patterns following
|
||||
// the load which guarantee a truncation or numeric conversion.
|
||||
if (viewType == ArrayBufferView::TYPE_FLOAT32 || viewType == ArrayBufferView::TYPE_FLOAT64) {
|
||||
if (viewType == Scalar::Float32 || viewType == Scalar::Float64) {
|
||||
jsbytecode *next = pc + JSOP_GETELEM_LENGTH;
|
||||
if (*next == JSOP_POS)
|
||||
load->setInfallible();
|
||||
@ -7133,7 +7132,7 @@ IonBuilder::getElemTryTypedArray(bool *emitted, MDefinition *obj, MDefinition *i
|
||||
{
|
||||
JS_ASSERT(*emitted == false);
|
||||
|
||||
ScalarTypeDescr::Type arrayType;
|
||||
Scalar::Type arrayType;
|
||||
if (!ElementAccessIsTypedArray(obj, index, &arrayType))
|
||||
return true;
|
||||
|
||||
@ -7505,7 +7504,7 @@ IonBuilder::addTypedArrayLengthAndData(MDefinition *obj,
|
||||
|
||||
MDefinition *
|
||||
IonBuilder::convertShiftToMaskForStaticTypedArray(MDefinition *id,
|
||||
ArrayBufferView::ViewType viewType)
|
||||
Scalar::Type viewType)
|
||||
{
|
||||
// No shifting is necessary if the typed array has single byte elements.
|
||||
if (TypedArrayShift(viewType) == 0)
|
||||
@ -7543,30 +7542,31 @@ IonBuilder::convertShiftToMaskForStaticTypedArray(MDefinition *id,
|
||||
}
|
||||
|
||||
static MIRType
|
||||
MIRTypeForTypedArrayRead(ScalarTypeDescr::Type arrayType,
|
||||
bool observedDouble)
|
||||
MIRTypeForTypedArrayRead(Scalar::Type arrayType, bool observedDouble)
|
||||
{
|
||||
switch (arrayType) {
|
||||
case ScalarTypeDescr::TYPE_INT8:
|
||||
case ScalarTypeDescr::TYPE_UINT8:
|
||||
case ScalarTypeDescr::TYPE_UINT8_CLAMPED:
|
||||
case ScalarTypeDescr::TYPE_INT16:
|
||||
case ScalarTypeDescr::TYPE_UINT16:
|
||||
case ScalarTypeDescr::TYPE_INT32:
|
||||
case Scalar::Int8:
|
||||
case Scalar::Uint8:
|
||||
case Scalar::Uint8Clamped:
|
||||
case Scalar::Int16:
|
||||
case Scalar::Uint16:
|
||||
case Scalar::Int32:
|
||||
return MIRType_Int32;
|
||||
case ScalarTypeDescr::TYPE_UINT32:
|
||||
case Scalar::Uint32:
|
||||
return observedDouble ? MIRType_Double : MIRType_Int32;
|
||||
case ScalarTypeDescr::TYPE_FLOAT32:
|
||||
case Scalar::Float32:
|
||||
return (LIRGenerator::allowFloat32Optimizations()) ? MIRType_Float32 : MIRType_Double;
|
||||
case ScalarTypeDescr::TYPE_FLOAT64:
|
||||
case Scalar::Float64:
|
||||
return MIRType_Double;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
MOZ_ASSUME_UNREACHABLE("Unknown typed array type");
|
||||
}
|
||||
|
||||
bool
|
||||
IonBuilder::jsop_getelem_typed(MDefinition *obj, MDefinition *index,
|
||||
ScalarTypeDescr::Type arrayType)
|
||||
Scalar::Type arrayType)
|
||||
{
|
||||
types::TemporaryTypeSet *types = bytecodeTypes(pc);
|
||||
|
||||
@ -7613,18 +7613,18 @@ IonBuilder::jsop_getelem_typed(MDefinition *obj, MDefinition *index,
|
||||
// will bailout when we read a double.
|
||||
BarrierKind barrier = BarrierKind::TypeSet;
|
||||
switch (arrayType) {
|
||||
case ScalarTypeDescr::TYPE_INT8:
|
||||
case ScalarTypeDescr::TYPE_UINT8:
|
||||
case ScalarTypeDescr::TYPE_UINT8_CLAMPED:
|
||||
case ScalarTypeDescr::TYPE_INT16:
|
||||
case ScalarTypeDescr::TYPE_UINT16:
|
||||
case ScalarTypeDescr::TYPE_INT32:
|
||||
case ScalarTypeDescr::TYPE_UINT32:
|
||||
case Scalar::Int8:
|
||||
case Scalar::Uint8:
|
||||
case Scalar::Uint8Clamped:
|
||||
case Scalar::Int16:
|
||||
case Scalar::Uint16:
|
||||
case Scalar::Int32:
|
||||
case Scalar::Uint32:
|
||||
if (types->hasType(types::Type::Int32Type()))
|
||||
barrier = BarrierKind::NoBarrier;
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_FLOAT32:
|
||||
case ScalarTypeDescr::TYPE_FLOAT64:
|
||||
case Scalar::Float32:
|
||||
case Scalar::Float64:
|
||||
if (allowDouble)
|
||||
barrier = BarrierKind::NoBarrier;
|
||||
break;
|
||||
@ -7767,7 +7767,7 @@ IonBuilder::setElemTryTypedStatic(bool *emitted, MDefinition *object,
|
||||
{
|
||||
JS_ASSERT(*emitted == false);
|
||||
|
||||
ScalarTypeDescr::Type arrayType;
|
||||
Scalar::Type arrayType;
|
||||
if (!ElementAccessIsTypedArray(object, index, &arrayType))
|
||||
return true;
|
||||
|
||||
@ -7794,7 +7794,7 @@ IonBuilder::setElemTryTypedStatic(bool *emitted, MDefinition *object,
|
||||
if (tarrType->unknownProperties())
|
||||
return true;
|
||||
|
||||
ArrayBufferView::ViewType viewType = (ArrayBufferView::ViewType) tarr->type();
|
||||
Scalar::Type viewType = tarr->type();
|
||||
MDefinition *ptr = convertShiftToMaskForStaticTypedArray(index, viewType);
|
||||
if (!ptr)
|
||||
return true;
|
||||
@ -7807,7 +7807,7 @@ IonBuilder::setElemTryTypedStatic(bool *emitted, MDefinition *object,
|
||||
|
||||
// Clamp value to [0, 255] for Uint8ClampedArray.
|
||||
MDefinition *toWrite = value;
|
||||
if (viewType == ArrayBufferView::TYPE_UINT8_CLAMPED) {
|
||||
if (viewType == Scalar::Uint8Clamped) {
|
||||
toWrite = MClampToUint8::New(alloc(), value);
|
||||
current->add(toWrite->toInstruction());
|
||||
}
|
||||
@ -7829,7 +7829,7 @@ IonBuilder::setElemTryTypedArray(bool *emitted, MDefinition *object,
|
||||
{
|
||||
JS_ASSERT(*emitted == false);
|
||||
|
||||
ScalarTypeDescr::Type arrayType;
|
||||
Scalar::Type arrayType;
|
||||
if (!ElementAccessIsTypedArray(object, index, &arrayType))
|
||||
return true;
|
||||
|
||||
@ -8053,8 +8053,7 @@ IonBuilder::jsop_setelem_dense(types::TemporaryTypeSet::DoubleConversion convers
|
||||
|
||||
|
||||
bool
|
||||
IonBuilder::jsop_setelem_typed(ScalarTypeDescr::Type arrayType,
|
||||
SetElemSafety safety,
|
||||
IonBuilder::jsop_setelem_typed(Scalar::Type arrayType, SetElemSafety safety,
|
||||
MDefinition *obj, MDefinition *id, MDefinition *value)
|
||||
{
|
||||
bool expectOOB;
|
||||
@ -8083,7 +8082,7 @@ IonBuilder::jsop_setelem_typed(ScalarTypeDescr::Type arrayType,
|
||||
|
||||
// Clamp value to [0, 255] for Uint8ClampedArray.
|
||||
MDefinition *toWrite = value;
|
||||
if (arrayType == ScalarTypeDescr::TYPE_UINT8_CLAMPED) {
|
||||
if (arrayType == Scalar::Uint8Clamped) {
|
||||
toWrite = MClampToUint8::New(alloc(), value);
|
||||
current->add(toWrite->toInstruction());
|
||||
}
|
||||
@ -8109,9 +8108,7 @@ IonBuilder::jsop_setelem_typed(ScalarTypeDescr::Type arrayType,
|
||||
}
|
||||
|
||||
bool
|
||||
IonBuilder::jsop_setelem_typed_object(ScalarTypeDescr::Type arrayType,
|
||||
SetElemSafety safety,
|
||||
bool racy,
|
||||
IonBuilder::jsop_setelem_typed_object(Scalar::Type arrayType, SetElemSafety safety, bool racy,
|
||||
MDefinition *object, MDefinition *index, MDefinition *value)
|
||||
{
|
||||
JS_ASSERT(safety == SetElem_Unsafe); // Can be fixed, but there's been no reason to as of yet
|
||||
@ -8812,7 +8809,7 @@ IonBuilder::getPropTryScalarPropOfTypedObject(bool *emitted, MDefinition *typedO
|
||||
types::TemporaryTypeSet *resultTypes)
|
||||
{
|
||||
// Must always be loading the same scalar type
|
||||
ScalarTypeDescr::Type fieldType = fieldPrediction.scalarType();
|
||||
Scalar::Type fieldType = fieldPrediction.scalarType();
|
||||
|
||||
// OK, perform the optimization.
|
||||
return pushScalarLoadFromTypedObject(emitted, typedObj, constantInt(fieldOffset),
|
||||
@ -9447,7 +9444,7 @@ IonBuilder::setPropTryScalarPropOfTypedObject(bool *emitted,
|
||||
TypedObjectPrediction fieldPrediction)
|
||||
{
|
||||
// Must always be loading the same scalar type
|
||||
ScalarTypeDescr::Type fieldType = fieldPrediction.scalarType();
|
||||
Scalar::Type fieldType = fieldPrediction.scalarType();
|
||||
|
||||
// OK! Perform the optimization.
|
||||
|
||||
@ -10512,7 +10509,7 @@ IonBuilder::storeScalarTypedObjectValue(MDefinition *typedObj,
|
||||
|
||||
// Clamp value to [0, 255] when type is Uint8Clamped
|
||||
MDefinition *toWrite = value;
|
||||
if (type == ScalarTypeDescr::TYPE_UINT8_CLAMPED) {
|
||||
if (type == Scalar::Uint8Clamped) {
|
||||
toWrite = MClampToUint8::New(alloc(), value);
|
||||
current->add(toWrite->toInstruction());
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ class IonBuilder : public MIRGenerator
|
||||
MInstruction *addShapeGuard(MDefinition *obj, Shape *const shape, BailoutKind bailoutKind);
|
||||
|
||||
MDefinition *convertShiftToMaskForStaticTypedArray(MDefinition *id,
|
||||
ArrayBufferView::ViewType viewType);
|
||||
Scalar::Type viewType);
|
||||
|
||||
bool invalidatedIdempotentCache();
|
||||
|
||||
|
@ -1083,7 +1083,7 @@ GenerateTypedArrayLength(JSContext *cx, MacroAssembler &masm, IonCache::StubAtta
|
||||
masm.branchPtr(Assembler::Below, tmpReg, ImmPtr(&TypedArrayObject::classes[0]),
|
||||
&failures);
|
||||
masm.branchPtr(Assembler::AboveOrEqual, tmpReg,
|
||||
ImmPtr(&TypedArrayObject::classes[ScalarTypeDescr::TYPE_MAX]),
|
||||
ImmPtr(&TypedArrayObject::classes[Scalar::TypeMax]),
|
||||
&failures);
|
||||
|
||||
// Load length.
|
||||
@ -3174,11 +3174,8 @@ GetElementIC::canAttachTypedArrayElement(JSObject *obj, const Value &idval,
|
||||
// The output register is not yet specialized as a float register, the only
|
||||
// way to accept float typed arrays for now is to return a Value type.
|
||||
uint32_t arrayType = obj->as<TypedArrayObject>().type();
|
||||
if (arrayType == ScalarTypeDescr::TYPE_FLOAT32 ||
|
||||
arrayType == ScalarTypeDescr::TYPE_FLOAT64)
|
||||
{
|
||||
if (arrayType == Scalar::Float32 || arrayType == Scalar::Float64)
|
||||
return output.hasValue();
|
||||
}
|
||||
|
||||
return output.hasValue() || !output.typedReg().isFloat();
|
||||
}
|
||||
@ -3194,7 +3191,7 @@ GenerateGetTypedArrayElement(JSContext *cx, MacroAssembler &masm, IonCache::Stub
|
||||
Label failures;
|
||||
|
||||
// The array type is the object within the table of typed array classes.
|
||||
int arrayType = tarr->type();
|
||||
Scalar::Type arrayType = tarr->type();
|
||||
|
||||
// Guard on the shape.
|
||||
Shape *shape = tarr->lastProperty();
|
||||
@ -3267,7 +3264,7 @@ GenerateGetTypedArrayElement(JSContext *cx, MacroAssembler &masm, IonCache::Stub
|
||||
|
||||
// Load the value. We use an invalid register because the destination
|
||||
// register is necessary a non double register.
|
||||
int width = TypedArrayObject::slotWidth(arrayType);
|
||||
int width = Scalar::byteSize(arrayType);
|
||||
BaseIndex source(elementReg, indexReg, ScaleFromElemWidth(width));
|
||||
if (output.hasValue()) {
|
||||
masm.loadFromTypedArray(arrayType, source, output.valueReg(), allowDoubleResult,
|
||||
@ -3733,11 +3730,11 @@ GenerateSetTypedArrayElement(JSContext *cx, MacroAssembler &masm, IonCache::Stub
|
||||
masm.loadPtr(Address(object, TypedArrayObject::dataOffset()), elements);
|
||||
|
||||
// Set the value.
|
||||
int arrayType = tarr->type();
|
||||
int width = TypedArrayObject::slotWidth(arrayType);
|
||||
Scalar::Type arrayType = tarr->type();
|
||||
int width = Scalar::byteSize(arrayType);
|
||||
BaseIndex target(elements, index, ScaleFromElemWidth(width));
|
||||
|
||||
if (arrayType == ScalarTypeDescr::TYPE_FLOAT32) {
|
||||
if (arrayType == Scalar::Float32) {
|
||||
FloatRegister ftemp;
|
||||
if (LIRGenerator::allowFloat32Optimizations()) {
|
||||
JS_ASSERT(tempFloat32 != InvalidFloatReg);
|
||||
@ -3750,7 +3747,7 @@ GenerateSetTypedArrayElement(JSContext *cx, MacroAssembler &masm, IonCache::Stub
|
||||
ftemp = tempDouble;
|
||||
}
|
||||
masm.storeToTypedFloatArray(arrayType, ftemp, target);
|
||||
} else if (arrayType == ScalarTypeDescr::TYPE_FLOAT64) {
|
||||
} else if (arrayType == Scalar::Float64) {
|
||||
if (!masm.convertConstantOrRegisterToDouble(cx, value, tempDouble, &failures))
|
||||
return false;
|
||||
masm.storeToTypedFloatArray(arrayType, tempDouble, target);
|
||||
@ -3760,7 +3757,7 @@ GenerateSetTypedArrayElement(JSContext *cx, MacroAssembler &masm, IonCache::Stub
|
||||
// afterwards.
|
||||
masm.push(object);
|
||||
|
||||
if (arrayType == ScalarTypeDescr::TYPE_UINT8_CLAMPED) {
|
||||
if (arrayType == Scalar::Uint8Clamped) {
|
||||
if (!masm.clampConstantOrRegisterToUint8(cx, value, tempDouble, object,
|
||||
&popObjectAndFail))
|
||||
{
|
||||
|
@ -277,7 +277,7 @@ static void
|
||||
StoreToTypedFloatArray(MacroAssembler &masm, int arrayType, const S &value, const T &dest)
|
||||
{
|
||||
switch (arrayType) {
|
||||
case ScalarTypeDescr::TYPE_FLOAT32:
|
||||
case Scalar::Float32:
|
||||
if (LIRGenerator::allowFloat32Optimizations()) {
|
||||
masm.storeFloat32(value, dest);
|
||||
} else {
|
||||
@ -289,7 +289,7 @@ StoreToTypedFloatArray(MacroAssembler &masm, int arrayType, const S &value, cons
|
||||
masm.storeFloat32(ScratchFloat32Reg, dest);
|
||||
}
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_FLOAT64:
|
||||
case Scalar::Float64:
|
||||
#ifdef JS_MORE_DETERMINISTIC
|
||||
// See the comment in TypedArrayObjectTemplate::doubleToNative.
|
||||
masm.canonicalizeDouble(value);
|
||||
@ -302,13 +302,13 @@ StoreToTypedFloatArray(MacroAssembler &masm, int arrayType, const S &value, cons
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::storeToTypedFloatArray(int arrayType, FloatRegister value,
|
||||
MacroAssembler::storeToTypedFloatArray(Scalar::Type arrayType, FloatRegister value,
|
||||
const BaseIndex &dest)
|
||||
{
|
||||
StoreToTypedFloatArray(*this, arrayType, value, dest);
|
||||
}
|
||||
void
|
||||
MacroAssembler::storeToTypedFloatArray(int arrayType, FloatRegister value,
|
||||
MacroAssembler::storeToTypedFloatArray(Scalar::Type arrayType, FloatRegister value,
|
||||
const Address &dest)
|
||||
{
|
||||
StoreToTypedFloatArray(*this, arrayType, value, dest);
|
||||
@ -316,27 +316,27 @@ MacroAssembler::storeToTypedFloatArray(int arrayType, FloatRegister value,
|
||||
|
||||
template<typename T>
|
||||
void
|
||||
MacroAssembler::loadFromTypedArray(int arrayType, const T &src, AnyRegister dest, Register temp,
|
||||
MacroAssembler::loadFromTypedArray(Scalar::Type arrayType, const T &src, AnyRegister dest, Register temp,
|
||||
Label *fail)
|
||||
{
|
||||
switch (arrayType) {
|
||||
case ScalarTypeDescr::TYPE_INT8:
|
||||
case Scalar::Int8:
|
||||
load8SignExtend(src, dest.gpr());
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT8:
|
||||
case ScalarTypeDescr::TYPE_UINT8_CLAMPED:
|
||||
case Scalar::Uint8:
|
||||
case Scalar::Uint8Clamped:
|
||||
load8ZeroExtend(src, dest.gpr());
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_INT16:
|
||||
case Scalar::Int16:
|
||||
load16SignExtend(src, dest.gpr());
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT16:
|
||||
case Scalar::Uint16:
|
||||
load16ZeroExtend(src, dest.gpr());
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_INT32:
|
||||
case Scalar::Int32:
|
||||
load32(src, dest.gpr());
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT32:
|
||||
case Scalar::Uint32:
|
||||
if (dest.isFloat()) {
|
||||
load32(src, temp);
|
||||
convertUInt32ToDouble(temp, dest.fpu());
|
||||
@ -349,7 +349,7 @@ MacroAssembler::loadFromTypedArray(int arrayType, const T &src, AnyRegister dest
|
||||
branchTest32(Assembler::Signed, dest.gpr(), dest.gpr(), fail);
|
||||
}
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_FLOAT32:
|
||||
case Scalar::Float32:
|
||||
if (LIRGenerator::allowFloat32Optimizations()) {
|
||||
loadFloat32(src, dest.fpu());
|
||||
canonicalizeFloat(dest.fpu());
|
||||
@ -358,7 +358,7 @@ MacroAssembler::loadFromTypedArray(int arrayType, const T &src, AnyRegister dest
|
||||
canonicalizeDouble(dest.fpu());
|
||||
}
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_FLOAT64:
|
||||
case Scalar::Float64:
|
||||
loadDouble(src, dest.fpu());
|
||||
canonicalizeDouble(dest.fpu());
|
||||
break;
|
||||
@ -367,27 +367,27 @@ MacroAssembler::loadFromTypedArray(int arrayType, const T &src, AnyRegister dest
|
||||
}
|
||||
}
|
||||
|
||||
template void MacroAssembler::loadFromTypedArray(int arrayType, const Address &src, AnyRegister dest,
|
||||
template void MacroAssembler::loadFromTypedArray(Scalar::Type arrayType, const Address &src, AnyRegister dest,
|
||||
Register temp, Label *fail);
|
||||
template void MacroAssembler::loadFromTypedArray(int arrayType, const BaseIndex &src, AnyRegister dest,
|
||||
template void MacroAssembler::loadFromTypedArray(Scalar::Type arrayType, const BaseIndex &src, AnyRegister dest,
|
||||
Register temp, Label *fail);
|
||||
|
||||
template<typename T>
|
||||
void
|
||||
MacroAssembler::loadFromTypedArray(int arrayType, const T &src, const ValueOperand &dest,
|
||||
MacroAssembler::loadFromTypedArray(Scalar::Type arrayType, const T &src, const ValueOperand &dest,
|
||||
bool allowDouble, Register temp, Label *fail)
|
||||
{
|
||||
switch (arrayType) {
|
||||
case ScalarTypeDescr::TYPE_INT8:
|
||||
case ScalarTypeDescr::TYPE_UINT8:
|
||||
case ScalarTypeDescr::TYPE_UINT8_CLAMPED:
|
||||
case ScalarTypeDescr::TYPE_INT16:
|
||||
case ScalarTypeDescr::TYPE_UINT16:
|
||||
case ScalarTypeDescr::TYPE_INT32:
|
||||
case Scalar::Int8:
|
||||
case Scalar::Uint8:
|
||||
case Scalar::Uint8Clamped:
|
||||
case Scalar::Int16:
|
||||
case Scalar::Uint16:
|
||||
case Scalar::Int32:
|
||||
loadFromTypedArray(arrayType, src, AnyRegister(dest.scratchReg()), InvalidReg, nullptr);
|
||||
tagValue(JSVAL_TYPE_INT32, dest.scratchReg(), dest);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT32:
|
||||
case Scalar::Uint32:
|
||||
// Don't clobber dest when we could fail, instead use temp.
|
||||
load32(src, temp);
|
||||
if (allowDouble) {
|
||||
@ -411,14 +411,14 @@ MacroAssembler::loadFromTypedArray(int arrayType, const T &src, const ValueOpera
|
||||
tagValue(JSVAL_TYPE_INT32, temp, dest);
|
||||
}
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_FLOAT32:
|
||||
case Scalar::Float32:
|
||||
loadFromTypedArray(arrayType, src, AnyRegister(ScratchFloat32Reg), dest.scratchReg(),
|
||||
nullptr);
|
||||
if (LIRGenerator::allowFloat32Optimizations())
|
||||
convertFloat32ToDouble(ScratchFloat32Reg, ScratchDoubleReg);
|
||||
boxDouble(ScratchDoubleReg, dest);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_FLOAT64:
|
||||
case Scalar::Float64:
|
||||
loadFromTypedArray(arrayType, src, AnyRegister(ScratchDoubleReg), dest.scratchReg(),
|
||||
nullptr);
|
||||
boxDouble(ScratchDoubleReg, dest);
|
||||
@ -428,9 +428,9 @@ MacroAssembler::loadFromTypedArray(int arrayType, const T &src, const ValueOpera
|
||||
}
|
||||
}
|
||||
|
||||
template void MacroAssembler::loadFromTypedArray(int arrayType, const Address &src, const ValueOperand &dest,
|
||||
template void MacroAssembler::loadFromTypedArray(Scalar::Type arrayType, const Address &src, const ValueOperand &dest,
|
||||
bool allowDouble, Register temp, Label *fail);
|
||||
template void MacroAssembler::loadFromTypedArray(int arrayType, const BaseIndex &src, const ValueOperand &dest,
|
||||
template void MacroAssembler::loadFromTypedArray(Scalar::Type arrayType, const BaseIndex &src, const ValueOperand &dest,
|
||||
bool allowDouble, Register temp, Label *fail);
|
||||
|
||||
// Inlined version of gc::CheckAllocatorState that checks the bare essentials
|
||||
|
@ -708,26 +708,26 @@ class MacroAssembler : public MacroAssemblerSpecific
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void loadFromTypedArray(int arrayType, const T &src, AnyRegister dest, Register temp, Label *fail);
|
||||
void loadFromTypedArray(Scalar::Type arrayType, const T &src, AnyRegister dest, Register temp, Label *fail);
|
||||
|
||||
template<typename T>
|
||||
void loadFromTypedArray(int arrayType, const T &src, const ValueOperand &dest, bool allowDouble,
|
||||
void loadFromTypedArray(Scalar::Type arrayType, const T &src, const ValueOperand &dest, bool allowDouble,
|
||||
Register temp, Label *fail);
|
||||
|
||||
template<typename S, typename T>
|
||||
void storeToTypedIntArray(int arrayType, const S &value, const T &dest) {
|
||||
void storeToTypedIntArray(Scalar::Type arrayType, const S &value, const T &dest) {
|
||||
switch (arrayType) {
|
||||
case ScalarTypeDescr::TYPE_INT8:
|
||||
case ScalarTypeDescr::TYPE_UINT8:
|
||||
case ScalarTypeDescr::TYPE_UINT8_CLAMPED:
|
||||
case Scalar::Int8:
|
||||
case Scalar::Uint8:
|
||||
case Scalar::Uint8Clamped:
|
||||
store8(value, dest);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_INT16:
|
||||
case ScalarTypeDescr::TYPE_UINT16:
|
||||
case Scalar::Int16:
|
||||
case Scalar::Uint16:
|
||||
store16(value, dest);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_INT32:
|
||||
case ScalarTypeDescr::TYPE_UINT32:
|
||||
case Scalar::Int32:
|
||||
case Scalar::Uint32:
|
||||
store32(value, dest);
|
||||
break;
|
||||
default:
|
||||
@ -735,8 +735,8 @@ class MacroAssembler : public MacroAssemblerSpecific
|
||||
}
|
||||
}
|
||||
|
||||
void storeToTypedFloatArray(int arrayType, FloatRegister value, const BaseIndex &dest);
|
||||
void storeToTypedFloatArray(int arrayType, FloatRegister value, const Address &dest);
|
||||
void storeToTypedFloatArray(Scalar::Type arrayType, FloatRegister value, const BaseIndex &dest);
|
||||
void storeToTypedFloatArray(Scalar::Type arrayType, FloatRegister value, const Address &dest);
|
||||
|
||||
Register extractString(const Address &address, Register scratch) {
|
||||
return extractObject(address, scratch);
|
||||
|
@ -2780,7 +2780,7 @@ LIRGenerator::visitLoadTypedArrayElement(MLoadTypedArrayElement *ins)
|
||||
|
||||
// We need a temp register for Uint32Array with known double result.
|
||||
LDefinition tempDef = LDefinition::BogusTemp();
|
||||
if (ins->arrayType() == ScalarTypeDescr::TYPE_UINT32 && IsFloatingPointType(ins->type()))
|
||||
if (ins->arrayType() == Scalar::Uint32 && IsFloatingPointType(ins->type()))
|
||||
tempDef = temp();
|
||||
|
||||
LLoadTypedArrayElement *lir = new(alloc()) LLoadTypedArrayElement(elements, index, tempDef);
|
||||
@ -2856,9 +2856,9 @@ LIRGenerator::visitStoreTypedArrayElement(MStoreTypedArrayElement *ins)
|
||||
|
||||
if (ins->isFloatArray()) {
|
||||
DebugOnly<bool> optimizeFloat32 = allowFloat32Optimizations();
|
||||
JS_ASSERT_IF(optimizeFloat32 && ins->arrayType() == ScalarTypeDescr::TYPE_FLOAT32,
|
||||
JS_ASSERT_IF(optimizeFloat32 && ins->arrayType() == Scalar::Float32,
|
||||
ins->value()->type() == MIRType_Float32);
|
||||
JS_ASSERT_IF(!optimizeFloat32 || ins->arrayType() == ScalarTypeDescr::TYPE_FLOAT64,
|
||||
JS_ASSERT_IF(!optimizeFloat32 || ins->arrayType() == Scalar::Float64,
|
||||
ins->value()->type() == MIRType_Double);
|
||||
} else {
|
||||
JS_ASSERT(ins->value()->type() == MIRType_Int32);
|
||||
@ -2885,9 +2885,9 @@ LIRGenerator::visitStoreTypedArrayElementHole(MStoreTypedArrayElementHole *ins)
|
||||
|
||||
if (ins->isFloatArray()) {
|
||||
DebugOnly<bool> optimizeFloat32 = allowFloat32Optimizations();
|
||||
JS_ASSERT_IF(optimizeFloat32 && ins->arrayType() == ScalarTypeDescr::TYPE_FLOAT32,
|
||||
JS_ASSERT_IF(optimizeFloat32 && ins->arrayType() == Scalar::Float32,
|
||||
ins->value()->type() == MIRType_Float32);
|
||||
JS_ASSERT_IF(!optimizeFloat32 || ins->arrayType() == ScalarTypeDescr::TYPE_FLOAT64,
|
||||
JS_ASSERT_IF(!optimizeFloat32 || ins->arrayType() == Scalar::Float64,
|
||||
ins->value()->type() == MIRType_Double);
|
||||
} else {
|
||||
JS_ASSERT(ins->value()->type() == MIRType_Int32);
|
||||
|
@ -224,10 +224,8 @@ IonBuilder::inlineNativeGetter(CallInfo &callInfo, JSFunction *target)
|
||||
// typed array prototype, and make sure we are accessing the right one
|
||||
// for the type of the instance object.
|
||||
if (thisTypes) {
|
||||
ScalarTypeDescr::Type type = (ScalarTypeDescr::Type) thisTypes->getTypedArrayType();
|
||||
if (type != ScalarTypeDescr::TYPE_MAX &&
|
||||
TypedArrayObject::isOriginalLengthGetter(type, native))
|
||||
{
|
||||
Scalar::Type type = thisTypes->getTypedArrayType();
|
||||
if (type != Scalar::TypeMax && TypedArrayObject::isOriginalLengthGetter(type, native)) {
|
||||
MInstruction *length = addTypedArrayLength(callInfo.thisArg());
|
||||
current->push(length);
|
||||
return InliningStatus_Inlined;
|
||||
@ -1392,7 +1390,7 @@ IonBuilder::inlineUnsafePutElements(CallInfo &callInfo)
|
||||
|
||||
// We can only inline setelem on dense arrays that do not need type
|
||||
// barriers and on typed arrays and on typed object arrays.
|
||||
ScalarTypeDescr::Type arrayType;
|
||||
Scalar::Type arrayType;
|
||||
if ((!isDenseNative || writeNeedsBarrier) &&
|
||||
!ElementAccessIsTypedArray(obj, id, &arrayType) &&
|
||||
!elementAccessIsTypedObjectArrayOfScalarType(obj, id, &arrayType))
|
||||
@ -1422,7 +1420,7 @@ IonBuilder::inlineUnsafePutElements(CallInfo &callInfo)
|
||||
continue;
|
||||
}
|
||||
|
||||
ScalarTypeDescr::Type arrayType;
|
||||
Scalar::Type arrayType;
|
||||
if (ElementAccessIsTypedArray(obj, id, &arrayType)) {
|
||||
if (!inlineUnsafeSetTypedArrayElement(callInfo, base, arrayType))
|
||||
return InliningStatus_Error;
|
||||
@ -1443,7 +1441,7 @@ IonBuilder::inlineUnsafePutElements(CallInfo &callInfo)
|
||||
|
||||
bool
|
||||
IonBuilder::elementAccessIsTypedObjectArrayOfScalarType(MDefinition* obj, MDefinition* id,
|
||||
ScalarTypeDescr::Type *arrayType)
|
||||
Scalar::Type *arrayType)
|
||||
{
|
||||
if (obj->type() != MIRType_Object) // lookupTypeDescrSet() tests for TypedObject
|
||||
return false;
|
||||
@ -1488,7 +1486,7 @@ IonBuilder::inlineUnsafeSetDenseArrayElement(CallInfo &callInfo, uint32_t base)
|
||||
bool
|
||||
IonBuilder::inlineUnsafeSetTypedArrayElement(CallInfo &callInfo,
|
||||
uint32_t base,
|
||||
ScalarTypeDescr::Type arrayType)
|
||||
Scalar::Type arrayType)
|
||||
{
|
||||
// Note: we do not check the conditions that are asserted as true
|
||||
// in intrinsic_UnsafePutElements():
|
||||
@ -1508,7 +1506,7 @@ IonBuilder::inlineUnsafeSetTypedArrayElement(CallInfo &callInfo,
|
||||
bool
|
||||
IonBuilder::inlineUnsafeSetTypedObjectArrayElement(CallInfo &callInfo,
|
||||
uint32_t base,
|
||||
ScalarTypeDescr::Type arrayType)
|
||||
Scalar::Type arrayType)
|
||||
{
|
||||
// Note: we do not check the conditions that are asserted as true
|
||||
// in intrinsic_UnsafePutElements():
|
||||
|
@ -3151,7 +3151,7 @@ jit::ElementAccessIsDenseNative(MDefinition *obj, MDefinition *id)
|
||||
|
||||
bool
|
||||
jit::ElementAccessIsTypedArray(MDefinition *obj, MDefinition *id,
|
||||
ScalarTypeDescr::Type *arrayType)
|
||||
Scalar::Type *arrayType)
|
||||
{
|
||||
if (obj->mightBeType(MIRType_String))
|
||||
return false;
|
||||
@ -3163,8 +3163,8 @@ jit::ElementAccessIsTypedArray(MDefinition *obj, MDefinition *id,
|
||||
if (!types)
|
||||
return false;
|
||||
|
||||
*arrayType = (ScalarTypeDescr::Type) types->getTypedArrayType();
|
||||
return *arrayType != ScalarTypeDescr::TYPE_MAX;
|
||||
*arrayType = types->getTypedArrayType();
|
||||
return *arrayType != Scalar::TypeMax;
|
||||
}
|
||||
|
||||
bool
|
||||
|
112
js/src/jit/MIR.h
112
js/src/jit/MIR.h
@ -6760,34 +6760,34 @@ class MArrayConcat
|
||||
class MLoadTypedArrayElement
|
||||
: public MBinaryInstruction
|
||||
{
|
||||
ScalarTypeDescr::Type arrayType_;
|
||||
Scalar::Type arrayType_;
|
||||
|
||||
MLoadTypedArrayElement(MDefinition *elements, MDefinition *index,
|
||||
ScalarTypeDescr::Type arrayType)
|
||||
Scalar::Type arrayType)
|
||||
: MBinaryInstruction(elements, index), arrayType_(arrayType)
|
||||
{
|
||||
setResultType(MIRType_Value);
|
||||
setMovable();
|
||||
JS_ASSERT(elements->type() == MIRType_Elements);
|
||||
JS_ASSERT(index->type() == MIRType_Int32);
|
||||
JS_ASSERT(arrayType >= 0 && arrayType < ScalarTypeDescr::TYPE_MAX);
|
||||
JS_ASSERT(arrayType >= 0 && arrayType < Scalar::TypeMax);
|
||||
}
|
||||
|
||||
public:
|
||||
INSTRUCTION_HEADER(LoadTypedArrayElement)
|
||||
|
||||
static MLoadTypedArrayElement *New(TempAllocator &alloc, MDefinition *elements, MDefinition *index,
|
||||
ScalarTypeDescr::Type arrayType)
|
||||
Scalar::Type arrayType)
|
||||
{
|
||||
return new(alloc) MLoadTypedArrayElement(elements, index, arrayType);
|
||||
}
|
||||
|
||||
ScalarTypeDescr::Type arrayType() const {
|
||||
Scalar::Type arrayType() const {
|
||||
return arrayType_;
|
||||
}
|
||||
bool fallible() const {
|
||||
// Bailout if the result does not fit in an int32.
|
||||
return arrayType_ == ScalarTypeDescr::TYPE_UINT32 && type() == MIRType_Int32;
|
||||
return arrayType_ == Scalar::Uint32 && type() == MIRType_Int32;
|
||||
}
|
||||
MDefinition *elements() const {
|
||||
return getOperand(0);
|
||||
@ -6812,7 +6812,7 @@ class MLoadTypedArrayElement
|
||||
|
||||
void computeRange(TempAllocator &alloc);
|
||||
|
||||
bool canProduceFloat32() const { return arrayType_ == ScalarTypeDescr::TYPE_FLOAT32; }
|
||||
bool canProduceFloat32() const { return arrayType_ == Scalar::Float32; }
|
||||
};
|
||||
|
||||
// Load a value from a typed array. Out-of-bounds accesses are handled in-line.
|
||||
@ -6820,35 +6820,35 @@ class MLoadTypedArrayElementHole
|
||||
: public MBinaryInstruction,
|
||||
public SingleObjectPolicy
|
||||
{
|
||||
int arrayType_;
|
||||
Scalar::Type arrayType_;
|
||||
bool allowDouble_;
|
||||
|
||||
MLoadTypedArrayElementHole(MDefinition *object, MDefinition *index, int arrayType, bool allowDouble)
|
||||
MLoadTypedArrayElementHole(MDefinition *object, MDefinition *index, Scalar::Type arrayType, bool allowDouble)
|
||||
: MBinaryInstruction(object, index), arrayType_(arrayType), allowDouble_(allowDouble)
|
||||
{
|
||||
setResultType(MIRType_Value);
|
||||
setMovable();
|
||||
JS_ASSERT(index->type() == MIRType_Int32);
|
||||
JS_ASSERT(arrayType >= 0 && arrayType < ScalarTypeDescr::TYPE_MAX);
|
||||
JS_ASSERT(arrayType >= 0 && arrayType < Scalar::TypeMax);
|
||||
}
|
||||
|
||||
public:
|
||||
INSTRUCTION_HEADER(LoadTypedArrayElementHole)
|
||||
|
||||
static MLoadTypedArrayElementHole *New(TempAllocator &alloc, MDefinition *object, MDefinition *index,
|
||||
int arrayType, bool allowDouble)
|
||||
Scalar::Type arrayType, bool allowDouble)
|
||||
{
|
||||
return new(alloc) MLoadTypedArrayElementHole(object, index, arrayType, allowDouble);
|
||||
}
|
||||
|
||||
int arrayType() const {
|
||||
Scalar::Type arrayType() const {
|
||||
return arrayType_;
|
||||
}
|
||||
bool allowDouble() const {
|
||||
return allowDouble_;
|
||||
}
|
||||
bool fallible() const {
|
||||
return arrayType_ == ScalarTypeDescr::TYPE_UINT32 && !allowDouble_;
|
||||
return arrayType_ == Scalar::Uint32 && !allowDouble_;
|
||||
}
|
||||
TypePolicy *typePolicy() {
|
||||
return this;
|
||||
@ -6872,7 +6872,7 @@ class MLoadTypedArrayElementHole
|
||||
AliasSet getAliasSet() const {
|
||||
return AliasSet::Load(AliasSet::TypedArrayElement);
|
||||
}
|
||||
bool canProduceFloat32() const { return arrayType_ == ScalarTypeDescr::TYPE_FLOAT32; }
|
||||
bool canProduceFloat32() const { return arrayType_ == Scalar::Float32; }
|
||||
};
|
||||
|
||||
// Load a value fallibly or infallibly from a statically known typed array.
|
||||
@ -6884,9 +6884,9 @@ class MLoadTypedArrayElementStatic
|
||||
: MUnaryInstruction(ptr), typedArray_(typedArray), fallible_(true)
|
||||
{
|
||||
int type = typedArray_->type();
|
||||
if (type == ScalarTypeDescr::TYPE_FLOAT32)
|
||||
if (type == Scalar::Float32)
|
||||
setResultType(MIRType_Float32);
|
||||
else if (type == ScalarTypeDescr::TYPE_FLOAT64)
|
||||
else if (type == Scalar::Float64)
|
||||
setResultType(MIRType_Double);
|
||||
else
|
||||
setResultType(MIRType_Int32);
|
||||
@ -6904,8 +6904,8 @@ class MLoadTypedArrayElementStatic
|
||||
return new(alloc) MLoadTypedArrayElementStatic(typedArray, ptr);
|
||||
}
|
||||
|
||||
ArrayBufferView::ViewType viewType() const {
|
||||
return (ArrayBufferView::ViewType) typedArray_->type();
|
||||
Scalar::Type viewType() const {
|
||||
return typedArray_->type();
|
||||
}
|
||||
void *base() const;
|
||||
size_t length() const;
|
||||
@ -6929,48 +6929,48 @@ class MLoadTypedArrayElementStatic
|
||||
|
||||
void computeRange(TempAllocator &alloc);
|
||||
bool truncate(TruncateKind kind);
|
||||
bool canProduceFloat32() const { return typedArray_->type() == ScalarTypeDescr::TYPE_FLOAT32; }
|
||||
bool canProduceFloat32() const { return typedArray_->type() == Scalar::Float32; }
|
||||
};
|
||||
|
||||
class MStoreTypedArrayElement
|
||||
: public MTernaryInstruction,
|
||||
public StoreTypedArrayPolicy
|
||||
{
|
||||
int arrayType_;
|
||||
Scalar::Type arrayType_;
|
||||
|
||||
// See note in MStoreElementCommon.
|
||||
bool racy_;
|
||||
|
||||
MStoreTypedArrayElement(MDefinition *elements, MDefinition *index, MDefinition *value,
|
||||
int arrayType)
|
||||
Scalar::Type arrayType)
|
||||
: MTernaryInstruction(elements, index, value), arrayType_(arrayType), racy_(false)
|
||||
{
|
||||
setMovable();
|
||||
JS_ASSERT(elements->type() == MIRType_Elements);
|
||||
JS_ASSERT(index->type() == MIRType_Int32);
|
||||
JS_ASSERT(arrayType >= 0 && arrayType < ScalarTypeDescr::TYPE_MAX);
|
||||
JS_ASSERT(arrayType >= 0 && arrayType < Scalar::TypeMax);
|
||||
}
|
||||
|
||||
public:
|
||||
INSTRUCTION_HEADER(StoreTypedArrayElement)
|
||||
|
||||
static MStoreTypedArrayElement *New(TempAllocator &alloc, MDefinition *elements, MDefinition *index,
|
||||
MDefinition *value, int arrayType)
|
||||
MDefinition *value, Scalar::Type arrayType)
|
||||
{
|
||||
return new(alloc) MStoreTypedArrayElement(elements, index, value, arrayType);
|
||||
}
|
||||
|
||||
int arrayType() const {
|
||||
Scalar::Type arrayType() const {
|
||||
return arrayType_;
|
||||
}
|
||||
bool isByteArray() const {
|
||||
return (arrayType_ == ScalarTypeDescr::TYPE_INT8 ||
|
||||
arrayType_ == ScalarTypeDescr::TYPE_UINT8 ||
|
||||
arrayType_ == ScalarTypeDescr::TYPE_UINT8_CLAMPED);
|
||||
return (arrayType_ == Scalar::Int8 ||
|
||||
arrayType_ == Scalar::Uint8 ||
|
||||
arrayType_ == Scalar::Uint8Clamped);
|
||||
}
|
||||
bool isFloatArray() const {
|
||||
return (arrayType_ == ScalarTypeDescr::TYPE_FLOAT32 ||
|
||||
arrayType_ == ScalarTypeDescr::TYPE_FLOAT64);
|
||||
return (arrayType_ == Scalar::Float32 ||
|
||||
arrayType_ == Scalar::Float64);
|
||||
}
|
||||
TypePolicy *typePolicy() {
|
||||
return this;
|
||||
@ -6996,7 +6996,7 @@ class MStoreTypedArrayElement
|
||||
TruncateKind operandTruncateKind(size_t index) const;
|
||||
|
||||
bool canConsumeFloat32(MUse *use) const {
|
||||
return use == getUseFor(2) && arrayType_ == ScalarTypeDescr::TYPE_FLOAT32;
|
||||
return use == getUseFor(2) && arrayType_ == Scalar::Float32;
|
||||
}
|
||||
};
|
||||
|
||||
@ -7004,10 +7004,10 @@ class MStoreTypedArrayElementHole
|
||||
: public MAryInstruction<4>,
|
||||
public StoreTypedArrayHolePolicy
|
||||
{
|
||||
int arrayType_;
|
||||
Scalar::Type arrayType_;
|
||||
|
||||
MStoreTypedArrayElementHole(MDefinition *elements, MDefinition *length, MDefinition *index,
|
||||
MDefinition *value, int arrayType)
|
||||
MDefinition *value, Scalar::Type arrayType)
|
||||
: MAryInstruction<4>(), arrayType_(arrayType)
|
||||
{
|
||||
initOperand(0, elements);
|
||||
@ -7018,7 +7018,7 @@ class MStoreTypedArrayElementHole
|
||||
JS_ASSERT(elements->type() == MIRType_Elements);
|
||||
JS_ASSERT(length->type() == MIRType_Int32);
|
||||
JS_ASSERT(index->type() == MIRType_Int32);
|
||||
JS_ASSERT(arrayType >= 0 && arrayType < ScalarTypeDescr::TYPE_MAX);
|
||||
JS_ASSERT(arrayType >= 0 && arrayType < Scalar::TypeMax);
|
||||
}
|
||||
|
||||
public:
|
||||
@ -7026,22 +7026,22 @@ class MStoreTypedArrayElementHole
|
||||
|
||||
static MStoreTypedArrayElementHole *New(TempAllocator &alloc, MDefinition *elements,
|
||||
MDefinition *length, MDefinition *index,
|
||||
MDefinition *value, int arrayType)
|
||||
MDefinition *value, Scalar::Type arrayType)
|
||||
{
|
||||
return new(alloc) MStoreTypedArrayElementHole(elements, length, index, value, arrayType);
|
||||
}
|
||||
|
||||
int arrayType() const {
|
||||
Scalar::Type arrayType() const {
|
||||
return arrayType_;
|
||||
}
|
||||
bool isByteArray() const {
|
||||
return (arrayType_ == ScalarTypeDescr::TYPE_INT8 ||
|
||||
arrayType_ == ScalarTypeDescr::TYPE_UINT8 ||
|
||||
arrayType_ == ScalarTypeDescr::TYPE_UINT8_CLAMPED);
|
||||
return (arrayType_ == Scalar::Int8 ||
|
||||
arrayType_ == Scalar::Uint8 ||
|
||||
arrayType_ == Scalar::Uint8Clamped);
|
||||
}
|
||||
bool isFloatArray() const {
|
||||
return (arrayType_ == ScalarTypeDescr::TYPE_FLOAT32 ||
|
||||
arrayType_ == ScalarTypeDescr::TYPE_FLOAT64);
|
||||
return (arrayType_ == Scalar::Float32 ||
|
||||
arrayType_ == Scalar::Float64);
|
||||
}
|
||||
TypePolicy *typePolicy() {
|
||||
return this;
|
||||
@ -7064,7 +7064,7 @@ class MStoreTypedArrayElementHole
|
||||
TruncateKind operandTruncateKind(size_t index) const;
|
||||
|
||||
bool canConsumeFloat32(MUse *use) const {
|
||||
return use == getUseFor(3) && arrayType_ == ScalarTypeDescr::TYPE_FLOAT32;
|
||||
return use == getUseFor(3) && arrayType_ == Scalar::Float32;
|
||||
}
|
||||
};
|
||||
|
||||
@ -7092,12 +7092,12 @@ class MStoreTypedArrayElementStatic :
|
||||
return this;
|
||||
}
|
||||
|
||||
ArrayBufferView::ViewType viewType() const {
|
||||
return (ArrayBufferView::ViewType) typedArray_->type();
|
||||
Scalar::Type viewType() const {
|
||||
return typedArray_->type();
|
||||
}
|
||||
bool isFloatArray() const {
|
||||
return (viewType() == ArrayBufferView::TYPE_FLOAT32 ||
|
||||
viewType() == ArrayBufferView::TYPE_FLOAT64);
|
||||
return (viewType() == Scalar::Float32 ||
|
||||
viewType() == Scalar::Float64);
|
||||
}
|
||||
|
||||
void *base() const;
|
||||
@ -7111,7 +7111,7 @@ class MStoreTypedArrayElementStatic :
|
||||
TruncateKind operandTruncateKind(size_t index) const;
|
||||
|
||||
bool canConsumeFloat32(MUse *use) const {
|
||||
return use == getUseFor(1) && typedArray_->type() == ScalarTypeDescr::TYPE_FLOAT32;
|
||||
return use == getUseFor(1) && typedArray_->type() == Scalar::Float32;
|
||||
}
|
||||
};
|
||||
|
||||
@ -10308,28 +10308,28 @@ class MAsmJSNeg : public MUnaryInstruction
|
||||
|
||||
class MAsmJSHeapAccess
|
||||
{
|
||||
ArrayBufferView::ViewType viewType_;
|
||||
Scalar::Type viewType_;
|
||||
bool skipBoundsCheck_;
|
||||
|
||||
public:
|
||||
MAsmJSHeapAccess(ArrayBufferView::ViewType vt, bool s)
|
||||
MAsmJSHeapAccess(Scalar::Type vt, bool s)
|
||||
: viewType_(vt), skipBoundsCheck_(s)
|
||||
{}
|
||||
|
||||
ArrayBufferView::ViewType viewType() const { return viewType_; }
|
||||
Scalar::Type viewType() const { return viewType_; }
|
||||
bool skipBoundsCheck() const { return skipBoundsCheck_; }
|
||||
void setSkipBoundsCheck(bool v) { skipBoundsCheck_ = v; }
|
||||
};
|
||||
|
||||
class MAsmJSLoadHeap : public MUnaryInstruction, public MAsmJSHeapAccess
|
||||
{
|
||||
MAsmJSLoadHeap(ArrayBufferView::ViewType vt, MDefinition *ptr)
|
||||
MAsmJSLoadHeap(Scalar::Type vt, MDefinition *ptr)
|
||||
: MUnaryInstruction(ptr), MAsmJSHeapAccess(vt, false)
|
||||
{
|
||||
setMovable();
|
||||
if (vt == ArrayBufferView::TYPE_FLOAT32)
|
||||
if (vt == Scalar::Float32)
|
||||
setResultType(MIRType_Float32);
|
||||
else if (vt == ArrayBufferView::TYPE_FLOAT64)
|
||||
else if (vt == Scalar::Float64)
|
||||
setResultType(MIRType_Double);
|
||||
else
|
||||
setResultType(MIRType_Int32);
|
||||
@ -10338,7 +10338,7 @@ class MAsmJSLoadHeap : public MUnaryInstruction, public MAsmJSHeapAccess
|
||||
public:
|
||||
INSTRUCTION_HEADER(AsmJSLoadHeap);
|
||||
|
||||
static MAsmJSLoadHeap *New(TempAllocator &alloc, ArrayBufferView::ViewType vt, MDefinition *ptr) {
|
||||
static MAsmJSLoadHeap *New(TempAllocator &alloc, Scalar::Type vt, MDefinition *ptr) {
|
||||
return new(alloc) MAsmJSLoadHeap(vt, ptr);
|
||||
}
|
||||
|
||||
@ -10353,14 +10353,14 @@ class MAsmJSLoadHeap : public MUnaryInstruction, public MAsmJSHeapAccess
|
||||
|
||||
class MAsmJSStoreHeap : public MBinaryInstruction, public MAsmJSHeapAccess
|
||||
{
|
||||
MAsmJSStoreHeap(ArrayBufferView::ViewType vt, MDefinition *ptr, MDefinition *v)
|
||||
MAsmJSStoreHeap(Scalar::Type vt, MDefinition *ptr, MDefinition *v)
|
||||
: MBinaryInstruction(ptr, v) , MAsmJSHeapAccess(vt, false)
|
||||
{}
|
||||
|
||||
public:
|
||||
INSTRUCTION_HEADER(AsmJSStoreHeap);
|
||||
|
||||
static MAsmJSStoreHeap *New(TempAllocator &alloc, ArrayBufferView::ViewType vt,
|
||||
static MAsmJSStoreHeap *New(TempAllocator &alloc, Scalar::Type vt,
|
||||
MDefinition *ptr, MDefinition *v)
|
||||
{
|
||||
return new(alloc) MAsmJSStoreHeap(vt, ptr, v);
|
||||
@ -10704,7 +10704,7 @@ typedef Vector<MDefinition *, 8, IonAllocPolicy> MDefinitionVector;
|
||||
|
||||
bool ElementAccessIsDenseNative(MDefinition *obj, MDefinition *id);
|
||||
bool ElementAccessIsTypedArray(MDefinition *obj, MDefinition *id,
|
||||
ScalarTypeDescr::Type *arrayType);
|
||||
Scalar::Type *arrayType);
|
||||
bool ElementAccessIsPacked(types::CompilerConstraintList *constraints, MDefinition *obj);
|
||||
bool ElementAccessHasExtraIndexedProperty(types::CompilerConstraintList *constraints,
|
||||
MDefinition *obj);
|
||||
|
@ -1452,23 +1452,23 @@ MLimitedTruncate::computeRange(TempAllocator &alloc)
|
||||
static Range *GetTypedArrayRange(TempAllocator &alloc, int type)
|
||||
{
|
||||
switch (type) {
|
||||
case ScalarTypeDescr::TYPE_UINT8_CLAMPED:
|
||||
case ScalarTypeDescr::TYPE_UINT8:
|
||||
case Scalar::Uint8Clamped:
|
||||
case Scalar::Uint8:
|
||||
return Range::NewUInt32Range(alloc, 0, UINT8_MAX);
|
||||
case ScalarTypeDescr::TYPE_UINT16:
|
||||
case Scalar::Uint16:
|
||||
return Range::NewUInt32Range(alloc, 0, UINT16_MAX);
|
||||
case ScalarTypeDescr::TYPE_UINT32:
|
||||
case Scalar::Uint32:
|
||||
return Range::NewUInt32Range(alloc, 0, UINT32_MAX);
|
||||
|
||||
case ScalarTypeDescr::TYPE_INT8:
|
||||
case Scalar::Int8:
|
||||
return Range::NewInt32Range(alloc, INT8_MIN, INT8_MAX);
|
||||
case ScalarTypeDescr::TYPE_INT16:
|
||||
case Scalar::Int16:
|
||||
return Range::NewInt32Range(alloc, INT16_MIN, INT16_MAX);
|
||||
case ScalarTypeDescr::TYPE_INT32:
|
||||
case Scalar::Int32:
|
||||
return Range::NewInt32Range(alloc, INT32_MIN, INT32_MAX);
|
||||
|
||||
case ScalarTypeDescr::TYPE_FLOAT32:
|
||||
case ScalarTypeDescr::TYPE_FLOAT64:
|
||||
case Scalar::Float32:
|
||||
case Scalar::Float64:
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1488,7 +1488,7 @@ MLoadTypedArrayElementStatic::computeRange(TempAllocator &alloc)
|
||||
{
|
||||
// We don't currently use MLoadTypedArrayElementStatic for uint32, so we
|
||||
// don't have to worry about it returning a value outside our type.
|
||||
JS_ASSERT(typedArray_->type() != ScalarTypeDescr::TYPE_UINT32);
|
||||
JS_ASSERT(typedArray_->type() != Scalar::Uint32);
|
||||
|
||||
setRange(GetTypedArrayRange(alloc, typedArray_->type()));
|
||||
}
|
||||
|
@ -761,22 +761,22 @@ StoreTypedArrayPolicy::adjustValueInput(TempAllocator &alloc, MInstruction *ins,
|
||||
value->type() == MIRType_Value);
|
||||
|
||||
switch (arrayType) {
|
||||
case ScalarTypeDescr::TYPE_INT8:
|
||||
case ScalarTypeDescr::TYPE_UINT8:
|
||||
case ScalarTypeDescr::TYPE_INT16:
|
||||
case ScalarTypeDescr::TYPE_UINT16:
|
||||
case ScalarTypeDescr::TYPE_INT32:
|
||||
case ScalarTypeDescr::TYPE_UINT32:
|
||||
case Scalar::Int8:
|
||||
case Scalar::Uint8:
|
||||
case Scalar::Int16:
|
||||
case Scalar::Uint16:
|
||||
case Scalar::Int32:
|
||||
case Scalar::Uint32:
|
||||
if (value->type() != MIRType_Int32) {
|
||||
value = MTruncateToInt32::New(alloc, value);
|
||||
ins->block()->insertBefore(ins, value->toInstruction());
|
||||
}
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT8_CLAMPED:
|
||||
case Scalar::Uint8Clamped:
|
||||
// IonBuilder should have inserted ClampToUint8.
|
||||
JS_ASSERT(value->type() == MIRType_Int32);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_FLOAT32:
|
||||
case Scalar::Float32:
|
||||
if (LIRGenerator::allowFloat32Optimizations()) {
|
||||
if (value->type() != MIRType_Float32) {
|
||||
value = MToFloat32::New(alloc, value);
|
||||
@ -786,7 +786,7 @@ StoreTypedArrayPolicy::adjustValueInput(TempAllocator &alloc, MInstruction *ins,
|
||||
}
|
||||
// Fallthrough: if the LIRGenerator cannot directly store Float32, it will expect the
|
||||
// stored value to be a double.
|
||||
case ScalarTypeDescr::TYPE_FLOAT64:
|
||||
case Scalar::Float64:
|
||||
if (value->type() != MIRType_Double) {
|
||||
value = MToDouble::New(alloc, value);
|
||||
ins->block()->insertBefore(ins, value->toInstruction());
|
||||
|
@ -1798,14 +1798,14 @@ CodeGeneratorARM::visitAsmJSLoadHeap(LAsmJSLoadHeap *ins)
|
||||
int size;
|
||||
bool isFloat = false;
|
||||
switch (mir->viewType()) {
|
||||
case ArrayBufferView::TYPE_INT8: isSigned = true; size = 8; break;
|
||||
case ArrayBufferView::TYPE_UINT8: isSigned = false; size = 8; break;
|
||||
case ArrayBufferView::TYPE_INT16: isSigned = true; size = 16; break;
|
||||
case ArrayBufferView::TYPE_UINT16: isSigned = false; size = 16; break;
|
||||
case ArrayBufferView::TYPE_INT32:
|
||||
case ArrayBufferView::TYPE_UINT32: isSigned = true; size = 32; break;
|
||||
case ArrayBufferView::TYPE_FLOAT64: isFloat = true; size = 64; break;
|
||||
case ArrayBufferView::TYPE_FLOAT32: isFloat = true; size = 32; break;
|
||||
case Scalar::Int8: isSigned = true; size = 8; break;
|
||||
case Scalar::Uint8: isSigned = false; size = 8; break;
|
||||
case Scalar::Int16: isSigned = true; size = 16; break;
|
||||
case Scalar::Uint16: isSigned = false; size = 16; break;
|
||||
case Scalar::Int32:
|
||||
case Scalar::Uint32: isSigned = true; size = 32; break;
|
||||
case Scalar::Float64: isFloat = true; size = 64; break;
|
||||
case Scalar::Float32: isFloat = true; size = 32; break;
|
||||
default: MOZ_ASSUME_UNREACHABLE("unexpected array type");
|
||||
}
|
||||
|
||||
@ -1872,14 +1872,14 @@ CodeGeneratorARM::visitAsmJSStoreHeap(LAsmJSStoreHeap *ins)
|
||||
int size;
|
||||
bool isFloat = false;
|
||||
switch (mir->viewType()) {
|
||||
case ArrayBufferView::TYPE_INT8:
|
||||
case ArrayBufferView::TYPE_UINT8: isSigned = false; size = 8; break;
|
||||
case ArrayBufferView::TYPE_INT16:
|
||||
case ArrayBufferView::TYPE_UINT16: isSigned = false; size = 16; break;
|
||||
case ArrayBufferView::TYPE_INT32:
|
||||
case ArrayBufferView::TYPE_UINT32: isSigned = true; size = 32; break;
|
||||
case ArrayBufferView::TYPE_FLOAT64: isFloat = true; size = 64; break;
|
||||
case ArrayBufferView::TYPE_FLOAT32: isFloat = true; size = 32; break;
|
||||
case Scalar::Int8:
|
||||
case Scalar::Uint8: isSigned = false; size = 8; break;
|
||||
case Scalar::Int16:
|
||||
case Scalar::Uint16: isSigned = false; size = 16; break;
|
||||
case Scalar::Int32:
|
||||
case Scalar::Uint32: isSigned = true; size = 32; break;
|
||||
case Scalar::Float64: isFloat = true; size = 64; break;
|
||||
case Scalar::Float32: isFloat = true; size = 32; break;
|
||||
default: MOZ_ASSUME_UNREACHABLE("unexpected array type");
|
||||
}
|
||||
const LAllocation *ptr = ins->ptr();
|
||||
|
@ -651,14 +651,14 @@ class AsmJSHeapAccess
|
||||
#if defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64)
|
||||
// If 'cmp' equals 'offset' or if it is not supplied then the
|
||||
// cmpDelta_ is zero indicating that there is no length to patch.
|
||||
AsmJSHeapAccess(uint32_t offset, uint32_t after, ArrayBufferView::ViewType vt,
|
||||
AsmJSHeapAccess(uint32_t offset, uint32_t after, Scalar::Type vt,
|
||||
AnyRegister loadedReg, uint32_t cmp = UINT32_MAX)
|
||||
: offset_(offset),
|
||||
# if defined(JS_CODEGEN_X86)
|
||||
cmpDelta_(cmp == UINT32_MAX ? 0 : offset - cmp),
|
||||
# endif
|
||||
opLength_(after - offset),
|
||||
isFloat32Load_(vt == ArrayBufferView::TYPE_FLOAT32),
|
||||
isFloat32Load_(vt == Scalar::Float32),
|
||||
loadedReg_(loadedReg.code())
|
||||
{}
|
||||
AsmJSHeapAccess(uint32_t offset, uint8_t after, uint32_t cmp = UINT32_MAX)
|
||||
|
@ -244,7 +244,7 @@ bool
|
||||
CodeGeneratorX64::visitAsmJSLoadHeap(LAsmJSLoadHeap *ins)
|
||||
{
|
||||
MAsmJSLoadHeap *mir = ins->mir();
|
||||
ArrayBufferView::ViewType vt = mir->viewType();
|
||||
Scalar::Type vt = mir->viewType();
|
||||
const LAllocation *ptr = ins->ptr();
|
||||
|
||||
// No need to note the access if it will never fault.
|
||||
@ -263,14 +263,14 @@ CodeGeneratorX64::visitAsmJSLoadHeap(LAsmJSLoadHeap *ins)
|
||||
|
||||
uint32_t before = masm.size();
|
||||
switch (vt) {
|
||||
case ArrayBufferView::TYPE_INT8: masm.movsbl(srcAddr, ToRegister(ins->output())); break;
|
||||
case ArrayBufferView::TYPE_UINT8: masm.movzbl(srcAddr, ToRegister(ins->output())); break;
|
||||
case ArrayBufferView::TYPE_INT16: masm.movswl(srcAddr, ToRegister(ins->output())); break;
|
||||
case ArrayBufferView::TYPE_UINT16: masm.movzwl(srcAddr, ToRegister(ins->output())); break;
|
||||
case ArrayBufferView::TYPE_INT32:
|
||||
case ArrayBufferView::TYPE_UINT32: masm.movl(srcAddr, ToRegister(ins->output())); break;
|
||||
case ArrayBufferView::TYPE_FLOAT32: masm.loadFloat32(srcAddr, ToFloatRegister(ins->output())); break;
|
||||
case ArrayBufferView::TYPE_FLOAT64: masm.loadDouble(srcAddr, ToFloatRegister(ins->output())); break;
|
||||
case Scalar::Int8: masm.movsbl(srcAddr, ToRegister(ins->output())); break;
|
||||
case Scalar::Uint8: masm.movzbl(srcAddr, ToRegister(ins->output())); break;
|
||||
case Scalar::Int16: masm.movswl(srcAddr, ToRegister(ins->output())); break;
|
||||
case Scalar::Uint16: masm.movzwl(srcAddr, ToRegister(ins->output())); break;
|
||||
case Scalar::Int32:
|
||||
case Scalar::Uint32: masm.movl(srcAddr, ToRegister(ins->output())); break;
|
||||
case Scalar::Float32: masm.loadFloat32(srcAddr, ToFloatRegister(ins->output())); break;
|
||||
case Scalar::Float64: masm.loadDouble(srcAddr, ToFloatRegister(ins->output())); break;
|
||||
default: MOZ_ASSUME_UNREACHABLE("unexpected array type");
|
||||
}
|
||||
uint32_t after = masm.size();
|
||||
@ -283,7 +283,7 @@ bool
|
||||
CodeGeneratorX64::visitAsmJSStoreHeap(LAsmJSStoreHeap *ins)
|
||||
{
|
||||
MAsmJSStoreHeap *mir = ins->mir();
|
||||
ArrayBufferView::ViewType vt = mir->viewType();
|
||||
Scalar::Type vt = mir->viewType();
|
||||
const LAllocation *ptr = ins->ptr();
|
||||
// No need to note the access if it will never fault.
|
||||
bool skipNote = mir->skipBoundsCheck();
|
||||
@ -302,24 +302,24 @@ CodeGeneratorX64::visitAsmJSStoreHeap(LAsmJSStoreHeap *ins)
|
||||
uint32_t before = masm.size();
|
||||
if (ins->value()->isConstant()) {
|
||||
switch (vt) {
|
||||
case ArrayBufferView::TYPE_INT8:
|
||||
case ArrayBufferView::TYPE_UINT8: masm.movb(Imm32(ToInt32(ins->value())), dstAddr); break;
|
||||
case ArrayBufferView::TYPE_INT16:
|
||||
case ArrayBufferView::TYPE_UINT16: masm.movw(Imm32(ToInt32(ins->value())), dstAddr); break;
|
||||
case ArrayBufferView::TYPE_INT32:
|
||||
case ArrayBufferView::TYPE_UINT32: masm.movl(Imm32(ToInt32(ins->value())), dstAddr); break;
|
||||
case Scalar::Int8:
|
||||
case Scalar::Uint8: masm.movb(Imm32(ToInt32(ins->value())), dstAddr); break;
|
||||
case Scalar::Int16:
|
||||
case Scalar::Uint16: masm.movw(Imm32(ToInt32(ins->value())), dstAddr); break;
|
||||
case Scalar::Int32:
|
||||
case Scalar::Uint32: masm.movl(Imm32(ToInt32(ins->value())), dstAddr); break;
|
||||
default: MOZ_ASSUME_UNREACHABLE("unexpected array type");
|
||||
}
|
||||
} else {
|
||||
switch (vt) {
|
||||
case ArrayBufferView::TYPE_INT8:
|
||||
case ArrayBufferView::TYPE_UINT8: masm.movb(ToRegister(ins->value()), dstAddr); break;
|
||||
case ArrayBufferView::TYPE_INT16:
|
||||
case ArrayBufferView::TYPE_UINT16: masm.movw(ToRegister(ins->value()), dstAddr); break;
|
||||
case ArrayBufferView::TYPE_INT32:
|
||||
case ArrayBufferView::TYPE_UINT32: masm.movl(ToRegister(ins->value()), dstAddr); break;
|
||||
case ArrayBufferView::TYPE_FLOAT32: masm.storeFloat32(ToFloatRegister(ins->value()), dstAddr); break;
|
||||
case ArrayBufferView::TYPE_FLOAT64: masm.storeDouble(ToFloatRegister(ins->value()), dstAddr); break;
|
||||
case Scalar::Int8:
|
||||
case Scalar::Uint8: masm.movb(ToRegister(ins->value()), dstAddr); break;
|
||||
case Scalar::Int16:
|
||||
case Scalar::Uint16: masm.movw(ToRegister(ins->value()), dstAddr); break;
|
||||
case Scalar::Int32:
|
||||
case Scalar::Uint32: masm.movl(ToRegister(ins->value()), dstAddr); break;
|
||||
case Scalar::Float32: masm.storeFloat32(ToFloatRegister(ins->value()), dstAddr); break;
|
||||
case Scalar::Float64: masm.storeDouble(ToFloatRegister(ins->value()), dstAddr); break;
|
||||
default: MOZ_ASSUME_UNREACHABLE("unexpected array type");
|
||||
}
|
||||
}
|
||||
|
@ -155,15 +155,20 @@ LIRGeneratorX64::visitAsmJSStoreHeap(MAsmJSStoreHeap *ins)
|
||||
// protected area reserved for the heap.
|
||||
LAllocation ptrAlloc = useRegisterOrNonNegativeConstantAtStart(ptr);
|
||||
switch (ins->viewType()) {
|
||||
case ArrayBufferView::TYPE_INT8: case ArrayBufferView::TYPE_UINT8:
|
||||
case ArrayBufferView::TYPE_INT16: case ArrayBufferView::TYPE_UINT16:
|
||||
case ArrayBufferView::TYPE_INT32: case ArrayBufferView::TYPE_UINT32:
|
||||
case Scalar::Int8:
|
||||
case Scalar::Uint8:
|
||||
case Scalar::Int16:
|
||||
case Scalar::Uint16:
|
||||
case Scalar::Int32:
|
||||
case Scalar::Uint32:
|
||||
lir = new(alloc()) LAsmJSStoreHeap(ptrAlloc, useRegisterOrConstantAtStart(ins->value()));
|
||||
break;
|
||||
case ArrayBufferView::TYPE_FLOAT32: case ArrayBufferView::TYPE_FLOAT64:
|
||||
case Scalar::Float32:
|
||||
case Scalar::Float64:
|
||||
lir = new(alloc()) LAsmJSStoreHeap(ptrAlloc, useRegisterAtStart(ins->value()));
|
||||
break;
|
||||
default: MOZ_ASSUME_UNREACHABLE("unexpected array type");
|
||||
default:
|
||||
MOZ_ASSUME_UNREACHABLE("unexpected array type");
|
||||
}
|
||||
|
||||
return add(lir, ins);
|
||||
|
@ -283,26 +283,26 @@ class jit::OutOfLineLoadTypedArrayOutOfBounds : public OutOfLineCodeBase<CodeGen
|
||||
|
||||
template<typename T>
|
||||
void
|
||||
CodeGeneratorX86::loadViewTypeElement(ArrayBufferView::ViewType vt, const T &srcAddr,
|
||||
CodeGeneratorX86::loadViewTypeElement(Scalar::Type vt, const T &srcAddr,
|
||||
const LDefinition *out)
|
||||
{
|
||||
switch (vt) {
|
||||
case ArrayBufferView::TYPE_INT8: masm.movsblWithPatch(srcAddr, ToRegister(out)); break;
|
||||
case ArrayBufferView::TYPE_UINT8_CLAMPED:
|
||||
case ArrayBufferView::TYPE_UINT8: masm.movzblWithPatch(srcAddr, ToRegister(out)); break;
|
||||
case ArrayBufferView::TYPE_INT16: masm.movswlWithPatch(srcAddr, ToRegister(out)); break;
|
||||
case ArrayBufferView::TYPE_UINT16: masm.movzwlWithPatch(srcAddr, ToRegister(out)); break;
|
||||
case ArrayBufferView::TYPE_INT32:
|
||||
case ArrayBufferView::TYPE_UINT32: masm.movlWithPatch(srcAddr, ToRegister(out)); break;
|
||||
case ArrayBufferView::TYPE_FLOAT32: masm.movssWithPatch(srcAddr, ToFloatRegister(out)); break;
|
||||
case ArrayBufferView::TYPE_FLOAT64: masm.movsdWithPatch(srcAddr, ToFloatRegister(out)); break;
|
||||
case Scalar::Int8: masm.movsblWithPatch(srcAddr, ToRegister(out)); break;
|
||||
case Scalar::Uint8Clamped:
|
||||
case Scalar::Uint8: masm.movzblWithPatch(srcAddr, ToRegister(out)); break;
|
||||
case Scalar::Int16: masm.movswlWithPatch(srcAddr, ToRegister(out)); break;
|
||||
case Scalar::Uint16: masm.movzwlWithPatch(srcAddr, ToRegister(out)); break;
|
||||
case Scalar::Int32:
|
||||
case Scalar::Uint32: masm.movlWithPatch(srcAddr, ToRegister(out)); break;
|
||||
case Scalar::Float32: masm.movssWithPatch(srcAddr, ToFloatRegister(out)); break;
|
||||
case Scalar::Float64: masm.movsdWithPatch(srcAddr, ToFloatRegister(out)); break;
|
||||
default: MOZ_ASSUME_UNREACHABLE("unexpected array type");
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool
|
||||
CodeGeneratorX86::loadAndNoteViewTypeElement(ArrayBufferView::ViewType vt, const T &srcAddr,
|
||||
CodeGeneratorX86::loadAndNoteViewTypeElement(Scalar::Type vt, const T &srcAddr,
|
||||
const LDefinition *out)
|
||||
{
|
||||
uint32_t before = masm.size();
|
||||
@ -316,14 +316,14 @@ bool
|
||||
CodeGeneratorX86::visitLoadTypedArrayElementStatic(LLoadTypedArrayElementStatic *ins)
|
||||
{
|
||||
const MLoadTypedArrayElementStatic *mir = ins->mir();
|
||||
ArrayBufferView::ViewType vt = mir->viewType();
|
||||
JS_ASSERT_IF(vt == ArrayBufferView::TYPE_FLOAT32, mir->type() == MIRType_Float32);
|
||||
Scalar::Type vt = mir->viewType();
|
||||
JS_ASSERT_IF(vt == Scalar::Float32, mir->type() == MIRType_Float32);
|
||||
|
||||
Register ptr = ToRegister(ins->ptr());
|
||||
const LDefinition *out = ins->output();
|
||||
|
||||
OutOfLineLoadTypedArrayOutOfBounds *ool = nullptr;
|
||||
bool isFloat32Load = (vt == ArrayBufferView::TYPE_FLOAT32);
|
||||
bool isFloat32Load = (vt == Scalar::Float32);
|
||||
if (!mir->fallible()) {
|
||||
ool = new(alloc()) OutOfLineLoadTypedArrayOutOfBounds(ToAnyRegister(out), isFloat32Load);
|
||||
if (!addOutOfLineCode(ool))
|
||||
@ -338,9 +338,9 @@ CodeGeneratorX86::visitLoadTypedArrayElementStatic(LLoadTypedArrayElementStatic
|
||||
|
||||
Address srcAddr(ptr, (int32_t) mir->base());
|
||||
loadViewTypeElement(vt, srcAddr, out);
|
||||
if (vt == ArrayBufferView::TYPE_FLOAT64)
|
||||
if (vt == Scalar::Float64)
|
||||
masm.canonicalizeDouble(ToFloatRegister(out));
|
||||
if (vt == ArrayBufferView::TYPE_FLOAT32)
|
||||
if (vt == Scalar::Float32)
|
||||
masm.canonicalizeFloat(ToFloatRegister(out));
|
||||
if (ool)
|
||||
masm.bind(ool->rejoin());
|
||||
@ -351,7 +351,7 @@ bool
|
||||
CodeGeneratorX86::visitAsmJSLoadHeap(LAsmJSLoadHeap *ins)
|
||||
{
|
||||
const MAsmJSLoadHeap *mir = ins->mir();
|
||||
ArrayBufferView::ViewType vt = mir->viewType();
|
||||
Scalar::Type vt = mir->viewType();
|
||||
const LAllocation *ptr = ins->ptr();
|
||||
const LDefinition *out = ins->output();
|
||||
|
||||
@ -370,7 +370,7 @@ CodeGeneratorX86::visitAsmJSLoadHeap(LAsmJSLoadHeap *ins)
|
||||
if (mir->skipBoundsCheck())
|
||||
return loadAndNoteViewTypeElement(vt, srcAddr, out);
|
||||
|
||||
bool isFloat32Load = vt == ArrayBufferView::TYPE_FLOAT32;
|
||||
bool isFloat32Load = vt == Scalar::Float32;
|
||||
OutOfLineLoadTypedArrayOutOfBounds *ool = new(alloc()) OutOfLineLoadTypedArrayOutOfBounds(ToAnyRegister(out), isFloat32Load);
|
||||
if (!addOutOfLineCode(ool))
|
||||
return false;
|
||||
@ -404,26 +404,26 @@ CodeGeneratorX86::visitOutOfLineLoadTypedArrayOutOfBounds(OutOfLineLoadTypedArra
|
||||
|
||||
template<typename T>
|
||||
void
|
||||
CodeGeneratorX86::storeViewTypeElement(ArrayBufferView::ViewType vt, const LAllocation *value,
|
||||
CodeGeneratorX86::storeViewTypeElement(Scalar::Type vt, const LAllocation *value,
|
||||
const T &dstAddr)
|
||||
{
|
||||
switch (vt) {
|
||||
case ArrayBufferView::TYPE_INT8:
|
||||
case ArrayBufferView::TYPE_UINT8_CLAMPED:
|
||||
case ArrayBufferView::TYPE_UINT8: masm.movbWithPatch(ToRegister(value), dstAddr); break;
|
||||
case ArrayBufferView::TYPE_INT16:
|
||||
case ArrayBufferView::TYPE_UINT16: masm.movwWithPatch(ToRegister(value), dstAddr); break;
|
||||
case ArrayBufferView::TYPE_INT32:
|
||||
case ArrayBufferView::TYPE_UINT32: masm.movlWithPatch(ToRegister(value), dstAddr); break;
|
||||
case ArrayBufferView::TYPE_FLOAT32: masm.movssWithPatch(ToFloatRegister(value), dstAddr); break;
|
||||
case ArrayBufferView::TYPE_FLOAT64: masm.movsdWithPatch(ToFloatRegister(value), dstAddr); break;
|
||||
case Scalar::Int8:
|
||||
case Scalar::Uint8Clamped:
|
||||
case Scalar::Uint8: masm.movbWithPatch(ToRegister(value), dstAddr); break;
|
||||
case Scalar::Int16:
|
||||
case Scalar::Uint16: masm.movwWithPatch(ToRegister(value), dstAddr); break;
|
||||
case Scalar::Int32:
|
||||
case Scalar::Uint32: masm.movlWithPatch(ToRegister(value), dstAddr); break;
|
||||
case Scalar::Float32: masm.movssWithPatch(ToFloatRegister(value), dstAddr); break;
|
||||
case Scalar::Float64: masm.movsdWithPatch(ToFloatRegister(value), dstAddr); break;
|
||||
default: MOZ_ASSUME_UNREACHABLE("unexpected array type");
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void
|
||||
CodeGeneratorX86::storeAndNoteViewTypeElement(ArrayBufferView::ViewType vt, const LAllocation *value,
|
||||
CodeGeneratorX86::storeAndNoteViewTypeElement(Scalar::Type vt, const LAllocation *value,
|
||||
const T &dstAddr)
|
||||
{
|
||||
uint32_t before = masm.size();
|
||||
@ -436,7 +436,7 @@ bool
|
||||
CodeGeneratorX86::visitStoreTypedArrayElementStatic(LStoreTypedArrayElementStatic *ins)
|
||||
{
|
||||
MStoreTypedArrayElementStatic *mir = ins->mir();
|
||||
ArrayBufferView::ViewType vt = mir->viewType();
|
||||
Scalar::Type vt = mir->viewType();
|
||||
|
||||
Register ptr = ToRegister(ins->ptr());
|
||||
const LAllocation *value = ins->value();
|
||||
@ -455,7 +455,7 @@ bool
|
||||
CodeGeneratorX86::visitAsmJSStoreHeap(LAsmJSStoreHeap *ins)
|
||||
{
|
||||
MAsmJSStoreHeap *mir = ins->mir();
|
||||
ArrayBufferView::ViewType vt = mir->viewType();
|
||||
Scalar::Type vt = mir->viewType();
|
||||
const LAllocation *value = ins->value();
|
||||
const LAllocation *ptr = ins->ptr();
|
||||
|
||||
|
@ -30,17 +30,17 @@ class CodeGeneratorX86 : public CodeGeneratorX86Shared
|
||||
ValueOperand ToTempValue(LInstruction *ins, size_t pos);
|
||||
|
||||
template<typename T>
|
||||
bool loadAndNoteViewTypeElement(ArrayBufferView::ViewType vt, const T &srcAddr,
|
||||
bool loadAndNoteViewTypeElement(Scalar::Type vt, const T &srcAddr,
|
||||
const LDefinition *out);
|
||||
template<typename T>
|
||||
void loadViewTypeElement(ArrayBufferView::ViewType vt, const T &srcAddr,
|
||||
void loadViewTypeElement(Scalar::Type vt, const T &srcAddr,
|
||||
const LDefinition *out);
|
||||
template<typename T>
|
||||
void storeAndNoteViewTypeElement(ArrayBufferView::ViewType vt, const LAllocation *value,
|
||||
void storeAndNoteViewTypeElement(Scalar::Type vt, const LAllocation *value,
|
||||
const T &dstAddr);
|
||||
template<typename T>
|
||||
void storeViewTypeElement(ArrayBufferView::ViewType vt, const LAllocation *value,
|
||||
const T &dstAddr);
|
||||
void storeViewTypeElement(Scalar::Type vt, const LAllocation *value,
|
||||
const T &dstAddr);
|
||||
public:
|
||||
CodeGeneratorX86(MIRGenerator *gen, LIRGraph *graph, MacroAssembler *masm);
|
||||
|
||||
|
@ -244,13 +244,13 @@ LIRGeneratorX86::visitAsmJSStoreHeap(MAsmJSStoreHeap *ins)
|
||||
JS_ASSERT(ptrValue >= 0);
|
||||
LAllocation ptrAlloc = LAllocation(ptr->toConstant()->vp());
|
||||
switch (ins->viewType()) {
|
||||
case ArrayBufferView::TYPE_INT8: case ArrayBufferView::TYPE_UINT8:
|
||||
case Scalar::Int8: case Scalar::Uint8:
|
||||
// See comment below.
|
||||
lir = new(alloc()) LAsmJSStoreHeap(ptrAlloc, useFixed(ins->value(), eax));
|
||||
break;
|
||||
case ArrayBufferView::TYPE_INT16: case ArrayBufferView::TYPE_UINT16:
|
||||
case ArrayBufferView::TYPE_INT32: case ArrayBufferView::TYPE_UINT32:
|
||||
case ArrayBufferView::TYPE_FLOAT32: case ArrayBufferView::TYPE_FLOAT64:
|
||||
case Scalar::Int16: case Scalar::Uint16:
|
||||
case Scalar::Int32: case Scalar::Uint32:
|
||||
case Scalar::Float32: case Scalar::Float64:
|
||||
// See comment below.
|
||||
lir = new(alloc()) LAsmJSStoreHeap(ptrAlloc, useRegisterAtStart(ins->value()));
|
||||
break;
|
||||
@ -260,13 +260,13 @@ LIRGeneratorX86::visitAsmJSStoreHeap(MAsmJSStoreHeap *ins)
|
||||
}
|
||||
|
||||
switch (ins->viewType()) {
|
||||
case ArrayBufferView::TYPE_INT8: case ArrayBufferView::TYPE_UINT8:
|
||||
case Scalar::Int8: case Scalar::Uint8:
|
||||
// See comment for LIRGeneratorX86::useByteOpRegister.
|
||||
lir = new(alloc()) LAsmJSStoreHeap(useRegister(ins->ptr()), useFixed(ins->value(), eax));
|
||||
break;
|
||||
case ArrayBufferView::TYPE_INT16: case ArrayBufferView::TYPE_UINT16:
|
||||
case ArrayBufferView::TYPE_INT32: case ArrayBufferView::TYPE_UINT32:
|
||||
case ArrayBufferView::TYPE_FLOAT32: case ArrayBufferView::TYPE_FLOAT64:
|
||||
case Scalar::Int16: case Scalar::Uint16:
|
||||
case Scalar::Int32: case Scalar::Uint32:
|
||||
case Scalar::Float32: case Scalar::Float64:
|
||||
// For now, don't allow constant values. The immediate operand
|
||||
// affects instruction layout which affects patching.
|
||||
lir = new(alloc()) LAsmJSStoreHeap(useRegisterAtStart(ptr), useRegisterAtStart(ins->value()));
|
||||
@ -284,14 +284,14 @@ LIRGeneratorX86::visitStoreTypedArrayElementStatic(MStoreTypedArrayElementStatic
|
||||
// for AsmJSStoreHeap, and the same concerns apply.
|
||||
LStoreTypedArrayElementStatic *lir;
|
||||
switch (ins->viewType()) {
|
||||
case ArrayBufferView::TYPE_INT8: case ArrayBufferView::TYPE_UINT8:
|
||||
case ArrayBufferView::TYPE_UINT8_CLAMPED:
|
||||
case Scalar::Int8: case Scalar::Uint8:
|
||||
case Scalar::Uint8Clamped:
|
||||
lir = new(alloc()) LStoreTypedArrayElementStatic(useRegister(ins->ptr()),
|
||||
useFixed(ins->value(), eax));
|
||||
break;
|
||||
case ArrayBufferView::TYPE_INT16: case ArrayBufferView::TYPE_UINT16:
|
||||
case ArrayBufferView::TYPE_INT32: case ArrayBufferView::TYPE_UINT32:
|
||||
case ArrayBufferView::TYPE_FLOAT32: case ArrayBufferView::TYPE_FLOAT64:
|
||||
case Scalar::Int16: case Scalar::Uint16:
|
||||
case Scalar::Int32: case Scalar::Uint32:
|
||||
case Scalar::Float32: case Scalar::Float64:
|
||||
lir = new(alloc()) LStoreTypedArrayElementStatic(useRegisterAtStart(ins->ptr()),
|
||||
useRegisterAtStart(ins->value()));
|
||||
break;
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
|
||||
#include "builtin/RegExp.h"
|
||||
#include "builtin/TypedObject.h"
|
||||
#include "gc/Zone.h"
|
||||
#include "vm/GlobalObject.h"
|
||||
#include "vm/PIC.h"
|
||||
|
@ -1242,42 +1242,54 @@ ErrorReportToString(JSContext *cx, JSErrorReport *reportp);
|
||||
extern JS_FRIEND_API(uint64_t)
|
||||
js_GetSCOffset(JSStructuredCloneWriter* writer);
|
||||
|
||||
/* Typed Array functions, implemented in jstypedarray.cpp */
|
||||
|
||||
namespace js {
|
||||
namespace ArrayBufferView {
|
||||
namespace Scalar {
|
||||
|
||||
enum ViewType {
|
||||
TYPE_INT8 = 0,
|
||||
TYPE_UINT8,
|
||||
TYPE_INT16,
|
||||
TYPE_UINT16,
|
||||
TYPE_INT32,
|
||||
TYPE_UINT32,
|
||||
TYPE_FLOAT32,
|
||||
TYPE_FLOAT64,
|
||||
/* Scalar types which can appear in typed arrays and typed objects. */
|
||||
enum Type {
|
||||
Int8 = 0,
|
||||
Uint8,
|
||||
Int16,
|
||||
Uint16,
|
||||
Int32,
|
||||
Uint32,
|
||||
Float32,
|
||||
Float64,
|
||||
|
||||
/*
|
||||
* Special type that is a uint8_t, but assignments are clamped to [0, 256).
|
||||
* Treat the raw data type as a uint8_t.
|
||||
*/
|
||||
TYPE_UINT8_CLAMPED,
|
||||
Uint8Clamped,
|
||||
|
||||
/*
|
||||
* Type returned for a DataView. Note that there is no single element type
|
||||
* in this case.
|
||||
*/
|
||||
TYPE_DATAVIEW,
|
||||
|
||||
TYPE_MAX
|
||||
TypeMax
|
||||
};
|
||||
|
||||
} /* namespace ArrayBufferView */
|
||||
static inline size_t
|
||||
byteSize(Type atype)
|
||||
{
|
||||
switch (atype) {
|
||||
case Int8:
|
||||
case Uint8:
|
||||
case Uint8Clamped:
|
||||
return 1;
|
||||
case Int16:
|
||||
case Uint16:
|
||||
return 2;
|
||||
case Int32:
|
||||
case Uint32:
|
||||
case Float32:
|
||||
return 4;
|
||||
case Float64:
|
||||
return 8;
|
||||
default:
|
||||
MOZ_ASSUME_UNREACHABLE("invalid type");
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace Scalar */
|
||||
} /* namespace js */
|
||||
|
||||
typedef js::ArrayBufferView::ViewType JSArrayBufferViewType;
|
||||
|
||||
/*
|
||||
* Create a new typed array with nelements elements.
|
||||
*
|
||||
@ -1529,13 +1541,13 @@ 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 TYPE_DATAVIEW if a DataView.
|
||||
* Get the type of elements in a typed array, or TypeMax 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
|
||||
* wrapper of an ArrayBufferView, and the unwrapping will succeed.
|
||||
*/
|
||||
extern JS_FRIEND_API(JSArrayBufferViewType)
|
||||
extern JS_FRIEND_API(js::Scalar::Type)
|
||||
JS_GetArrayBufferViewType(JSObject *obj);
|
||||
|
||||
/*
|
||||
|
@ -1931,14 +1931,14 @@ TemporaryTypeSet::forAllClasses(bool (*func)(const Class* clasp))
|
||||
return true_results ? ForAllResult::ALL_TRUE : ForAllResult::ALL_FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
Scalar::Type
|
||||
TemporaryTypeSet::getTypedArrayType()
|
||||
{
|
||||
const Class *clasp = getKnownClass();
|
||||
|
||||
if (clasp && IsTypedArrayClass(clasp))
|
||||
return clasp - &TypedArrayObject::classes[0];
|
||||
return ScalarTypeDescr::TYPE_MAX;
|
||||
return (Scalar::Type) (clasp - &TypedArrayObject::classes[0]);
|
||||
return Scalar::TypeMax;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -749,7 +749,7 @@ class TemporaryTypeSet : public TypeSet
|
||||
JSObject *getCommonPrototype();
|
||||
|
||||
/* Get the typed array type of all objects in this set, or TypedArrayObject::TYPE_MAX. */
|
||||
int getTypedArrayType();
|
||||
Scalar::Type getTypedArrayType();
|
||||
|
||||
/* Whether all objects have JSCLASS_IS_DOMJSCLASS set. */
|
||||
bool isDOMClass();
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
#define CLASP(name) (&name##Class)
|
||||
#define OCLASP(name) (&name##Object::class_)
|
||||
#define TYPED_ARRAY_CLASP(type) (&TypedArrayObject::classes[ScalarTypeDescr::type])
|
||||
#define TYPED_ARRAY_CLASP(type) (&TypedArrayObject::classes[Scalar::type])
|
||||
|
||||
#ifdef ENABLE_PARALLEL_JS
|
||||
#define IF_PJS(real,imaginary) real
|
||||
@ -83,15 +83,15 @@
|
||||
real(Iterator, 19, js_InitIteratorClasses, OCLASP(PropertyIterator)) \
|
||||
real(StopIteration, 20, js_InitIteratorClasses, OCLASP(StopIteration)) \
|
||||
real(ArrayBuffer, 21, js_InitArrayBufferClass, &js::ArrayBufferObject::protoClass) \
|
||||
real(Int8Array, 22, js_InitViaClassSpec, TYPED_ARRAY_CLASP(TYPE_INT8)) \
|
||||
real(Uint8Array, 23, js_InitViaClassSpec, TYPED_ARRAY_CLASP(TYPE_UINT8)) \
|
||||
real(Int16Array, 24, js_InitViaClassSpec, TYPED_ARRAY_CLASP(TYPE_INT16)) \
|
||||
real(Uint16Array, 25, js_InitViaClassSpec, TYPED_ARRAY_CLASP(TYPE_UINT16)) \
|
||||
real(Int32Array, 26, js_InitViaClassSpec, TYPED_ARRAY_CLASP(TYPE_INT32)) \
|
||||
real(Uint32Array, 27, js_InitViaClassSpec, TYPED_ARRAY_CLASP(TYPE_UINT32)) \
|
||||
real(Float32Array, 28, js_InitViaClassSpec, TYPED_ARRAY_CLASP(TYPE_FLOAT32)) \
|
||||
real(Float64Array, 29, js_InitViaClassSpec, TYPED_ARRAY_CLASP(TYPE_FLOAT64)) \
|
||||
real(Uint8ClampedArray, 30, js_InitViaClassSpec, TYPED_ARRAY_CLASP(TYPE_UINT8_CLAMPED)) \
|
||||
real(Int8Array, 22, js_InitViaClassSpec, TYPED_ARRAY_CLASP(Int8)) \
|
||||
real(Uint8Array, 23, js_InitViaClassSpec, TYPED_ARRAY_CLASP(Uint8)) \
|
||||
real(Int16Array, 24, js_InitViaClassSpec, TYPED_ARRAY_CLASP(Int16)) \
|
||||
real(Uint16Array, 25, js_InitViaClassSpec, TYPED_ARRAY_CLASP(Uint16)) \
|
||||
real(Int32Array, 26, js_InitViaClassSpec, TYPED_ARRAY_CLASP(Int32)) \
|
||||
real(Uint32Array, 27, js_InitViaClassSpec, TYPED_ARRAY_CLASP(Uint32)) \
|
||||
real(Float32Array, 28, js_InitViaClassSpec, TYPED_ARRAY_CLASP(Float32)) \
|
||||
real(Float64Array, 29, js_InitViaClassSpec, TYPED_ARRAY_CLASP(Float64)) \
|
||||
real(Uint8ClampedArray, 30, js_InitViaClassSpec, TYPED_ARRAY_CLASP(Uint8Clamped)) \
|
||||
real(Proxy, 31, js_InitProxyClass, &ProxyObject::uncallableClass_) \
|
||||
real(WeakMap, 32, js_InitWeakMapClass, OCLASP(WeakMap)) \
|
||||
real(Map, 33, js_InitMapClass, OCLASP(Map)) \
|
||||
|
@ -75,16 +75,16 @@ enum StructuredDataType MOZ_ENUM_TYPE(uint32_t) {
|
||||
SCTAG_DO_NOT_USE_2, // Required for backwards compatibility
|
||||
SCTAG_TYPED_ARRAY_OBJECT,
|
||||
SCTAG_TYPED_ARRAY_V1_MIN = 0xFFFF0100,
|
||||
SCTAG_TYPED_ARRAY_V1_INT8 = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeDescr::TYPE_INT8,
|
||||
SCTAG_TYPED_ARRAY_V1_UINT8 = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeDescr::TYPE_UINT8,
|
||||
SCTAG_TYPED_ARRAY_V1_INT16 = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeDescr::TYPE_INT16,
|
||||
SCTAG_TYPED_ARRAY_V1_UINT16 = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeDescr::TYPE_UINT16,
|
||||
SCTAG_TYPED_ARRAY_V1_INT32 = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeDescr::TYPE_INT32,
|
||||
SCTAG_TYPED_ARRAY_V1_UINT32 = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeDescr::TYPE_UINT32,
|
||||
SCTAG_TYPED_ARRAY_V1_FLOAT32 = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeDescr::TYPE_FLOAT32,
|
||||
SCTAG_TYPED_ARRAY_V1_FLOAT64 = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeDescr::TYPE_FLOAT64,
|
||||
SCTAG_TYPED_ARRAY_V1_UINT8_CLAMPED = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeDescr::TYPE_UINT8_CLAMPED,
|
||||
SCTAG_TYPED_ARRAY_V1_MAX = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeDescr::TYPE_MAX - 1,
|
||||
SCTAG_TYPED_ARRAY_V1_INT8 = SCTAG_TYPED_ARRAY_V1_MIN + Scalar::Int8,
|
||||
SCTAG_TYPED_ARRAY_V1_UINT8 = SCTAG_TYPED_ARRAY_V1_MIN + Scalar::Uint8,
|
||||
SCTAG_TYPED_ARRAY_V1_INT16 = SCTAG_TYPED_ARRAY_V1_MIN + Scalar::Int16,
|
||||
SCTAG_TYPED_ARRAY_V1_UINT16 = SCTAG_TYPED_ARRAY_V1_MIN + Scalar::Uint16,
|
||||
SCTAG_TYPED_ARRAY_V1_INT32 = SCTAG_TYPED_ARRAY_V1_MIN + Scalar::Int32,
|
||||
SCTAG_TYPED_ARRAY_V1_UINT32 = SCTAG_TYPED_ARRAY_V1_MIN + Scalar::Uint32,
|
||||
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,
|
||||
|
||||
/*
|
||||
* Define a separate range of numbers for Transferable-only tags, since
|
||||
@ -327,7 +327,7 @@ js_GetSCOffset(JSStructuredCloneWriter* writer)
|
||||
|
||||
JS_STATIC_ASSERT(SCTAG_END_OF_BUILTIN_TYPES <= JS_SCTAG_USER_MIN);
|
||||
JS_STATIC_ASSERT(JS_SCTAG_USER_MIN <= JS_SCTAG_USER_MAX);
|
||||
JS_STATIC_ASSERT(ScalarTypeDescr::TYPE_INT8 == 0);
|
||||
JS_STATIC_ASSERT(Scalar::Int8 == 0);
|
||||
|
||||
static void
|
||||
ReportErrorTransferable(JSContext *cx, const JSStructuredCloneCallbacks *callbacks)
|
||||
@ -1224,7 +1224,7 @@ bool
|
||||
JSStructuredCloneReader::readTypedArray(uint32_t arrayType, uint32_t nelems, Value *vp,
|
||||
bool v1Read)
|
||||
{
|
||||
if (arrayType > ScalarTypeDescr::TYPE_UINT8_CLAMPED) {
|
||||
if (arrayType > Scalar::Uint8Clamped) {
|
||||
JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr,
|
||||
JSMSG_SC_BAD_SERIALIZED_DATA, "unhandled typed array element type");
|
||||
return false;
|
||||
@ -1255,31 +1255,31 @@ JSStructuredCloneReader::readTypedArray(uint32_t arrayType, uint32_t nelems, Val
|
||||
RootedObject obj(context(), nullptr);
|
||||
|
||||
switch (arrayType) {
|
||||
case ScalarTypeDescr::TYPE_INT8:
|
||||
case Scalar::Int8:
|
||||
obj = JS_NewInt8ArrayWithBuffer(context(), buffer, byteOffset, nelems);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT8:
|
||||
case Scalar::Uint8:
|
||||
obj = JS_NewUint8ArrayWithBuffer(context(), buffer, byteOffset, nelems);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_INT16:
|
||||
case Scalar::Int16:
|
||||
obj = JS_NewInt16ArrayWithBuffer(context(), buffer, byteOffset, nelems);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT16:
|
||||
case Scalar::Uint16:
|
||||
obj = JS_NewUint16ArrayWithBuffer(context(), buffer, byteOffset, nelems);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_INT32:
|
||||
case Scalar::Int32:
|
||||
obj = JS_NewInt32ArrayWithBuffer(context(), buffer, byteOffset, nelems);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT32:
|
||||
case Scalar::Uint32:
|
||||
obj = JS_NewUint32ArrayWithBuffer(context(), buffer, byteOffset, nelems);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_FLOAT32:
|
||||
case Scalar::Float32:
|
||||
obj = JS_NewFloat32ArrayWithBuffer(context(), buffer, byteOffset, nelems);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_FLOAT64:
|
||||
case Scalar::Float64:
|
||||
obj = JS_NewFloat64ArrayWithBuffer(context(), buffer, byteOffset, nelems);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT8_CLAMPED:
|
||||
case Scalar::Uint8Clamped:
|
||||
obj = JS_NewUint8ClampedArrayWithBuffer(context(), buffer, byteOffset, nelems);
|
||||
break;
|
||||
default:
|
||||
@ -1311,18 +1311,18 @@ static size_t
|
||||
bytesPerTypedArrayElement(uint32_t arrayType)
|
||||
{
|
||||
switch (arrayType) {
|
||||
case ScalarTypeDescr::TYPE_INT8:
|
||||
case ScalarTypeDescr::TYPE_UINT8:
|
||||
case ScalarTypeDescr::TYPE_UINT8_CLAMPED:
|
||||
case Scalar::Int8:
|
||||
case Scalar::Uint8:
|
||||
case Scalar::Uint8Clamped:
|
||||
return sizeof(uint8_t);
|
||||
case ScalarTypeDescr::TYPE_INT16:
|
||||
case ScalarTypeDescr::TYPE_UINT16:
|
||||
case Scalar::Int16:
|
||||
case Scalar::Uint16:
|
||||
return sizeof(uint16_t);
|
||||
case ScalarTypeDescr::TYPE_INT32:
|
||||
case ScalarTypeDescr::TYPE_UINT32:
|
||||
case ScalarTypeDescr::TYPE_FLOAT32:
|
||||
case Scalar::Int32:
|
||||
case Scalar::Uint32:
|
||||
case Scalar::Float32:
|
||||
return sizeof(uint32_t);
|
||||
case ScalarTypeDescr::TYPE_FLOAT64:
|
||||
case Scalar::Float64:
|
||||
return sizeof(uint64_t);
|
||||
default:
|
||||
MOZ_ASSUME_UNREACHABLE("unknown TypedArrayObject type");
|
||||
@ -1336,7 +1336,7 @@ bytesPerTypedArrayElement(uint32_t arrayType)
|
||||
bool
|
||||
JSStructuredCloneReader::readV1ArrayBuffer(uint32_t arrayType, uint32_t nelems, Value *vp)
|
||||
{
|
||||
JS_ASSERT(arrayType <= ScalarTypeDescr::TYPE_UINT8_CLAMPED);
|
||||
JS_ASSERT(arrayType <= Scalar::Uint8Clamped);
|
||||
|
||||
uint32_t nbytes = nelems * bytesPerTypedArrayElement(arrayType);
|
||||
JSObject *obj = ArrayBufferObject::create(context(), nbytes);
|
||||
@ -1347,18 +1347,18 @@ JSStructuredCloneReader::readV1ArrayBuffer(uint32_t arrayType, uint32_t nelems,
|
||||
JS_ASSERT(buffer.byteLength() == nbytes);
|
||||
|
||||
switch (arrayType) {
|
||||
case ScalarTypeDescr::TYPE_INT8:
|
||||
case ScalarTypeDescr::TYPE_UINT8:
|
||||
case ScalarTypeDescr::TYPE_UINT8_CLAMPED:
|
||||
case Scalar::Int8:
|
||||
case Scalar::Uint8:
|
||||
case Scalar::Uint8Clamped:
|
||||
return in.readArray((uint8_t*) buffer.dataPointer(), nelems);
|
||||
case ScalarTypeDescr::TYPE_INT16:
|
||||
case ScalarTypeDescr::TYPE_UINT16:
|
||||
case Scalar::Int16:
|
||||
case Scalar::Uint16:
|
||||
return in.readArray((uint16_t*) buffer.dataPointer(), nelems);
|
||||
case ScalarTypeDescr::TYPE_INT32:
|
||||
case ScalarTypeDescr::TYPE_UINT32:
|
||||
case ScalarTypeDescr::TYPE_FLOAT32:
|
||||
case Scalar::Int32:
|
||||
case Scalar::Uint32:
|
||||
case Scalar::Float32:
|
||||
return in.readArray((uint32_t*) buffer.dataPointer(), nelems);
|
||||
case ScalarTypeDescr::TYPE_FLOAT64:
|
||||
case Scalar::Float64:
|
||||
return in.readArray((uint64_t*) buffer.dataPointer(), nelems);
|
||||
default:
|
||||
MOZ_ASSUME_UNREACHABLE("unknown TypedArrayObject type");
|
||||
|
@ -171,16 +171,16 @@ js::ClampDoubleToUint8(const double x)
|
||||
return y;
|
||||
}
|
||||
|
||||
template<typename NativeType> static inline ScalarTypeDescr::Type TypeIDOfType();
|
||||
template<> inline ScalarTypeDescr::Type TypeIDOfType<int8_t>() { return ScalarTypeDescr::TYPE_INT8; }
|
||||
template<> inline ScalarTypeDescr::Type TypeIDOfType<uint8_t>() { return ScalarTypeDescr::TYPE_UINT8; }
|
||||
template<> inline ScalarTypeDescr::Type TypeIDOfType<int16_t>() { return ScalarTypeDescr::TYPE_INT16; }
|
||||
template<> inline ScalarTypeDescr::Type TypeIDOfType<uint16_t>() { return ScalarTypeDescr::TYPE_UINT16; }
|
||||
template<> inline ScalarTypeDescr::Type TypeIDOfType<int32_t>() { return ScalarTypeDescr::TYPE_INT32; }
|
||||
template<> inline ScalarTypeDescr::Type TypeIDOfType<uint32_t>() { return ScalarTypeDescr::TYPE_UINT32; }
|
||||
template<> inline ScalarTypeDescr::Type TypeIDOfType<float>() { return ScalarTypeDescr::TYPE_FLOAT32; }
|
||||
template<> inline ScalarTypeDescr::Type TypeIDOfType<double>() { return ScalarTypeDescr::TYPE_FLOAT64; }
|
||||
template<> inline ScalarTypeDescr::Type TypeIDOfType<uint8_clamped>() { return ScalarTypeDescr::TYPE_UINT8_CLAMPED; }
|
||||
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 ElementType>
|
||||
static inline JSObject *
|
||||
@ -194,7 +194,7 @@ class TypedArrayObjectTemplate : public TypedArrayObject
|
||||
public:
|
||||
typedef NativeType ThisType;
|
||||
typedef TypedArrayObjectTemplate<NativeType> ThisTypedArrayObject;
|
||||
static ScalarTypeDescr::Type ArrayTypeID() { return TypeIDOfType<NativeType>(); }
|
||||
static Scalar::Type ArrayTypeID() { return TypeIDOfType<NativeType>(); }
|
||||
static bool ArrayTypeIsUnsigned() { return TypeIsUnsigned<NativeType>(); }
|
||||
static bool ArrayTypeIsFloatingPoint() { return TypeIsFloatingPoint<NativeType>(); }
|
||||
|
||||
@ -235,7 +235,7 @@ class TypedArrayObjectTemplate : public TypedArrayObject
|
||||
JS_ASSERT(sizeof(NativeType) <= 4);
|
||||
uint32_t n = ToUint32(d);
|
||||
setIndex(tarray, index, NativeType(n));
|
||||
} else if (ArrayTypeID() == ScalarTypeDescr::TYPE_UINT8_CLAMPED) {
|
||||
} else if (ArrayTypeID() == Scalar::Uint8Clamped) {
|
||||
// The uint8_clamped type has a special rounding converter
|
||||
// for doubles.
|
||||
setIndex(tarray, index, NativeType(d));
|
||||
@ -992,50 +992,50 @@ class TypedArrayObjectTemplate : public TypedArrayObject
|
||||
|
||||
unsigned srclen = tarray->length();
|
||||
switch (tarray->type()) {
|
||||
case ScalarTypeDescr::TYPE_INT8: {
|
||||
case Scalar::Int8: {
|
||||
int8_t *src = static_cast<int8_t*>(tarray->viewData());
|
||||
for (unsigned i = 0; i < srclen; ++i)
|
||||
*dest++ = NativeType(*src++);
|
||||
break;
|
||||
}
|
||||
case ScalarTypeDescr::TYPE_UINT8:
|
||||
case ScalarTypeDescr::TYPE_UINT8_CLAMPED: {
|
||||
case Scalar::Uint8:
|
||||
case Scalar::Uint8Clamped: {
|
||||
uint8_t *src = static_cast<uint8_t*>(tarray->viewData());
|
||||
for (unsigned i = 0; i < srclen; ++i)
|
||||
*dest++ = NativeType(*src++);
|
||||
break;
|
||||
}
|
||||
case ScalarTypeDescr::TYPE_INT16: {
|
||||
case Scalar::Int16: {
|
||||
int16_t *src = static_cast<int16_t*>(tarray->viewData());
|
||||
for (unsigned i = 0; i < srclen; ++i)
|
||||
*dest++ = NativeType(*src++);
|
||||
break;
|
||||
}
|
||||
case ScalarTypeDescr::TYPE_UINT16: {
|
||||
case Scalar::Uint16: {
|
||||
uint16_t *src = static_cast<uint16_t*>(tarray->viewData());
|
||||
for (unsigned i = 0; i < srclen; ++i)
|
||||
*dest++ = NativeType(*src++);
|
||||
break;
|
||||
}
|
||||
case ScalarTypeDescr::TYPE_INT32: {
|
||||
case Scalar::Int32: {
|
||||
int32_t *src = static_cast<int32_t*>(tarray->viewData());
|
||||
for (unsigned i = 0; i < srclen; ++i)
|
||||
*dest++ = NativeType(*src++);
|
||||
break;
|
||||
}
|
||||
case ScalarTypeDescr::TYPE_UINT32: {
|
||||
case Scalar::Uint32: {
|
||||
uint32_t *src = static_cast<uint32_t*>(tarray->viewData());
|
||||
for (unsigned i = 0; i < srclen; ++i)
|
||||
*dest++ = NativeType(*src++);
|
||||
break;
|
||||
}
|
||||
case ScalarTypeDescr::TYPE_FLOAT32: {
|
||||
case Scalar::Float32: {
|
||||
float *src = static_cast<float*>(tarray->viewData());
|
||||
for (unsigned i = 0; i < srclen; ++i)
|
||||
*dest++ = NativeType(*src++);
|
||||
break;
|
||||
}
|
||||
case ScalarTypeDescr::TYPE_FLOAT64: {
|
||||
case Scalar::Float64: {
|
||||
double *src = static_cast<double*>(tarray->viewData());
|
||||
for (unsigned i = 0; i < srclen; ++i)
|
||||
*dest++ = NativeType(*src++);
|
||||
@ -1073,50 +1073,50 @@ class TypedArrayObjectTemplate : public TypedArrayObject
|
||||
|
||||
uint32_t len = tarray->length();
|
||||
switch (tarray->type()) {
|
||||
case ScalarTypeDescr::TYPE_INT8: {
|
||||
case Scalar::Int8: {
|
||||
int8_t *src = (int8_t*) srcbuf;
|
||||
for (unsigned i = 0; i < len; ++i)
|
||||
*dest++ = NativeType(*src++);
|
||||
break;
|
||||
}
|
||||
case ScalarTypeDescr::TYPE_UINT8:
|
||||
case ScalarTypeDescr::TYPE_UINT8_CLAMPED: {
|
||||
case Scalar::Uint8:
|
||||
case Scalar::Uint8Clamped: {
|
||||
uint8_t *src = (uint8_t*) srcbuf;
|
||||
for (unsigned i = 0; i < len; ++i)
|
||||
*dest++ = NativeType(*src++);
|
||||
break;
|
||||
}
|
||||
case ScalarTypeDescr::TYPE_INT16: {
|
||||
case Scalar::Int16: {
|
||||
int16_t *src = (int16_t*) srcbuf;
|
||||
for (unsigned i = 0; i < len; ++i)
|
||||
*dest++ = NativeType(*src++);
|
||||
break;
|
||||
}
|
||||
case ScalarTypeDescr::TYPE_UINT16: {
|
||||
case Scalar::Uint16: {
|
||||
uint16_t *src = (uint16_t*) srcbuf;
|
||||
for (unsigned i = 0; i < len; ++i)
|
||||
*dest++ = NativeType(*src++);
|
||||
break;
|
||||
}
|
||||
case ScalarTypeDescr::TYPE_INT32: {
|
||||
case Scalar::Int32: {
|
||||
int32_t *src = (int32_t*) srcbuf;
|
||||
for (unsigned i = 0; i < len; ++i)
|
||||
*dest++ = NativeType(*src++);
|
||||
break;
|
||||
}
|
||||
case ScalarTypeDescr::TYPE_UINT32: {
|
||||
case Scalar::Uint32: {
|
||||
uint32_t *src = (uint32_t*) srcbuf;
|
||||
for (unsigned i = 0; i < len; ++i)
|
||||
*dest++ = NativeType(*src++);
|
||||
break;
|
||||
}
|
||||
case ScalarTypeDescr::TYPE_FLOAT32: {
|
||||
case Scalar::Float32: {
|
||||
float *src = (float*) srcbuf;
|
||||
for (unsigned i = 0; i < len; ++i)
|
||||
*dest++ = NativeType(*src++);
|
||||
break;
|
||||
}
|
||||
case ScalarTypeDescr::TYPE_FLOAT64: {
|
||||
case Scalar::Float64: {
|
||||
double *src = (double*) srcbuf;
|
||||
for (unsigned i = 0; i < len; ++i)
|
||||
*dest++ = NativeType(*src++);
|
||||
@ -1133,63 +1133,63 @@ class TypedArrayObjectTemplate : public TypedArrayObject
|
||||
|
||||
class Int8ArrayObject : public TypedArrayObjectTemplate<int8_t> {
|
||||
public:
|
||||
enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_INT8 };
|
||||
enum { ACTUAL_TYPE = Scalar::Int8 };
|
||||
static const JSProtoKey key = JSProto_Int8Array;
|
||||
static const JSFunctionSpec jsfuncs[];
|
||||
static const JSPropertySpec jsprops[];
|
||||
};
|
||||
class Uint8ArrayObject : public TypedArrayObjectTemplate<uint8_t> {
|
||||
public:
|
||||
enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_UINT8 };
|
||||
enum { ACTUAL_TYPE = Scalar::Uint8 };
|
||||
static const JSProtoKey key = JSProto_Uint8Array;
|
||||
static const JSFunctionSpec jsfuncs[];
|
||||
static const JSPropertySpec jsprops[];
|
||||
};
|
||||
class Int16ArrayObject : public TypedArrayObjectTemplate<int16_t> {
|
||||
public:
|
||||
enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_INT16 };
|
||||
enum { ACTUAL_TYPE = Scalar::Int16 };
|
||||
static const JSProtoKey key = JSProto_Int16Array;
|
||||
static const JSFunctionSpec jsfuncs[];
|
||||
static const JSPropertySpec jsprops[];
|
||||
};
|
||||
class Uint16ArrayObject : public TypedArrayObjectTemplate<uint16_t> {
|
||||
public:
|
||||
enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_UINT16 };
|
||||
enum { ACTUAL_TYPE = Scalar::Uint16 };
|
||||
static const JSProtoKey key = JSProto_Uint16Array;
|
||||
static const JSFunctionSpec jsfuncs[];
|
||||
static const JSPropertySpec jsprops[];
|
||||
};
|
||||
class Int32ArrayObject : public TypedArrayObjectTemplate<int32_t> {
|
||||
public:
|
||||
enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_INT32 };
|
||||
enum { ACTUAL_TYPE = Scalar::Int32 };
|
||||
static const JSProtoKey key = JSProto_Int32Array;
|
||||
static const JSFunctionSpec jsfuncs[];
|
||||
static const JSPropertySpec jsprops[];
|
||||
};
|
||||
class Uint32ArrayObject : public TypedArrayObjectTemplate<uint32_t> {
|
||||
public:
|
||||
enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_UINT32 };
|
||||
enum { ACTUAL_TYPE = Scalar::Uint32 };
|
||||
static const JSProtoKey key = JSProto_Uint32Array;
|
||||
static const JSFunctionSpec jsfuncs[];
|
||||
static const JSPropertySpec jsprops[];
|
||||
};
|
||||
class Float32ArrayObject : public TypedArrayObjectTemplate<float> {
|
||||
public:
|
||||
enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_FLOAT32 };
|
||||
enum { ACTUAL_TYPE = Scalar::Float32 };
|
||||
static const JSProtoKey key = JSProto_Float32Array;
|
||||
static const JSFunctionSpec jsfuncs[];
|
||||
static const JSPropertySpec jsprops[];
|
||||
};
|
||||
class Float64ArrayObject : public TypedArrayObjectTemplate<double> {
|
||||
public:
|
||||
enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_FLOAT64 };
|
||||
enum { ACTUAL_TYPE = Scalar::Float64 };
|
||||
static const JSProtoKey key = JSProto_Float64Array;
|
||||
static const JSFunctionSpec jsfuncs[];
|
||||
static const JSPropertySpec jsprops[];
|
||||
};
|
||||
class Uint8ClampedArrayObject : public TypedArrayObjectTemplate<uint8_clamped> {
|
||||
public:
|
||||
enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_UINT8_CLAMPED };
|
||||
enum { ACTUAL_TYPE = Scalar::Uint8Clamped };
|
||||
static const JSProtoKey key = JSProto_Uint8ClampedArray;
|
||||
static const JSFunctionSpec jsfuncs[];
|
||||
static const JSPropertySpec jsprops[];
|
||||
@ -1957,31 +1957,31 @@ Value
|
||||
TypedArrayObject::getElement(uint32_t index)
|
||||
{
|
||||
switch (type()) {
|
||||
case ScalarTypeDescr::TYPE_INT8:
|
||||
case Scalar::Int8:
|
||||
return TypedArrayObjectTemplate<int8_t>::getIndexValue(this, index);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT8:
|
||||
case Scalar::Uint8:
|
||||
return TypedArrayObjectTemplate<uint8_t>::getIndexValue(this, index);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT8_CLAMPED:
|
||||
case Scalar::Uint8Clamped:
|
||||
return TypedArrayObjectTemplate<uint8_clamped>::getIndexValue(this, index);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_INT16:
|
||||
case Scalar::Int16:
|
||||
return TypedArrayObjectTemplate<int16_t>::getIndexValue(this, index);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT16:
|
||||
case Scalar::Uint16:
|
||||
return TypedArrayObjectTemplate<uint16_t>::getIndexValue(this, index);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_INT32:
|
||||
case Scalar::Int32:
|
||||
return TypedArrayObjectTemplate<int32_t>::getIndexValue(this, index);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT32:
|
||||
case Scalar::Uint32:
|
||||
return TypedArrayObjectTemplate<uint32_t>::getIndexValue(this, index);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_FLOAT32:
|
||||
case Scalar::Float32:
|
||||
return TypedArrayObjectTemplate<float>::getIndexValue(this, index);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_FLOAT64:
|
||||
case Scalar::Float64:
|
||||
return TypedArrayObjectTemplate<double>::getIndexValue(this, index);
|
||||
break;
|
||||
default:
|
||||
@ -1996,31 +1996,31 @@ TypedArrayObject::setElement(TypedArrayObject &obj, uint32_t index, double d)
|
||||
MOZ_ASSERT(index < obj.length());
|
||||
|
||||
switch (obj.type()) {
|
||||
case ScalarTypeDescr::TYPE_INT8:
|
||||
case Scalar::Int8:
|
||||
TypedArrayObjectTemplate<int8_t>::setIndexValue(obj, index, d);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT8:
|
||||
case Scalar::Uint8:
|
||||
TypedArrayObjectTemplate<uint8_t>::setIndexValue(obj, index, d);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT8_CLAMPED:
|
||||
case Scalar::Uint8Clamped:
|
||||
TypedArrayObjectTemplate<uint8_clamped>::setIndexValue(obj, index, d);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_INT16:
|
||||
case Scalar::Int16:
|
||||
TypedArrayObjectTemplate<int16_t>::setIndexValue(obj, index, d);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT16:
|
||||
case Scalar::Uint16:
|
||||
TypedArrayObjectTemplate<uint16_t>::setIndexValue(obj, index, d);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_INT32:
|
||||
case Scalar::Int32:
|
||||
TypedArrayObjectTemplate<int32_t>::setIndexValue(obj, index, d);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_UINT32:
|
||||
case Scalar::Uint32:
|
||||
TypedArrayObjectTemplate<uint32_t>::setIndexValue(obj, index, d);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_FLOAT32:
|
||||
case Scalar::Float32:
|
||||
TypedArrayObjectTemplate<float>::setIndexValue(obj, index, d);
|
||||
break;
|
||||
case ScalarTypeDescr::TYPE_FLOAT64:
|
||||
case Scalar::Float64:
|
||||
TypedArrayObjectTemplate<double>::setIndexValue(obj, index, d);
|
||||
break;
|
||||
default:
|
||||
@ -2249,7 +2249,7 @@ IMPL_TYPED_ARRAY_STATICS(Float32Array)
|
||||
IMPL_TYPED_ARRAY_STATICS(Float64Array)
|
||||
IMPL_TYPED_ARRAY_STATICS(Uint8ClampedArray)
|
||||
|
||||
const Class TypedArrayObject::classes[ScalarTypeDescr::TYPE_MAX] = {
|
||||
const Class TypedArrayObject::classes[Scalar::TypeMax] = {
|
||||
IMPL_TYPED_ARRAY_FAST_CLASS(Int8Array),
|
||||
IMPL_TYPED_ARRAY_FAST_CLASS(Uint8Array),
|
||||
IMPL_TYPED_ARRAY_FAST_CLASS(Int16Array),
|
||||
@ -2261,7 +2261,7 @@ const Class TypedArrayObject::classes[ScalarTypeDescr::TYPE_MAX] = {
|
||||
IMPL_TYPED_ARRAY_FAST_CLASS(Uint8ClampedArray)
|
||||
};
|
||||
|
||||
const Class TypedArrayObject::protoClasses[ScalarTypeDescr::TYPE_MAX] = {
|
||||
const Class TypedArrayObject::protoClasses[Scalar::TypeMax] = {
|
||||
IMPL_TYPED_ARRAY_PROTO_CLASS(Int8Array),
|
||||
IMPL_TYPED_ARRAY_PROTO_CLASS(Uint8Array),
|
||||
IMPL_TYPED_ARRAY_PROTO_CLASS(Int16Array),
|
||||
@ -2319,26 +2319,26 @@ js_InitArrayBufferClass(JSContext *cx, HandleObject obj)
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
TypedArrayObject::isOriginalLengthGetter(ScalarTypeDescr::Type type, Native native)
|
||||
TypedArrayObject::isOriginalLengthGetter(Scalar::Type type, Native native)
|
||||
{
|
||||
switch (type) {
|
||||
case ScalarTypeDescr::TYPE_INT8:
|
||||
case Scalar::Int8:
|
||||
return native == Int8Array_lengthGetter;
|
||||
case ScalarTypeDescr::TYPE_UINT8:
|
||||
case Scalar::Uint8:
|
||||
return native == Uint8Array_lengthGetter;
|
||||
case ScalarTypeDescr::TYPE_UINT8_CLAMPED:
|
||||
case Scalar::Uint8Clamped:
|
||||
return native == Uint8ClampedArray_lengthGetter;
|
||||
case ScalarTypeDescr::TYPE_INT16:
|
||||
case Scalar::Int16:
|
||||
return native == Int16Array_lengthGetter;
|
||||
case ScalarTypeDescr::TYPE_UINT16:
|
||||
case Scalar::Uint16:
|
||||
return native == Uint16Array_lengthGetter;
|
||||
case ScalarTypeDescr::TYPE_INT32:
|
||||
case Scalar::Int32:
|
||||
return native == Int32Array_lengthGetter;
|
||||
case ScalarTypeDescr::TYPE_UINT32:
|
||||
case Scalar::Uint32:
|
||||
return native == Uint32Array_lengthGetter;
|
||||
case ScalarTypeDescr::TYPE_FLOAT32:
|
||||
case Scalar::Float32:
|
||||
return native == Float32Array_lengthGetter;
|
||||
case ScalarTypeDescr::TYPE_FLOAT64:
|
||||
case Scalar::Float64:
|
||||
return native == Float64Array_lengthGetter;
|
||||
default:
|
||||
MOZ_ASSUME_UNREACHABLE("Unknown TypedArray type");
|
||||
@ -2502,23 +2502,23 @@ bool
|
||||
js::IsTypedArrayConstructor(HandleValue v, uint32_t type)
|
||||
{
|
||||
switch (type) {
|
||||
case ScalarTypeDescr::TYPE_INT8:
|
||||
case Scalar::Int8:
|
||||
return IsNativeFunction(v, Int8ArrayObject::class_constructor);
|
||||
case ScalarTypeDescr::TYPE_UINT8:
|
||||
case Scalar::Uint8:
|
||||
return IsNativeFunction(v, Uint8ArrayObject::class_constructor);
|
||||
case ScalarTypeDescr::TYPE_INT16:
|
||||
case Scalar::Int16:
|
||||
return IsNativeFunction(v, Int16ArrayObject::class_constructor);
|
||||
case ScalarTypeDescr::TYPE_UINT16:
|
||||
case Scalar::Uint16:
|
||||
return IsNativeFunction(v, Uint16ArrayObject::class_constructor);
|
||||
case ScalarTypeDescr::TYPE_INT32:
|
||||
case Scalar::Int32:
|
||||
return IsNativeFunction(v, Int32ArrayObject::class_constructor);
|
||||
case ScalarTypeDescr::TYPE_UINT32:
|
||||
case Scalar::Uint32:
|
||||
return IsNativeFunction(v, Uint32ArrayObject::class_constructor);
|
||||
case ScalarTypeDescr::TYPE_FLOAT32:
|
||||
case Scalar::Float32:
|
||||
return IsNativeFunction(v, Float32ArrayObject::class_constructor);
|
||||
case ScalarTypeDescr::TYPE_FLOAT64:
|
||||
case Scalar::Float64:
|
||||
return IsNativeFunction(v, Float64ArrayObject::class_constructor);
|
||||
case ScalarTypeDescr::TYPE_UINT8_CLAMPED:
|
||||
case Scalar::Uint8Clamped:
|
||||
return IsNativeFunction(v, Uint8ClampedArrayObject::class_constructor);
|
||||
}
|
||||
MOZ_ASSUME_UNREACHABLE("unexpected typed array type");
|
||||
@ -2631,17 +2631,17 @@ JS_GetTypedArrayByteLength(JSObject *obj)
|
||||
return obj->as<TypedArrayObject>().byteLength();
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSArrayBufferViewType)
|
||||
JS_FRIEND_API(js::Scalar::Type)
|
||||
JS_GetArrayBufferViewType(JSObject *obj)
|
||||
{
|
||||
obj = CheckedUnwrap(obj);
|
||||
if (!obj)
|
||||
return ArrayBufferView::TYPE_MAX;
|
||||
return Scalar::TypeMax;
|
||||
|
||||
if (obj->is<TypedArrayObject>())
|
||||
return static_cast<JSArrayBufferViewType>(obj->as<TypedArrayObject>().type());
|
||||
return obj->as<TypedArrayObject>().type();
|
||||
else if (obj->is<DataViewObject>())
|
||||
return ArrayBufferView::TYPE_DATAVIEW;
|
||||
return Scalar::TypeMax;
|
||||
MOZ_ASSUME_UNREACHABLE("invalid ArrayBufferView type");
|
||||
}
|
||||
|
||||
@ -2652,7 +2652,7 @@ JS_GetInt8ArrayData(JSObject *obj)
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
TypedArrayObject *tarr = &obj->as<TypedArrayObject>();
|
||||
JS_ASSERT((int32_t) tarr->type() == ArrayBufferView::TYPE_INT8);
|
||||
JS_ASSERT((int32_t) tarr->type() == Scalar::Int8);
|
||||
return static_cast<int8_t *>(tarr->viewData());
|
||||
}
|
||||
|
||||
@ -2663,7 +2663,7 @@ JS_GetUint8ArrayData(JSObject *obj)
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
TypedArrayObject *tarr = &obj->as<TypedArrayObject>();
|
||||
JS_ASSERT((int32_t) tarr->type() == ArrayBufferView::TYPE_UINT8);
|
||||
JS_ASSERT((int32_t) tarr->type() == Scalar::Uint8);
|
||||
return static_cast<uint8_t *>(tarr->viewData());
|
||||
}
|
||||
|
||||
@ -2674,7 +2674,7 @@ JS_GetUint8ClampedArrayData(JSObject *obj)
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
TypedArrayObject *tarr = &obj->as<TypedArrayObject>();
|
||||
JS_ASSERT((int32_t) tarr->type() == ArrayBufferView::TYPE_UINT8_CLAMPED);
|
||||
JS_ASSERT((int32_t) tarr->type() == Scalar::Uint8Clamped);
|
||||
return static_cast<uint8_t *>(tarr->viewData());
|
||||
}
|
||||
|
||||
@ -2685,7 +2685,7 @@ JS_GetInt16ArrayData(JSObject *obj)
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
TypedArrayObject *tarr = &obj->as<TypedArrayObject>();
|
||||
JS_ASSERT((int32_t) tarr->type() == ArrayBufferView::TYPE_INT16);
|
||||
JS_ASSERT((int32_t) tarr->type() == Scalar::Int16);
|
||||
return static_cast<int16_t *>(tarr->viewData());
|
||||
}
|
||||
|
||||
@ -2696,7 +2696,7 @@ JS_GetUint16ArrayData(JSObject *obj)
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
TypedArrayObject *tarr = &obj->as<TypedArrayObject>();
|
||||
JS_ASSERT((int32_t) tarr->type() == ArrayBufferView::TYPE_UINT16);
|
||||
JS_ASSERT((int32_t) tarr->type() == Scalar::Uint16);
|
||||
return static_cast<uint16_t *>(tarr->viewData());
|
||||
}
|
||||
|
||||
@ -2707,7 +2707,7 @@ JS_GetInt32ArrayData(JSObject *obj)
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
TypedArrayObject *tarr = &obj->as<TypedArrayObject>();
|
||||
JS_ASSERT((int32_t) tarr->type() == ArrayBufferView::TYPE_INT32);
|
||||
JS_ASSERT((int32_t) tarr->type() == Scalar::Int32);
|
||||
return static_cast<int32_t *>(tarr->viewData());
|
||||
}
|
||||
|
||||
@ -2718,7 +2718,7 @@ JS_GetUint32ArrayData(JSObject *obj)
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
TypedArrayObject *tarr = &obj->as<TypedArrayObject>();
|
||||
JS_ASSERT((int32_t) tarr->type() == ArrayBufferView::TYPE_UINT32);
|
||||
JS_ASSERT((int32_t) tarr->type() == Scalar::Uint32);
|
||||
return static_cast<uint32_t *>(tarr->viewData());
|
||||
}
|
||||
|
||||
@ -2729,7 +2729,7 @@ JS_GetFloat32ArrayData(JSObject *obj)
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
TypedArrayObject *tarr = &obj->as<TypedArrayObject>();
|
||||
JS_ASSERT((int32_t) tarr->type() == ArrayBufferView::TYPE_FLOAT32);
|
||||
JS_ASSERT((int32_t) tarr->type() == Scalar::Float32);
|
||||
return static_cast<float *>(tarr->viewData());
|
||||
}
|
||||
|
||||
@ -2740,7 +2740,7 @@ JS_GetFloat64ArrayData(JSObject *obj)
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
TypedArrayObject *tarr = &obj->as<TypedArrayObject>();
|
||||
JS_ASSERT((int32_t) tarr->type() == ArrayBufferView::TYPE_FLOAT64);
|
||||
JS_ASSERT((int32_t) tarr->type() == Scalar::Float64);
|
||||
return static_cast<double *>(tarr->viewData());
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "jsobj.h"
|
||||
|
||||
#include "builtin/TypedObject.h"
|
||||
#include "gc/Barrier.h"
|
||||
#include "js/Class.h"
|
||||
#include "vm/ArrayBufferObject.h"
|
||||
@ -39,8 +38,8 @@ class TypedArrayObject : public ArrayBufferViewObject
|
||||
"bad inlined constant in jsfriendapi.h");
|
||||
|
||||
public:
|
||||
static const Class classes[ScalarTypeDescr::TYPE_MAX];
|
||||
static const Class protoClasses[ScalarTypeDescr::TYPE_MAX];
|
||||
static const Class classes[Scalar::TypeMax];
|
||||
static const Class protoClasses[Scalar::TypeMax];
|
||||
|
||||
static const size_t FIXED_DATA_START = DATA_SLOT + 1;
|
||||
|
||||
@ -59,8 +58,8 @@ class TypedArrayObject : public ArrayBufferViewObject
|
||||
return gc::GetGCObjectKind(FIXED_DATA_START + dataSlots);
|
||||
}
|
||||
|
||||
ScalarTypeDescr::Type type() const {
|
||||
return (ScalarTypeDescr::Type) getFixedSlot(TYPE_SLOT).toInt32();
|
||||
Scalar::Type type() const {
|
||||
return (Scalar::Type) getFixedSlot(TYPE_SLOT).toInt32();
|
||||
}
|
||||
|
||||
static Value bufferValue(TypedArrayObject *tarr) {
|
||||
@ -70,7 +69,7 @@ class TypedArrayObject : public ArrayBufferViewObject
|
||||
return tarr->getFixedSlot(BYTEOFFSET_SLOT);
|
||||
}
|
||||
static Value byteLengthValue(TypedArrayObject *tarr) {
|
||||
int32_t size = ScalarTypeDescr::size(tarr->type());
|
||||
int32_t size = Scalar::byteSize(tarr->type());
|
||||
return Int32Value(tarr->getFixedSlot(LENGTH_SLOT).toInt32() * size);
|
||||
}
|
||||
static Value lengthValue(TypedArrayObject *tarr) {
|
||||
@ -109,28 +108,8 @@ class TypedArrayObject : public ArrayBufferViewObject
|
||||
|
||||
void neuter(void *newData);
|
||||
|
||||
static uint32_t slotWidth(int atype) {
|
||||
switch (atype) {
|
||||
case ScalarTypeDescr::TYPE_INT8:
|
||||
case ScalarTypeDescr::TYPE_UINT8:
|
||||
case ScalarTypeDescr::TYPE_UINT8_CLAMPED:
|
||||
return 1;
|
||||
case ScalarTypeDescr::TYPE_INT16:
|
||||
case ScalarTypeDescr::TYPE_UINT16:
|
||||
return 2;
|
||||
case ScalarTypeDescr::TYPE_INT32:
|
||||
case ScalarTypeDescr::TYPE_UINT32:
|
||||
case ScalarTypeDescr::TYPE_FLOAT32:
|
||||
return 4;
|
||||
case ScalarTypeDescr::TYPE_FLOAT64:
|
||||
return 8;
|
||||
default:
|
||||
MOZ_ASSUME_UNREACHABLE("invalid typed array type");
|
||||
}
|
||||
}
|
||||
|
||||
int slotWidth() {
|
||||
return slotWidth(type());
|
||||
return Scalar::byteSize(type());
|
||||
}
|
||||
|
||||
/*
|
||||
@ -142,21 +121,21 @@ class TypedArrayObject : public ArrayBufferViewObject
|
||||
static int lengthOffset();
|
||||
static int dataOffset();
|
||||
|
||||
static bool isOriginalLengthGetter(ScalarTypeDescr::Type type, Native native);
|
||||
static bool isOriginalLengthGetter(Scalar::Type type, Native native);
|
||||
};
|
||||
|
||||
inline bool
|
||||
IsTypedArrayClass(const Class *clasp)
|
||||
{
|
||||
return &TypedArrayObject::classes[0] <= clasp &&
|
||||
clasp < &TypedArrayObject::classes[ScalarTypeDescr::TYPE_MAX];
|
||||
clasp < &TypedArrayObject::classes[Scalar::TypeMax];
|
||||
}
|
||||
|
||||
inline bool
|
||||
IsTypedArrayProtoClass(const Class *clasp)
|
||||
{
|
||||
return &TypedArrayObject::protoClasses[0] <= clasp &&
|
||||
clasp < &TypedArrayObject::protoClasses[ScalarTypeDescr::TYPE_MAX];
|
||||
clasp < &TypedArrayObject::protoClasses[Scalar::TypeMax];
|
||||
}
|
||||
|
||||
bool
|
||||
@ -206,21 +185,21 @@ IsTypedArrayIndex(jsid id, uint64_t *indexp)
|
||||
}
|
||||
|
||||
static inline unsigned
|
||||
TypedArrayShift(ArrayBufferView::ViewType viewType)
|
||||
TypedArrayShift(Scalar::Type viewType)
|
||||
{
|
||||
switch (viewType) {
|
||||
case ArrayBufferView::TYPE_INT8:
|
||||
case ArrayBufferView::TYPE_UINT8:
|
||||
case ArrayBufferView::TYPE_UINT8_CLAMPED:
|
||||
case Scalar::Int8:
|
||||
case Scalar::Uint8:
|
||||
case Scalar::Uint8Clamped:
|
||||
return 0;
|
||||
case ArrayBufferView::TYPE_INT16:
|
||||
case ArrayBufferView::TYPE_UINT16:
|
||||
case Scalar::Int16:
|
||||
case Scalar::Uint16:
|
||||
return 1;
|
||||
case ArrayBufferView::TYPE_INT32:
|
||||
case ArrayBufferView::TYPE_UINT32:
|
||||
case ArrayBufferView::TYPE_FLOAT32:
|
||||
case Scalar::Int32:
|
||||
case Scalar::Uint32:
|
||||
case Scalar::Float32:
|
||||
return 2;
|
||||
case ArrayBufferView::TYPE_FLOAT64:
|
||||
case Scalar::Float64:
|
||||
return 3;
|
||||
default:;
|
||||
}
|
||||
|
@ -1461,7 +1461,7 @@ XPCConvert::JSTypedArray2Native(void** d,
|
||||
void* output = nullptr;
|
||||
|
||||
switch (JS_GetArrayBufferViewType(jsArray)) {
|
||||
case js::ArrayBufferView::TYPE_INT8:
|
||||
case js::Scalar::Int8:
|
||||
if (!CheckTargetAndPopulate(nsXPTType::T_I8, type,
|
||||
sizeof(int8_t), count,
|
||||
jsArray, &output, pErr)) {
|
||||
@ -1469,8 +1469,8 @@ XPCConvert::JSTypedArray2Native(void** d,
|
||||
}
|
||||
break;
|
||||
|
||||
case js::ArrayBufferView::TYPE_UINT8:
|
||||
case js::ArrayBufferView::TYPE_UINT8_CLAMPED:
|
||||
case js::Scalar::Uint8:
|
||||
case js::Scalar::Uint8Clamped:
|
||||
if (!CheckTargetAndPopulate(nsXPTType::T_U8, type,
|
||||
sizeof(uint8_t), count,
|
||||
jsArray, &output, pErr)) {
|
||||
@ -1478,7 +1478,7 @@ XPCConvert::JSTypedArray2Native(void** d,
|
||||
}
|
||||
break;
|
||||
|
||||
case js::ArrayBufferView::TYPE_INT16:
|
||||
case js::Scalar::Int16:
|
||||
if (!CheckTargetAndPopulate(nsXPTType::T_I16, type,
|
||||
sizeof(int16_t), count,
|
||||
jsArray, &output, pErr)) {
|
||||
@ -1486,7 +1486,7 @@ XPCConvert::JSTypedArray2Native(void** d,
|
||||
}
|
||||
break;
|
||||
|
||||
case js::ArrayBufferView::TYPE_UINT16:
|
||||
case js::Scalar::Uint16:
|
||||
if (!CheckTargetAndPopulate(nsXPTType::T_U16, type,
|
||||
sizeof(uint16_t), count,
|
||||
jsArray, &output, pErr)) {
|
||||
@ -1494,7 +1494,7 @@ XPCConvert::JSTypedArray2Native(void** d,
|
||||
}
|
||||
break;
|
||||
|
||||
case js::ArrayBufferView::TYPE_INT32:
|
||||
case js::Scalar::Int32:
|
||||
if (!CheckTargetAndPopulate(nsXPTType::T_I32, type,
|
||||
sizeof(int32_t), count,
|
||||
jsArray, &output, pErr)) {
|
||||
@ -1502,7 +1502,7 @@ XPCConvert::JSTypedArray2Native(void** d,
|
||||
}
|
||||
break;
|
||||
|
||||
case js::ArrayBufferView::TYPE_UINT32:
|
||||
case js::Scalar::Uint32:
|
||||
if (!CheckTargetAndPopulate(nsXPTType::T_U32, type,
|
||||
sizeof(uint32_t), count,
|
||||
jsArray, &output, pErr)) {
|
||||
@ -1510,7 +1510,7 @@ XPCConvert::JSTypedArray2Native(void** d,
|
||||
}
|
||||
break;
|
||||
|
||||
case js::ArrayBufferView::TYPE_FLOAT32:
|
||||
case js::Scalar::Float32:
|
||||
if (!CheckTargetAndPopulate(nsXPTType::T_FLOAT, type,
|
||||
sizeof(float), count,
|
||||
jsArray, &output, pErr)) {
|
||||
@ -1518,7 +1518,7 @@ XPCConvert::JSTypedArray2Native(void** d,
|
||||
}
|
||||
break;
|
||||
|
||||
case js::ArrayBufferView::TYPE_FLOAT64:
|
||||
case js::Scalar::Float64:
|
||||
if (!CheckTargetAndPopulate(nsXPTType::T_DOUBLE, type,
|
||||
sizeof(double), count,
|
||||
jsArray, &output, pErr)) {
|
||||
|
Loading…
Reference in New Issue
Block a user