diff --git a/js/src/builtin/SIMD.cpp b/js/src/builtin/SIMD.cpp index 2cd01f70a84..23d62bd760e 100644 --- a/js/src/builtin/SIMD.cpp +++ b/js/src/builtin/SIMD.cpp @@ -47,7 +47,7 @@ extern const JSFunctionSpec Int32x4Methods[]; } \ TypedDatum &datum = args.thisv().toObject().as(); \ TypeRepresentation *typeRepr = datum.typeRepresentation(); \ - if (typeRepr->kind() != TypeRepresentation::X4 || typeRepr->asX4()->type() != Type32x4::type) { \ + if (typeRepr->kind() != TypeDescr::X4 || typeRepr->asX4()->type() != Type32x4::type) { \ JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, \ X4TypeDescr::class_.name, laneNames[lane], \ InformalValueTypeName(args.thisv())); \ @@ -78,7 +78,7 @@ extern const JSFunctionSpec Int32x4Methods[]; } \ TypedDatum &datum = args.thisv().toObject().as(); \ TypeRepresentation *typeRepr = datum.typeRepresentation(); \ - if (typeRepr->kind() != TypeRepresentation::X4 || typeRepr->asX4()->type() != Type32x4::type) { \ + if (typeRepr->kind() != TypeDescr::X4 || typeRepr->asX4()->type() != Type32x4::type) { \ JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, \ X4TypeDescr::class_.name, "signMask", \ InformalValueTypeName(args.thisv())); \ @@ -118,14 +118,14 @@ const Class X4TypeDescr::class_ = { namespace js { class Int32x4Defn { public: - static const X4TypeRepresentation::Type type = X4TypeRepresentation::TYPE_INT32; + static const X4TypeDescr::Type type = X4TypeDescr::TYPE_INT32; static const JSFunctionSpec TypeDescriptorMethods[]; static const JSPropertySpec TypedDatumProperties[]; static const JSFunctionSpec TypedDatumMethods[]; }; class Float32x4Defn { public: - static const X4TypeRepresentation::Type type = X4TypeRepresentation::TYPE_FLOAT32; + static const X4TypeDescr::Type type = X4TypeDescr::TYPE_FLOAT32; static const JSFunctionSpec TypeDescriptorMethods[]; static const JSPropertySpec TypedDatumProperties[]; static const JSFunctionSpec TypedDatumMethods[]; @@ -368,7 +368,7 @@ ObjectIsVector(JSObject &obj) { if (!obj.is()) return false; TypeRepresentation *typeRepr = obj.as().typeRepresentation(); - if (typeRepr->kind() != TypeRepresentation::X4) + if (typeRepr->kind() != TypeDescr::X4) return false; return typeRepr->asX4()->type() == V::type; } diff --git a/js/src/builtin/SIMD.h b/js/src/builtin/SIMD.h index 487a1dde249..a81f743dcc3 100644 --- a/js/src/builtin/SIMD.h +++ b/js/src/builtin/SIMD.h @@ -33,8 +33,8 @@ class SIMDObject : public JSObject struct Float32x4 { typedef float Elem; static const int32_t lanes = 4; - static const X4TypeRepresentation::Type type = - X4TypeRepresentation::TYPE_FLOAT32; + static const X4TypeDescr::Type type = + X4TypeDescr::TYPE_FLOAT32; static TypeDescr &GetTypeDescr(GlobalObject &global) { return global.float32x4TypeDescr().as(); @@ -53,8 +53,8 @@ struct Float32x4 { struct Int32x4 { typedef int32_t Elem; static const int32_t lanes = 4; - static const X4TypeRepresentation::Type type = - X4TypeRepresentation::TYPE_INT32; + static const X4TypeDescr::Type type = + X4TypeDescr::TYPE_INT32; static TypeDescr &GetTypeDescr(GlobalObject &global) { return global.int32x4TypeDescr().as(); diff --git a/js/src/builtin/TypeRepresentation.cpp b/js/src/builtin/TypeRepresentation.cpp index be93e57bb6a..9eac851cd62 100644 --- a/js/src/builtin/TypeRepresentation.cpp +++ b/js/src/builtin/TypeRepresentation.cpp @@ -56,23 +56,23 @@ TypeRepresentationHasher::match(TypeRepresentation *key1, return false; switch (key1->kind()) { - case TypeRepresentation::Scalar: + case TypeDescr::Scalar: return matchScalars(key1->asScalar(), key2->asScalar()); - case TypeRepresentation::Reference: + case TypeDescr::Reference: return matchReferences(key1->asReference(), key2->asReference()); - case TypeRepresentation::X4: + case TypeDescr::X4: return matchX4s(key1->asX4(), key2->asX4()); - case TypeRepresentation::Struct: + case TypeDescr::Struct: return matchStructs(key1->asStruct(), key2->asStruct()); - case TypeRepresentation::SizedArray: + case TypeDescr::SizedArray: return matchSizedArrays(key1->asSizedArray(), key2->asSizedArray()); - case TypeRepresentation::UnsizedArray: + case TypeDescr::UnsizedArray: return matchUnsizedArrays(key1->asUnsizedArray(), key2->asUnsizedArray()); } @@ -139,22 +139,22 @@ TypeRepresentationHasher::matchUnsizedArrays(UnsizedArrayTypeRepresentation *key HashNumber TypeRepresentationHasher::hash(TypeRepresentation *key) { switch (key->kind()) { - case TypeRepresentation::Scalar: + case TypeDescr::Scalar: return hashScalar(key->asScalar()); - case TypeRepresentation::Reference: + case TypeDescr::Reference: return hashReference(key->asReference()); - case TypeRepresentation::X4: + case TypeDescr::X4: return hashX4(key->asX4()); - case TypeRepresentation::Struct: + case TypeDescr::Struct: return hashStruct(key->asStruct()); - case TypeRepresentation::UnsizedArray: + case TypeDescr::UnsizedArray: return hashUnsizedArray(key->asUnsizedArray()); - case TypeRepresentation::SizedArray: + case TypeDescr::SizedArray: return hashSizedArray(key->asSizedArray()); } @@ -205,39 +205,25 @@ TypeRepresentationHasher::hashUnsizedArray(UnsizedArrayTypeRepresentation *key) /////////////////////////////////////////////////////////////////////////// // Constructors -TypeRepresentation::TypeRepresentation(Kind kind, bool opaque) +TypeRepresentation::TypeRepresentation(TypeDescr::Kind kind, bool opaque) : kind_(kind), opaque_(opaque) {} -SizedTypeRepresentation::SizedTypeRepresentation(Kind kind, bool opaque, - size_t size, size_t align) +SizedTypeRepresentation::SizedTypeRepresentation(SizedTypeDescr::Kind kind, + bool opaque, + size_t size, + size_t align) : TypeRepresentation(kind, opaque), size_(size), alignment_(align) {} -static size_t ScalarSizes[] = { -#define SCALAR_SIZE(_kind, _type, _name) \ - sizeof(_type), - JS_FOR_EACH_SCALAR_TYPE_REPR(SCALAR_SIZE) 0 -#undef SCALAR_SIZE -}; - -size_t -ScalarTypeRepresentation::size(Type t) -{ - return ScalarSizes[t]; -} - -size_t -ScalarTypeRepresentation::alignment(Type t) -{ - return ScalarSizes[t]; -} - -ScalarTypeRepresentation::ScalarTypeRepresentation(Type type) - : SizedTypeRepresentation(Scalar, false, ScalarSizes[type], ScalarSizes[type]), +ScalarTypeRepresentation::ScalarTypeRepresentation(ScalarTypeDescr::Type type) + : SizedTypeRepresentation(TypeDescr::Scalar, + false, + ScalarTypeDescr::size(type), + ScalarTypeDescr::alignment(type)), type_(type) { } @@ -249,24 +235,24 @@ static size_t X4Sizes[] = { #undef X4_SIZE }; -X4TypeRepresentation::X4TypeRepresentation(Type type) - : SizedTypeRepresentation(X4, false, X4Sizes[type], X4Sizes[type]), +X4TypeRepresentation::X4TypeRepresentation(X4TypeDescr::Type type) + : SizedTypeRepresentation(X4TypeDescr::X4, false, X4Sizes[type], X4Sizes[type]), type_(type) { } -ReferenceTypeRepresentation::ReferenceTypeRepresentation(Type type) - : SizedTypeRepresentation(Reference, true, 0, 1), +ReferenceTypeRepresentation::ReferenceTypeRepresentation(ReferenceTypeDescr::Type type) + : SizedTypeRepresentation(TypeDescr::Reference, true, 0, 1), type_(type) { switch (type) { - case TYPE_ANY: + case ReferenceTypeDescr::TYPE_ANY: size_ = sizeof(js::HeapValue); alignment_ = MOZ_ALIGNOF(js::HeapValue); break; - case TYPE_OBJECT: - case TYPE_STRING: + case ReferenceTypeDescr::TYPE_OBJECT: + case ReferenceTypeDescr::TYPE_STRING: size_ = sizeof(js::HeapPtrObject); alignment_ = MOZ_ALIGNOF(js::HeapPtrObject); break; @@ -275,7 +261,7 @@ ReferenceTypeRepresentation::ReferenceTypeRepresentation(Type type) SizedArrayTypeRepresentation::SizedArrayTypeRepresentation(SizedTypeRepresentation *element, size_t length) - : SizedTypeRepresentation(SizedArray, element->opaque(), + : SizedTypeRepresentation(TypeDescr::SizedArray, element->opaque(), element->size() * length, element->alignment()), element_(element), length_(length) @@ -283,7 +269,7 @@ SizedArrayTypeRepresentation::SizedArrayTypeRepresentation(SizedTypeRepresentati } UnsizedArrayTypeRepresentation::UnsizedArrayTypeRepresentation(SizedTypeRepresentation *element) - : TypeRepresentation(UnsizedArray, element->opaque()), + : TypeRepresentation(TypeDescr::UnsizedArray, element->opaque()), element_(element) { } @@ -304,7 +290,7 @@ StructField::StructField(size_t index, {} StructTypeRepresentation::StructTypeRepresentation() - : SizedTypeRepresentation(Struct, false, 0, 1), + : SizedTypeRepresentation(TypeDescr::Struct, false, 0, 1), fieldCount_(0) // see ::init() below! { // note: size_, alignment_, and opaque_ are computed in ::init() below @@ -428,30 +414,30 @@ TypeRepresentation::addToTableOrFree(JSContext *cx, } switch (kind()) { - case UnsizedArray: + case TypeDescr::UnsizedArray: break; - case SizedArray: + case TypeDescr::SizedArray: ownerObject->initReservedSlot(JS_TYPEREPR_SLOT_LENGTH, Int32Value(asSizedArray()->length())); break; - case Scalar: + case TypeDescr::Scalar: ownerObject->initReservedSlot(JS_TYPEREPR_SLOT_TYPE, Int32Value(asScalar()->type())); break; - case Reference: + case TypeDescr::Reference: ownerObject->initReservedSlot(JS_TYPEREPR_SLOT_TYPE, Int32Value(asReference()->type())); break; - case X4: + case TypeDescr::X4: ownerObject->initReservedSlot(JS_TYPEREPR_SLOT_TYPE, Int32Value(asX4()->type())); break; - case Struct: + case TypeDescr::Struct: break; } @@ -463,8 +449,8 @@ TypeRepresentation::addToTableOrFree(JSContext *cx, namespace js { class TypeRepresentationHelper { public: - template - static JSObject *CreateSimple(JSContext *cx, typename T::Type type) { + template + static JSObject *CreateSimple(JSContext *cx, typename D::Type type) { JSCompartment *comp = cx->compartment(); TypeRepresentationHash::AddPtr p; @@ -489,23 +475,25 @@ class TypeRepresentationHelper { /*static*/ JSObject * ScalarTypeRepresentation::Create(JSContext *cx, - ScalarTypeRepresentation::Type type) + ScalarTypeDescr::Type type) { - return TypeRepresentationHelper::CreateSimple(cx, type); + return TypeRepresentationHelper::CreateSimple(cx, type); } /*static*/ JSObject * X4TypeRepresentation::Create(JSContext *cx, - X4TypeRepresentation::Type type) + X4TypeDescr::Type type) { - return TypeRepresentationHelper::CreateSimple(cx, type); + return TypeRepresentationHelper::CreateSimple(cx, type); } /*static*/ JSObject * ReferenceTypeRepresentation::Create(JSContext *cx, - ReferenceTypeRepresentation::Type type) + ReferenceTypeDescr::Type type) { JSCompartment *comp = cx->compartment(); @@ -644,20 +632,20 @@ TypeRepresentation::traceFields(JSTracer *trace) mark(trace); // don't forget to mark the self-reference here! switch (kind()) { - case Scalar: - case Reference: - case X4: + case TypeDescr::Scalar: + case TypeDescr::Reference: + case TypeDescr::X4: break; - case Struct: + case TypeDescr::Struct: asStruct()->traceStructFields(trace); break; - case SizedArray: + case TypeDescr::SizedArray: asSizedArray()->traceSizedArrayFields(trace); break; - case UnsizedArray: + case TypeDescr::UnsizedArray: asUnsizedArray()->traceUnsizedArrayFields(trace); break; } @@ -698,31 +686,6 @@ TypeRepresentation::obj_finalize(js::FreeOp *fop, JSObject *object) js_free(typeRepr); } -/////////////////////////////////////////////////////////////////////////// -// To string - -/*static*/ const char * -ScalarTypeRepresentation::typeName(Type type) -{ - switch (type) { -#define NUMERIC_TYPE_TO_STRING(constant_, type_, name_) \ - case constant_: return #name_; - JS_FOR_EACH_SCALAR_TYPE_REPR(NUMERIC_TYPE_TO_STRING) - } - MOZ_ASSUME_UNREACHABLE("Invalid type"); -} - -/*static*/ const char * -ReferenceTypeRepresentation::typeName(Type type) -{ - switch (type) { -#define NUMERIC_TYPE_TO_STRING(constant_, type_, name_) \ - case constant_: return #name_; - JS_FOR_EACH_REFERENCE_TYPE_REPR(NUMERIC_TYPE_TO_STRING) - } - MOZ_ASSUME_UNREACHABLE("Invalid type"); -} - /////////////////////////////////////////////////////////////////////////// // Walking memory @@ -736,15 +699,15 @@ visitReferences(SizedTypeRepresentation *repr, return; switch (repr->kind()) { - case TypeRepresentation::Scalar: - case TypeRepresentation::X4: + case TypeDescr::Scalar: + case TypeDescr::X4: return; - case TypeRepresentation::Reference: + case TypeDescr::Reference: visitor.visitReference(repr->asReference(), mem); return; - case TypeRepresentation::SizedArray: + case TypeDescr::SizedArray: { SizedArrayTypeRepresentation *arrayRepr = repr->asSizedArray(); SizedTypeRepresentation *elementRepr = arrayRepr->element(); @@ -755,12 +718,12 @@ visitReferences(SizedTypeRepresentation *repr, return; } - case TypeRepresentation::UnsizedArray: + case TypeDescr::UnsizedArray: { MOZ_ASSUME_UNREACHABLE("Only Sized Type representations"); } - case TypeRepresentation::Struct: + case TypeDescr::Struct: { StructTypeRepresentation *structRepr = repr->asStruct(); for (size_t i = 0; i < structRepr->fieldCount(); i++) { @@ -794,14 +757,14 @@ void js::MemoryInitVisitor::visitReference(ReferenceTypeRepresentation *repr, uint8_t *mem) { switch (repr->type()) { - case ReferenceTypeRepresentation::TYPE_ANY: + case ReferenceTypeDescr::TYPE_ANY: { js::HeapValue *heapValue = reinterpret_cast(mem); heapValue->init(UndefinedValue()); return; } - case ReferenceTypeRepresentation::TYPE_OBJECT: + case ReferenceTypeDescr::TYPE_OBJECT: { js::HeapPtrObject *objectPtr = reinterpret_cast(mem); @@ -809,7 +772,7 @@ js::MemoryInitVisitor::visitReference(ReferenceTypeRepresentation *repr, uint8_t return; } - case ReferenceTypeRepresentation::TYPE_STRING: + case ReferenceTypeDescr::TYPE_STRING: { js::HeapPtrString *stringPtr = reinterpret_cast(mem); @@ -864,14 +827,14 @@ void js::MemoryTracingVisitor::visitReference(ReferenceTypeRepresentation *repr, uint8_t *mem) { switch (repr->type()) { - case ReferenceTypeRepresentation::TYPE_ANY: + case ReferenceTypeDescr::TYPE_ANY: { js::HeapValue *heapValue = reinterpret_cast(mem); gc::MarkValue(trace_, heapValue, "reference-val"); return; } - case ReferenceTypeRepresentation::TYPE_OBJECT: + case ReferenceTypeDescr::TYPE_OBJECT: { js::HeapPtrObject *objectPtr = reinterpret_cast(mem); @@ -880,7 +843,7 @@ js::MemoryTracingVisitor::visitReference(ReferenceTypeRepresentation *repr, uint return; } - case ReferenceTypeRepresentation::TYPE_STRING: + case ReferenceTypeDescr::TYPE_STRING: { js::HeapPtrString *stringPtr = reinterpret_cast(mem); diff --git a/js/src/builtin/TypeRepresentation.h b/js/src/builtin/TypeRepresentation.h index a3f5f55fd6e..8d61f7c6828 100644 --- a/js/src/builtin/TypeRepresentation.h +++ b/js/src/builtin/TypeRepresentation.h @@ -70,6 +70,7 @@ #include "jscntxt.h" #include "jspubtd.h" +#include "builtin/TypedObject.h" #include "builtin/TypedObjectConstants.h" #include "gc/Barrier.h" #include "js/HashTable.h" @@ -123,23 +124,13 @@ typedef js::HashSet JS_TYPEREPR_MAX_UNSIZED_KIND; - } - bool isSized() const { - return isSized(kind()); + return TypeDescr::isSized(kind()); } inline SizedTypeRepresentation *asSized(); bool isScalar() const { - return kind() == Scalar; + return kind() == TypeDescr::Scalar; } inline ScalarTypeRepresentation *asScalar(); bool isReference() const { - return kind() == Reference; + return kind() == TypeDescr::Reference; } inline ReferenceTypeRepresentation *asReference(); bool isX4() const { - return kind() == X4; + return kind() == TypeDescr::X4; } inline X4TypeRepresentation *asX4(); bool isSizedArray() const { - return kind() == SizedArray; + return kind() == TypeDescr::SizedArray; } inline SizedArrayTypeRepresentation *asSizedArray(); bool isUnsizedArray() const { - return kind() == UnsizedArray; + return kind() == TypeDescr::UnsizedArray; } inline UnsizedArrayTypeRepresentation *asUnsizedArray(); @@ -208,7 +195,7 @@ class TypeRepresentation { } bool isStruct() const { - return kind() == Struct; + return kind() == TypeDescr::Struct; } inline StructTypeRepresentation *asStruct(); @@ -218,7 +205,7 @@ class TypeRepresentation { class SizedTypeRepresentation : public TypeRepresentation { protected: - SizedTypeRepresentation(Kind kind, bool opaque, size_t size, size_t align); + SizedTypeRepresentation(TypeDescr::Kind kind, bool opaque, size_t size, size_t align); size_t size_; size_t alignment_; @@ -236,129 +223,61 @@ class SizedTypeRepresentation : public TypeRepresentation { }; class ScalarTypeRepresentation : public SizedTypeRepresentation { - 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; - private: // in order to call constructor friend class TypeRepresentationHelper; - const Type type_; + const ScalarTypeDescr::Type type_; - explicit ScalarTypeRepresentation(Type type); + explicit ScalarTypeRepresentation(ScalarTypeDescr::Type type); public: - static size_t size(Type t); - static size_t alignment(Type t); - - Type type() const { + ScalarTypeDescr::Type type() const { return type_; } const char *typeName() const { - return typeName(type()); + return ScalarTypeDescr::typeName(type()); } - static const char *typeName(Type type); - static JSObject *Create(JSContext *cx, Type type); + static JSObject *Create(JSContext *cx, ScalarTypeDescr::Type type); }; -// Enumerates the cases of ScalarTypeRepresentation::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_(ScalarTypeRepresentation::TYPE_INT8, int8_t, int8) \ - macro_(ScalarTypeRepresentation::TYPE_UINT8, uint8_t, uint8) \ - macro_(ScalarTypeRepresentation::TYPE_INT16, int16_t, int16) \ - macro_(ScalarTypeRepresentation::TYPE_UINT16, uint16_t, uint16) \ - macro_(ScalarTypeRepresentation::TYPE_INT32, int32_t, int32) \ - macro_(ScalarTypeRepresentation::TYPE_UINT32, uint32_t, uint32) \ - macro_(ScalarTypeRepresentation::TYPE_FLOAT32, float, float32) \ - macro_(ScalarTypeRepresentation::TYPE_FLOAT64, double, float64) - -// Must be in same order as the enum ScalarTypeRepresentation::Type: -#define JS_FOR_EACH_SCALAR_TYPE_REPR(macro_) \ - JS_FOR_EACH_UNIQUE_SCALAR_TYPE_REPR_CTYPE(macro_) \ - macro_(ScalarTypeRepresentation::TYPE_UINT8_CLAMPED, uint8_t, uint8Clamped) - class ReferenceTypeRepresentation : public SizedTypeRepresentation { - public: - // Must match order of JS_FOR_EACH_REFERENCE_TYPE_REPR below - enum Type { - TYPE_ANY = JS_REFERENCETYPEREPR_ANY, - TYPE_OBJECT = JS_REFERENCETYPEREPR_OBJECT, - TYPE_STRING = JS_REFERENCETYPEREPR_STRING, - }; - static const int32_t TYPE_MAX = TYPE_STRING + 1; - private: - Type type_; + ReferenceTypeDescr::Type type_; - explicit ReferenceTypeRepresentation(Type type); + explicit ReferenceTypeRepresentation(ReferenceTypeDescr::Type type); public: - Type type() const { + ReferenceTypeDescr::Type type() const { return type_; } const char *typeName() const { - return typeName(type()); + return ReferenceTypeDescr::typeName(type()); } - static const char *typeName(Type type); - static JSObject *Create(JSContext *cx, Type type); + static JSObject *Create(JSContext *cx, ReferenceTypeDescr::Type type); }; -#define JS_FOR_EACH_REFERENCE_TYPE_REPR(macro_) \ - macro_(ReferenceTypeRepresentation::TYPE_ANY, HeapValue, Any) \ - macro_(ReferenceTypeRepresentation::TYPE_OBJECT, HeapPtrObject, Object) \ - macro_(ReferenceTypeRepresentation::TYPE_STRING, HeapPtrString, string) - class X4TypeRepresentation : public SizedTypeRepresentation { - public: - enum Type { - TYPE_INT32 = JS_X4TYPEREPR_INT32, - TYPE_FLOAT32 = JS_X4TYPEREPR_FLOAT32, - }; - private: // in order to call constructor friend class TypeRepresentationHelper; - const Type type_; + const X4TypeDescr::Type type_; - explicit X4TypeRepresentation(Type type); + explicit X4TypeRepresentation(X4TypeDescr::Type type); public: - Type type() const { + X4TypeDescr::Type type() const { return type_; } - static JSObject *Create(JSContext *cx, Type type); + static JSObject *Create(JSContext *cx, X4TypeDescr::Type type); }; -// Must be in same order as the enum ScalarTypeRepresentation::Type: -#define JS_FOR_EACH_X4_TYPE_REPR(macro_) \ - macro_(X4TypeRepresentation::TYPE_INT32, int32_t, int32) \ - macro_(X4TypeRepresentation::TYPE_FLOAT32, float, float32) - class UnsizedArrayTypeRepresentation : public TypeRepresentation { private: // so TypeRepresentation can call tracing routines diff --git a/js/src/builtin/TypedObject.cpp b/js/src/builtin/TypedObject.cpp index 3a12ef61bf0..2412dfe3925 100644 --- a/js/src/builtin/TypedObject.cpp +++ b/js/src/builtin/TypedObject.cpp @@ -174,6 +174,20 @@ GetPrototype(JSContext *cx, HandleObject obj) return &prototypeVal.toObject(); } +/*************************************************************************** + * Type descriptors + */ + +TypeRepresentation * +TypeDescr::typeRepresentation() const { + return TypeRepresentation::fromOwnerObject(typeRepresentationOwnerObj()); +} + +TypeDescr::Kind +TypeDescr::kind() const { + return typeRepresentation()->kind(); +} + /*************************************************************************** * Scalar type objects * @@ -208,6 +222,36 @@ const JSFunctionSpec js::ScalarTypeDescr::typeObjectMethods[] = { JS_FS_END }; +static size_t ScalarSizes[] = { +#define SCALAR_SIZE(_kind, _type, _name) \ + sizeof(_type), + JS_FOR_EACH_SCALAR_TYPE_REPR(SCALAR_SIZE) 0 +#undef SCALAR_SIZE +}; + +size_t +ScalarTypeDescr::size(Type t) +{ + return ScalarSizes[t]; +} + +size_t +ScalarTypeDescr::alignment(Type t) +{ + return ScalarSizes[t]; +} + +/*static*/ const char * +ScalarTypeDescr::typeName(Type type) +{ + switch (type) { +#define NUMERIC_TYPE_TO_STRING(constant_, type_, name_) \ + case constant_: return #name_; + JS_FOR_EACH_SCALAR_TYPE_REPR(NUMERIC_TYPE_TO_STRING) + } + MOZ_ASSUME_UNREACHABLE("Invalid type"); +} + bool ScalarTypeDescr::call(JSContext *cx, unsigned argc, Value *vp) { @@ -220,13 +264,13 @@ ScalarTypeDescr::call(JSContext *cx, unsigned argc, Value *vp) ScalarTypeRepresentation *typeRepr = args.callee().as().typeRepresentation()->asScalar(); - ScalarTypeRepresentation::Type type = typeRepr->type(); + ScalarTypeDescr::Type type = typeRepr->type(); double number; if (!ToNumber(cx, args[0], &number)) return false; - if (type == ScalarTypeRepresentation::TYPE_UINT8_CLAMPED) + if (type == ScalarTypeDescr::TYPE_UINT8_CLAMPED) number = ClampDoubleToUint8(number); switch (type) { @@ -279,6 +323,17 @@ const JSFunctionSpec js::ReferenceTypeDescr::typeObjectMethods[] = { JS_FS_END }; +/*static*/ const char * +ReferenceTypeDescr::typeName(Type type) +{ + switch (type) { +#define NUMERIC_TYPE_TO_STRING(constant_, type_, name_) \ + case constant_: return #name_; + JS_FOR_EACH_REFERENCE_TYPE_REPR(NUMERIC_TYPE_TO_STRING) + } + MOZ_ASSUME_UNREACHABLE("Invalid type"); +} + bool js::ReferenceTypeDescr::call(JSContext *cx, unsigned argc, Value *vp) { @@ -296,11 +351,11 @@ js::ReferenceTypeDescr::call(JSContext *cx, unsigned argc, Value *vp) } switch (typeRepr->type()) { - case ReferenceTypeRepresentation::TYPE_ANY: + case ReferenceTypeDescr::TYPE_ANY: args.rval().set(args[0]); return true; - case ReferenceTypeRepresentation::TYPE_OBJECT: + case ReferenceTypeDescr::TYPE_OBJECT: { RootedObject obj(cx, ToObject(cx, args[0])); if (!obj) @@ -309,7 +364,7 @@ js::ReferenceTypeDescr::call(JSContext *cx, unsigned argc, Value *vp) return true; } - case ReferenceTypeRepresentation::TYPE_STRING: + case ReferenceTypeDescr::TYPE_STRING: { RootedString obj(cx, ToString(cx, args[0])); if (!obj) @@ -582,7 +637,8 @@ ArrayMetaTypeDescr::construct(JSContext *cx, unsigned argc, Value *vp) Rooted elementType(cx); elementType = &args[0].toObject().as(); - SizedTypeRepresentation *elementTypeRepr = elementType->typeRepresentation(); + SizedTypeRepresentation *elementTypeRepr = + elementType->typeRepresentation()->asSized(); // construct the type repr RootedObject arrayTypeReprObj( @@ -1020,7 +1076,7 @@ static bool DefineSimpleTypeDescr(JSContext *cx, Handle global, HandleObject module, - typename T::TypeRepr::Type type, + typename T::Type type, HandlePropertyName className) { RootedObject funcProto(cx, global->getOrCreateFunctionPrototype(cx)); @@ -1255,39 +1311,39 @@ js_InitTypedObjectDummy(JSContext *cx, HandleObject obj) */ /*static*/ bool TypedObjectModuleObject::getSuitableClaspAndProto(JSContext *cx, - TypeRepresentation::Kind kind, + TypeDescr::Kind kind, const Class **clasp, MutableHandleObject proto) { Rooted global(cx, cx->global()); JS_ASSERT(global); switch (kind) { - case TypeRepresentation::Scalar: + case TypeDescr::Scalar: *clasp = &ScalarTypeDescr::class_; proto.set(global->getOrCreateFunctionPrototype(cx)); break; - case TypeRepresentation::Reference: + case TypeDescr::Reference: *clasp = &ReferenceTypeDescr::class_; proto.set(global->getOrCreateFunctionPrototype(cx)); break; - case TypeRepresentation::X4: + case TypeDescr::X4: *clasp = &X4TypeDescr::class_; proto.set(global->getOrCreateFunctionPrototype(cx)); break; - case TypeRepresentation::Struct: + case TypeDescr::Struct: *clasp = &StructTypeDescr::class_; proto.set(&global->getTypedObjectModule().getSlot(StructTypePrototype).toObject()); break; - case TypeRepresentation::SizedArray: + case TypeDescr::SizedArray: *clasp = &SizedArrayTypeDescr::class_; proto.set(&global->getTypedObjectModule().getSlot(ArrayTypePrototype).toObject()); break; - case TypeRepresentation::UnsizedArray: + case TypeDescr::UnsizedArray: *clasp = &UnsizedArrayTypeDescr::class_; proto.set(&global->getTypedObjectModule().getSlot(ArrayTypePrototype).toObject()); break; @@ -1396,16 +1452,16 @@ DatumLengthFromType(TypeDescr &descr) { TypeRepresentation *typeRepr = descr.typeRepresentation(); switch (typeRepr->kind()) { - case TypeRepresentation::Scalar: - case TypeRepresentation::Reference: - case TypeRepresentation::Struct: - case TypeRepresentation::X4: + case TypeDescr::Scalar: + case TypeDescr::Reference: + case TypeDescr::Struct: + case TypeDescr::X4: return 0; - case TypeRepresentation::SizedArray: + case TypeDescr::SizedArray: return typeRepr->asSizedArray()->length(); - case TypeRepresentation::UnsizedArray: + case TypeDescr::UnsizedArray: MOZ_ASSUME_UNREACHABLE("DatumLengthFromType() invoked on unsized type"); } MOZ_ASSUME_UNREACHABLE("Invalid kind"); @@ -1479,15 +1535,15 @@ TypedDatum::obj_trace(JSTracer *trace, JSObject *object) return; // unattached handle or partially constructed switch (repr->kind()) { - case TypeRepresentation::Scalar: - case TypeRepresentation::Reference: - case TypeRepresentation::Struct: - case TypeRepresentation::SizedArray: - case TypeRepresentation::X4: + case TypeDescr::Scalar: + case TypeDescr::Reference: + case TypeDescr::Struct: + case TypeDescr::SizedArray: + case TypeDescr::X4: repr->asSized()->traceInstance(trace, mem, 1); break; - case TypeRepresentation::UnsizedArray: + case TypeDescr::UnsizedArray: repr->asUnsizedArray()->element()->traceInstance(trace, mem, datum.length()); break; } @@ -1521,13 +1577,13 @@ TypedDatum::obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, TypeRepresentation *typeRepr = typeDescr->typeRepresentation(); switch (typeRepr->kind()) { - case TypeRepresentation::Scalar: - case TypeRepresentation::Reference: - case TypeRepresentation::X4: + case TypeDescr::Scalar: + case TypeDescr::Reference: + case TypeDescr::X4: break; - case TypeRepresentation::SizedArray: - case TypeRepresentation::UnsizedArray: + case TypeDescr::SizedArray: + case TypeDescr::UnsizedArray: { uint32_t index; if (js_IdIsIndex(id, &index)) @@ -1541,7 +1597,7 @@ TypedDatum::obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, break; } - case TypeRepresentation::Struct: + case TypeDescr::Struct: { StructTypeRepresentation *structTypeRepr = typeRepr->asStruct(); const StructField *field = structTypeRepr->fieldNamed(id); @@ -1666,15 +1722,15 @@ TypedDatum::obj_getGeneric(JSContext *cx, HandleObject obj, HandleObject receive TypeRepresentation *typeRepr = datum->typeRepresentation(); switch (typeRepr->kind()) { - case TypeRepresentation::Scalar: - case TypeRepresentation::Reference: + case TypeDescr::Scalar: + case TypeDescr::Reference: break; - case TypeRepresentation::X4: + case TypeDescr::X4: break; - case TypeRepresentation::SizedArray: - case TypeRepresentation::UnsizedArray: + case TypeDescr::SizedArray: + case TypeDescr::UnsizedArray: if (JSID_IS_ATOM(id, cx->names().length)) { if (!datum->typedMem()) { // unattached JS_ReportErrorNumber( @@ -1688,7 +1744,7 @@ TypedDatum::obj_getGeneric(JSContext *cx, HandleObject obj, HandleObject receive } break; - case TypeRepresentation::Struct: { + case TypeDescr::Struct: { Rooted descr(cx, &datum->typeDescr().as()); size_t fieldIndex; @@ -1725,20 +1781,19 @@ TypedDatum::obj_getElement(JSContext *cx, HandleObject obj, HandleObject receive JS_ASSERT(obj->is()); Rooted datum(cx, &obj->as()); Rooted descr(cx, &datum->typeDescr()); - TypeRepresentation *typeRepr = datum->typeRepresentation(); - switch (typeRepr->kind()) { - case TypeRepresentation::Scalar: - case TypeRepresentation::Reference: - case TypeRepresentation::X4: - case TypeRepresentation::Struct: + switch (descr->kind()) { + case TypeDescr::Scalar: + case TypeDescr::Reference: + case TypeDescr::X4: + case TypeDescr::Struct: break; - case TypeRepresentation::SizedArray: + case TypeDescr::SizedArray: return obj_getArrayElement(cx, datum, descr, index, vp); - case TypeRepresentation::UnsizedArray: + case TypeDescr::UnsizedArray: return obj_getArrayElement(cx, datum, descr, index, vp); } @@ -1767,10 +1822,8 @@ TypedDatum::obj_getArrayElement(JSContext *cx, return true; } - Rooted elementType(cx); - elementType = &typeDescr->as().elementType(); - SizedTypeRepresentation *elementTypeRepr = elementType->typeRepresentation(); - size_t offset = elementTypeRepr->size() * index; + Rooted elementType(cx, &typeDescr->as().elementType()); + size_t offset = elementType->size() * index; return Reify(cx, elementType, datum, offset, vp); } @@ -1796,15 +1849,15 @@ TypedDatum::obj_setGeneric(JSContext *cx, HandleObject obj, HandleId id, TypeRepresentation *typeRepr = datum->typeRepresentation(); switch (typeRepr->kind()) { - case ScalarTypeRepresentation::Scalar: - case TypeRepresentation::Reference: + case ScalarTypeDescr::Scalar: + case TypeDescr::Reference: break; - case ScalarTypeRepresentation::X4: + case ScalarTypeDescr::X4: break; - case ScalarTypeRepresentation::SizedArray: - case ScalarTypeRepresentation::UnsizedArray: + case ScalarTypeDescr::SizedArray: + case ScalarTypeDescr::UnsizedArray: if (JSID_IS_ATOM(id, cx->names().length)) { JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_REDEFINE_ARRAY_LENGTH); @@ -1812,7 +1865,7 @@ TypedDatum::obj_setGeneric(JSContext *cx, HandleObject obj, HandleId id, } break; - case ScalarTypeRepresentation::Struct: { + case ScalarTypeDescr::Struct: { Rooted descr(cx, &datum->typeDescr().as()); size_t fieldIndex; @@ -1844,19 +1897,18 @@ TypedDatum::obj_setElement(JSContext *cx, HandleObject obj, uint32_t index, JS_ASSERT(obj->is()); Rooted datum(cx, &obj->as()); Rooted descr(cx, &datum->typeDescr()); - TypeRepresentation *typeRepr = datum->typeRepresentation(); - switch (typeRepr->kind()) { - case TypeRepresentation::Scalar: - case TypeRepresentation::Reference: - case TypeRepresentation::X4: - case TypeRepresentation::Struct: + switch (descr->kind()) { + case TypeDescr::Scalar: + case TypeDescr::Reference: + case TypeDescr::X4: + case TypeDescr::Struct: break; - case TypeRepresentation::SizedArray: + case TypeDescr::SizedArray: return obj_setArrayElement(cx, datum, descr, index, vp); - case TypeRepresentation::UnsizedArray: + case TypeDescr::UnsizedArray: return obj_setArrayElement(cx, datum, descr, index, vp); } @@ -1881,8 +1933,7 @@ TypedDatum::obj_setArrayElement(JSContext *cx, Rooted elementType(cx); elementType = &descr->as().elementType(); - SizedTypeRepresentation *elementTypeRepr = elementType->typeRepresentation(); - size_t offset = elementTypeRepr->size() * index; + size_t offset = elementType->size() * index; return ConvertAndCopyTo(cx, elementType, datum, offset, vp); } @@ -1904,15 +1955,15 @@ TypedDatum::obj_getGenericAttributes(JSContext *cx, HandleObject obj, TypeRepresentation *typeRepr = datum->typeRepresentation(); switch (typeRepr->kind()) { - case TypeRepresentation::Scalar: - case TypeRepresentation::Reference: + case TypeDescr::Scalar: + case TypeDescr::Reference: break; - case TypeRepresentation::X4: + case TypeDescr::X4: break; - case TypeRepresentation::SizedArray: - case TypeRepresentation::UnsizedArray: + case TypeDescr::SizedArray: + case TypeDescr::UnsizedArray: if (js_IdIsIndex(id, &index)) { *attrsp = JSPROP_ENUMERATE | JSPROP_PERMANENT; return true; @@ -1923,7 +1974,7 @@ TypedDatum::obj_getGenericAttributes(JSContext *cx, HandleObject obj, } break; - case TypeRepresentation::Struct: + case TypeDescr::Struct: if (typeRepr->asStruct()->fieldNamed(id) != nullptr) { *attrsp = JSPROP_ENUMERATE | JSPROP_PERMANENT; return true; @@ -1948,16 +1999,16 @@ IsOwnId(JSContext *cx, HandleObject obj, HandleId id) TypeRepresentation *typeRepr = datum->typeRepresentation(); switch (typeRepr->kind()) { - case TypeRepresentation::Scalar: - case TypeRepresentation::Reference: - case TypeRepresentation::X4: + case TypeDescr::Scalar: + case TypeDescr::Reference: + case TypeDescr::X4: return false; - case TypeRepresentation::SizedArray: - case TypeRepresentation::UnsizedArray: + case TypeDescr::SizedArray: + case TypeDescr::UnsizedArray: return js_IdIsIndex(id, &index) || JSID_IS_ATOM(id, cx->names().length); - case TypeRepresentation::Struct: + case TypeDescr::Struct: return typeRepr->asStruct()->fieldNamed(id) != nullptr; } @@ -2041,9 +2092,9 @@ TypedDatum::obj_enumerate(JSContext *cx, HandleObject obj, JSIterateOp enum_op, TypeRepresentation *typeRepr = datum->typeRepresentation(); switch (typeRepr->kind()) { - case TypeRepresentation::Scalar: - case TypeRepresentation::Reference: - case TypeRepresentation::X4: + case TypeDescr::Scalar: + case TypeDescr::Reference: + case TypeDescr::X4: switch (enum_op) { case JSENUMERATE_INIT_ALL: case JSENUMERATE_INIT: @@ -2057,8 +2108,8 @@ TypedDatum::obj_enumerate(JSContext *cx, HandleObject obj, JSIterateOp enum_op, } break; - case TypeRepresentation::SizedArray: - case TypeRepresentation::UnsizedArray: + case TypeDescr::SizedArray: + case TypeDescr::UnsizedArray: switch (enum_op) { case JSENUMERATE_INIT_ALL: case JSENUMERATE_INIT: @@ -2085,7 +2136,7 @@ TypedDatum::obj_enumerate(JSContext *cx, HandleObject obj, JSIterateOp enum_op, } break; - case TypeRepresentation::Struct: + case TypeDescr::Struct: switch (enum_op) { case JSENUMERATE_INIT_ALL: case JSENUMERATE_INIT: @@ -2189,10 +2240,10 @@ TypedObject::createZeroed(JSContext *cx, // Also initialize the JS_DATUM_SLOT_LENGTH slot. TypeRepresentation *typeRepr = descr->typeRepresentation(); switch (typeRepr->kind()) { - case TypeRepresentation::Scalar: - case TypeRepresentation::Reference: - case TypeRepresentation::Struct: - case TypeRepresentation::X4: + case TypeDescr::Scalar: + case TypeDescr::Reference: + case TypeDescr::Struct: + case TypeDescr::X4: { uint8_t *memory = (uint8_t*) cx->malloc_(typeRepr->asSized()->size()); if (!memory) @@ -2202,7 +2253,7 @@ TypedObject::createZeroed(JSContext *cx, return obj; } - case TypeRepresentation::SizedArray: + case TypeDescr::SizedArray: { uint8_t *memory = (uint8_t*) cx->malloc_(typeRepr->asSizedArray()->size()); if (!memory) @@ -2212,7 +2263,7 @@ TypedObject::createZeroed(JSContext *cx, return obj; } - case TypeRepresentation::UnsizedArray: + case TypeDescr::UnsizedArray: { SizedTypeRepresentation *elementTypeRepr = typeRepr->asUnsizedArray()->element(); @@ -2251,18 +2302,18 @@ TypedObject::construct(JSContext *cx, unsigned int argc, Value *vp) uint32_t nextArg = 0; int32_t length = 0; switch (typeRepr->kind()) { - case TypeRepresentation::Scalar: - case TypeRepresentation::Reference: - case TypeRepresentation::Struct: - case TypeRepresentation::X4: + case TypeDescr::Scalar: + case TypeDescr::Reference: + case TypeDescr::Struct: + case TypeDescr::X4: length = 0; break; - case TypeRepresentation::SizedArray: + case TypeDescr::SizedArray: length = typeRepr->asSizedArray()->length(); break; - case TypeRepresentation::UnsizedArray: + case TypeDescr::UnsizedArray: // First argument is a length. if (nextArg >= argc || !args[nextArg].isInt32()) { JS_ReportErrorNumber(cx, js_GetErrorMessage, diff --git a/js/src/builtin/TypedObject.h b/js/src/builtin/TypedObject.h index 8e405d1dec9..40e278b73e8 100644 --- a/js/src/builtin/TypedObject.h +++ b/js/src/builtin/TypedObject.h @@ -10,7 +10,6 @@ #include "jsobj.h" #include "builtin/TypedObjectConstants.h" -#include "builtin/TypeRepresentation.h" /* * ------------- @@ -96,29 +95,12 @@ namespace js { +class TypeRepresentation; +class ScalarTypeRepresentation; +class ReferenceTypeRepresentation; +class X4TypeRepresentation; class StructTypeDescr; -/* - * This object exists in order to encapsulate the typed object types - * somewhat, rather than sticking them all into the global object. - * Eventually it will go away and become a module. - */ -class TypedObjectModuleObject : public JSObject { - public: - enum Slot { - ArrayTypePrototype, - StructTypePrototype, - SlotCount - }; - - static const Class class_; - - static bool getSuitableClaspAndProto(JSContext *cx, - TypeRepresentation::Kind kind, - const Class **clasp, - MutableHandleObject proto); -}; - /* * Helper method for converting a double into other scalar * types in the same way that JavaScript would. In particular, @@ -142,17 +124,47 @@ static T ConvertScalar(double d) class TypeDescr : public JSObject { public: + enum Kind { + Scalar = JS_TYPEREPR_SCALAR_KIND, + Reference = JS_TYPEREPR_REFERENCE_KIND, + X4 = JS_TYPEREPR_X4_KIND, + Struct = JS_TYPEREPR_STRUCT_KIND, + SizedArray = JS_TYPEREPR_SIZED_ARRAY_KIND, + UnsizedArray = JS_TYPEREPR_UNSIZED_ARRAY_KIND, + }; + + static bool isSized(Kind kind) { + return kind > JS_TYPEREPR_MAX_UNSIZED_KIND; + } + JSObject &typeRepresentationOwnerObj() const { return getReservedSlot(JS_DESCR_SLOT_TYPE_REPR).toObject(); } - TypeRepresentation *typeRepresentation() const { - return TypeRepresentation::fromOwnerObject(typeRepresentationOwnerObj()); - } + TypeRepresentation *typeRepresentation() const; - TypeRepresentation::Kind kind() const { - return typeRepresentation()->kind(); - } + TypeDescr::Kind kind() const; +}; + +/* + * This object exists in order to encapsulate the typed object types + * somewhat, rather than sticking them all into the global object. + * Eventually it will go away and become a module. + */ +class TypedObjectModuleObject : public JSObject { + public: + enum Slot { + ArrayTypePrototype, + StructTypePrototype, + SlotCount + }; + + static const Class class_; + + static bool getSuitableClaspAndProto(JSContext *cx, + TypeDescr::Kind kind, + const Class **clasp, + MutableHandleObject proto); }; typedef Handle HandleTypeDescr; @@ -164,12 +176,8 @@ bool InitializeCommonTypeDescriptorProperties(JSContext *cx, class SizedTypeDescr : public TypeDescr { public: - SizedTypeRepresentation *typeRepresentation() const { - return ((TypeDescr*)this)->typeRepresentation()->asSized(); - } - size_t size() { - return typeRepresentation()->size(); + return getReservedSlot(JS_DESCR_SLOT_SIZE).toInt32(); } }; @@ -186,52 +194,115 @@ 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; + + static size_t size(Type t); + static size_t alignment(Type t); + static const char *typeName(Type type); + static const Class class_; static const JSFunctionSpec typeObjectMethods[]; typedef ScalarTypeRepresentation TypeRepr; - ScalarTypeRepresentation::Type type() const { - return (ScalarTypeRepresentation::Type) getReservedSlot(JS_DESCR_SLOT_TYPE).toInt32(); + ScalarTypeDescr::Type type() const { + return (ScalarTypeDescr::Type) getReservedSlot(JS_DESCR_SLOT_TYPE).toInt32(); } static bool call(JSContext *cx, unsigned argc, Value *vp); }; +// 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) + +// 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) + // Type for reference type constructors like `Any`, `String`, and // `Object`. All such type constructors share a common js::Class and // JSFunctionSpec. All these types are opaque. class ReferenceTypeDescr : public SimpleTypeDescr { public: + // Must match order of JS_FOR_EACH_REFERENCE_TYPE_REPR below + enum Type { + TYPE_ANY = JS_REFERENCETYPEREPR_ANY, + TYPE_OBJECT = JS_REFERENCETYPEREPR_OBJECT, + TYPE_STRING = JS_REFERENCETYPEREPR_STRING, + }; + static const int32_t TYPE_MAX = TYPE_STRING + 1; + static const char *typeName(Type type); + static const Class class_; static const JSFunctionSpec typeObjectMethods[]; typedef ReferenceTypeRepresentation TypeRepr; - ReferenceTypeRepresentation::Type type() const { - return (ReferenceTypeRepresentation::Type) getReservedSlot(JS_DESCR_SLOT_TYPE).toInt32(); + ReferenceTypeDescr::Type type() const { + return (ReferenceTypeDescr::Type) getReservedSlot(JS_DESCR_SLOT_TYPE).toInt32(); } static bool call(JSContext *cx, unsigned argc, Value *vp); }; +#define JS_FOR_EACH_REFERENCE_TYPE_REPR(macro_) \ + macro_(ReferenceTypeDescr::TYPE_ANY, HeapValue, Any) \ + macro_(ReferenceTypeDescr::TYPE_OBJECT, HeapPtrObject, Object) \ + macro_(ReferenceTypeDescr::TYPE_STRING, HeapPtrString, string) + /* * Type descriptors `float32x4` and `int32x4` */ class X4TypeDescr : public SizedTypeDescr { - private: public: + enum Type { + TYPE_INT32 = JS_X4TYPEREPR_INT32, + TYPE_FLOAT32 = JS_X4TYPEREPR_FLOAT32, + }; + static const Class class_; typedef X4TypeRepresentation TypeRepr; - X4TypeRepresentation::Type type() const { - return (X4TypeRepresentation::Type) getReservedSlot(JS_DESCR_SLOT_TYPE).toInt32(); + X4TypeDescr::Type type() const { + return (X4TypeDescr::Type) getReservedSlot(JS_DESCR_SLOT_TYPE).toInt32(); } static bool call(JSContext *cx, unsigned argc, Value *vp); static bool is(const Value &v); }; +#define JS_FOR_EACH_X4_TYPE_REPR(macro_) \ + macro_(X4TypeDescr::TYPE_INT32, int32_t, int32) \ + macro_(X4TypeDescr::TYPE_FLOAT32, float, float32) + /* * Properties and methods of the `ArrayType` meta type object. There * is no `class_` field because `ArrayType` is just a native @@ -341,10 +412,6 @@ class StructMetaTypeDescr : public JSObject // This is the function that gets called when the user // does `new StructType(...)`. It produces a struct type object. static bool construct(JSContext *cx, unsigned argc, Value *vp); - - static bool convertAndCopyTo(JSContext *cx, - StructTypeRepresentation *typeRepr, - HandleValue from, uint8_t *mem); }; class StructTypeDescr : public SizedTypeDescr { @@ -520,22 +587,22 @@ class TypedDatum : public JSObject } size_t length() const { - JS_ASSERT(typeRepresentation()->isAnyArray()); return getReservedSlot(JS_DATUM_SLOT_LENGTH).toInt32(); } size_t size() const { - TypeRepresentation *typeRepr = typeRepresentation(); - switch (typeRepr->kind()) { - case TypeRepresentation::Scalar: - case TypeRepresentation::X4: - case TypeRepresentation::Reference: - case TypeRepresentation::Struct: - case TypeRepresentation::SizedArray: - return typeRepr->asSized()->size(); + switch (typeDescr().kind()) { + case TypeDescr::Scalar: + case TypeDescr::X4: + case TypeDescr::Reference: + case TypeDescr::Struct: + case TypeDescr::SizedArray: + return typeDescr().as().size(); - case TypeRepresentation::UnsizedArray: - return typeRepr->asUnsizedArray()->element()->size() * length(); + case TypeDescr::UnsizedArray: { + SizedTypeDescr &elementType = typeDescr().as().elementType(); + return elementType.size() * length(); + } } MOZ_ASSUME_UNREACHABLE("unhandled typerepresentation kind"); } diff --git a/js/src/ctypes/CTypes.cpp b/js/src/ctypes/CTypes.cpp index edcdd7e14d7..5713e0399ba 100644 --- a/js/src/ctypes/CTypes.cpp +++ b/js/src/ctypes/CTypes.cpp @@ -31,10 +31,12 @@ #include #endif +#include "jscntxt.h" +#include "jsfun.h" #include "jsnum.h" #include "jsprf.h" -#include "builtin/TypeRepresentation.h" +#include "builtin/TypedObject.h" #include "ctypes/Library.h" using namespace std; @@ -2183,29 +2185,29 @@ bool CanConvertTypedArrayItemTo(JSObject *baseType, JSObject *valObj, JSContext } TypeCode elementTypeCode; switch (JS_GetArrayBufferViewType(valObj)) { - case ScalarTypeRepresentation::TYPE_INT8: + case ScalarTypeDescr::TYPE_INT8: elementTypeCode = TYPE_int8_t; break; - case ScalarTypeRepresentation::TYPE_UINT8: - case ScalarTypeRepresentation::TYPE_UINT8_CLAMPED: + case ScalarTypeDescr::TYPE_UINT8: + case ScalarTypeDescr::TYPE_UINT8_CLAMPED: elementTypeCode = TYPE_uint8_t; break; - case ScalarTypeRepresentation::TYPE_INT16: + case ScalarTypeDescr::TYPE_INT16: elementTypeCode = TYPE_int16_t; break; - case ScalarTypeRepresentation::TYPE_UINT16: + case ScalarTypeDescr::TYPE_UINT16: elementTypeCode = TYPE_uint16_t; break; - case ScalarTypeRepresentation::TYPE_INT32: + case ScalarTypeDescr::TYPE_INT32: elementTypeCode = TYPE_int32_t; break; - case ScalarTypeRepresentation::TYPE_UINT32: + case ScalarTypeDescr::TYPE_UINT32: elementTypeCode = TYPE_uint32_t; break; - case ScalarTypeRepresentation::TYPE_FLOAT32: + case ScalarTypeDescr::TYPE_FLOAT32: elementTypeCode = TYPE_float32_t; break; - case ScalarTypeRepresentation::TYPE_FLOAT64: + case ScalarTypeDescr::TYPE_FLOAT64: elementTypeCode = TYPE_float64_t; break; default: diff --git a/js/src/jit/BaselineIC.cpp b/js/src/jit/BaselineIC.cpp index 020d0589e71..f56a1877647 100644 --- a/js/src/jit/BaselineIC.cpp +++ b/js/src/jit/BaselineIC.cpp @@ -3821,9 +3821,9 @@ static bool TypedArrayRequiresFloatingPoint(TypedArrayObject *tarr) { uint32_t type = tarr->type(); - return (type == ScalarTypeRepresentation::TYPE_UINT32 || - type == ScalarTypeRepresentation::TYPE_FLOAT32 || - type == ScalarTypeRepresentation::TYPE_FLOAT64); + return (type == ScalarTypeDescr::TYPE_UINT32 || + type == ScalarTypeDescr::TYPE_FLOAT32 || + type == ScalarTypeDescr::TYPE_FLOAT64); } static bool @@ -5489,10 +5489,10 @@ ICSetElem_TypedArray::Compiler::generateStubCode(MacroAssembler &masm) regs.take(scratchReg); Register secondScratch = regs.takeAny(); - if (type_ == ScalarTypeRepresentation::TYPE_FLOAT32 || type_ == ScalarTypeRepresentation::TYPE_FLOAT64) { + if (type_ == ScalarTypeDescr::TYPE_FLOAT32 || type_ == ScalarTypeDescr::TYPE_FLOAT64) { masm.ensureDouble(value, FloatReg0, &failure); if (LIRGenerator::allowFloat32Optimizations() && - type_ == ScalarTypeRepresentation::TYPE_FLOAT32) + type_ == ScalarTypeDescr::TYPE_FLOAT32) { masm.convertDoubleToFloat32(FloatReg0, ScratchFloatReg); masm.storeToTypedFloatArray(type_, ScratchFloatReg, dest); @@ -5500,7 +5500,7 @@ ICSetElem_TypedArray::Compiler::generateStubCode(MacroAssembler &masm) masm.storeToTypedFloatArray(type_, FloatReg0, dest); } EmitReturnFromIC(masm); - } else if (type_ == ScalarTypeRepresentation::TYPE_UINT8_CLAMPED) { + } else if (type_ == ScalarTypeDescr::TYPE_UINT8_CLAMPED) { Label notInt32; masm.branchTestInt32(Assembler::NotEqual, value, ¬Int32); masm.unboxInt32(value, secondScratch); @@ -6468,7 +6468,7 @@ ICGetProp_TypedArrayLength::Compiler::generateStubCode(MacroAssembler &masm) masm.branchPtr(Assembler::Below, scratch, ImmPtr(&TypedArrayObject::classes[0]), &failure); masm.branchPtr(Assembler::AboveOrEqual, scratch, - ImmPtr(&TypedArrayObject::classes[ScalarTypeRepresentation::TYPE_MAX]), + ImmPtr(&TypedArrayObject::classes[ScalarTypeDescr::TYPE_MAX]), &failure); // Load length from fixed slot. diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index 1c06b107fec..ce9eb6785c6 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -7366,8 +7366,8 @@ template static inline void StoreToTypedArray(MacroAssembler &masm, int arrayType, const LAllocation *value, const T &dest) { - if (arrayType == ScalarTypeRepresentation::TYPE_FLOAT32 || - arrayType == ScalarTypeRepresentation::TYPE_FLOAT64) + if (arrayType == ScalarTypeDescr::TYPE_FLOAT32 || + arrayType == ScalarTypeDescr::TYPE_FLOAT64) { masm.storeToTypedFloatArray(arrayType, ToFloatRegister(value), dest); } else { diff --git a/js/src/jit/IonBuilder.cpp b/js/src/jit/IonBuilder.cpp index 4a1b26879f6..4b2d9e140bc 100644 --- a/js/src/jit/IonBuilder.cpp +++ b/js/src/jit/IonBuilder.cpp @@ -10,7 +10,6 @@ #include "builtin/Eval.h" #include "builtin/TypedObject.h" -#include "builtin/TypeRepresentation.h" #include "frontend/SourceNotes.h" #include "jit/BaselineFrame.h" #include "jit/BaselineInspector.h" @@ -6628,26 +6627,26 @@ IonBuilder::getElemTryTypedObject(bool *emitted, MDefinition *obj, MDefinition * if (elemDescrs.empty()) return true; - JS_ASSERT(TypeRepresentation::isSized(elemDescrs.kind())); + JS_ASSERT(TypeDescr::isSized(elemDescrs.kind())); size_t elemSize; if (!elemDescrs.allHaveSameSize(&elemSize)) return true; switch (elemDescrs.kind()) { - case TypeRepresentation::X4: + case TypeDescr::X4: // FIXME (bug 894105): load into a MIRType_float32x4 etc return true; - case TypeRepresentation::Struct: - case TypeRepresentation::SizedArray: + case TypeDescr::Struct: + case TypeDescr::SizedArray: return getElemTryComplexElemOfTypedObject(emitted, obj, index, objDescrs, elemDescrs, elemSize); - case TypeRepresentation::Scalar: + case TypeDescr::Scalar: return getElemTryScalarElemOfTypedObject(emitted, obj, index, @@ -6655,10 +6654,10 @@ IonBuilder::getElemTryTypedObject(bool *emitted, MDefinition *obj, MDefinition * elemDescrs, elemSize); - case TypeRepresentation::Reference: + case TypeDescr::Reference: return true; - case TypeRepresentation::UnsizedArray: + case TypeDescr::UnsizedArray: MOZ_ASSUME_UNREACHABLE("Unsized arrays cannot be element types"); } @@ -6666,7 +6665,7 @@ IonBuilder::getElemTryTypedObject(bool *emitted, MDefinition *obj, MDefinition * } static MIRType -MIRTypeForTypedArrayRead(ScalarTypeRepresentation::Type arrayType, +MIRTypeForTypedArrayRead(ScalarTypeDescr::Type arrayType, bool observedDouble); bool @@ -6721,10 +6720,10 @@ IonBuilder::getElemTryScalarElemOfTypedObject(bool *emitted, JS_ASSERT(objDescrs.allOfArrayKind()); // Must always be loading the same scalar type - ScalarTypeRepresentation::Type elemType; + ScalarTypeDescr::Type elemType; if (!elemDescrs.scalarType(&elemType)) return true; - JS_ASSERT(elemSize == ScalarTypeRepresentation::alignment(elemType)); + JS_ASSERT(elemSize == ScalarTypeDescr::alignment(elemType)); MDefinition *indexAsByteOffset; if (!checkTypedObjectIndexInBounds(elemSize, obj, index, &indexAsByteOffset, objDescrs)) @@ -6737,10 +6736,10 @@ bool IonBuilder::pushScalarLoadFromTypedObject(bool *emitted, MDefinition *obj, MDefinition *offset, - ScalarTypeRepresentation::Type elemType) + ScalarTypeDescr::Type elemType) { - size_t size = ScalarTypeRepresentation::size(elemType); - JS_ASSERT(size == ScalarTypeRepresentation::alignment(elemType)); + size_t size = ScalarTypeDescr::size(elemType); + JS_ASSERT(size == ScalarTypeDescr::alignment(elemType)); // Find location within the owner object. MDefinition *elements, *scaledOffset; @@ -6870,7 +6869,7 @@ IonBuilder::getElemTryTypedStatic(bool *emitted, MDefinition *obj, MDefinition * { JS_ASSERT(*emitted == false); - ScalarTypeRepresentation::Type arrayType; + ScalarTypeDescr::Type arrayType; if (!ElementAccessIsTypedArray(obj, index, &arrayType)) return true; @@ -6931,7 +6930,7 @@ IonBuilder::getElemTryTypedArray(bool *emitted, MDefinition *obj, MDefinition *i { JS_ASSERT(*emitted == false); - ScalarTypeRepresentation::Type arrayType; + ScalarTypeDescr::Type arrayType; if (!ElementAccessIsTypedArray(obj, index, &arrayType)) return true; @@ -7280,22 +7279,22 @@ IonBuilder::convertShiftToMaskForStaticTypedArray(MDefinition *id, } static MIRType -MIRTypeForTypedArrayRead(ScalarTypeRepresentation::Type arrayType, +MIRTypeForTypedArrayRead(ScalarTypeDescr::Type arrayType, bool observedDouble) { switch (arrayType) { - case ScalarTypeRepresentation::TYPE_INT8: - case ScalarTypeRepresentation::TYPE_UINT8: - case ScalarTypeRepresentation::TYPE_UINT8_CLAMPED: - case ScalarTypeRepresentation::TYPE_INT16: - case ScalarTypeRepresentation::TYPE_UINT16: - case ScalarTypeRepresentation::TYPE_INT32: + 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: return MIRType_Int32; - case ScalarTypeRepresentation::TYPE_UINT32: + case ScalarTypeDescr::TYPE_UINT32: return observedDouble ? MIRType_Double : MIRType_Int32; - case ScalarTypeRepresentation::TYPE_FLOAT32: + case ScalarTypeDescr::TYPE_FLOAT32: return (LIRGenerator::allowFloat32Optimizations()) ? MIRType_Float32 : MIRType_Double; - case ScalarTypeRepresentation::TYPE_FLOAT64: + case ScalarTypeDescr::TYPE_FLOAT64: return MIRType_Double; } MOZ_ASSUME_UNREACHABLE("Unknown typed array type"); @@ -7303,7 +7302,7 @@ MIRTypeForTypedArrayRead(ScalarTypeRepresentation::Type arrayType, bool IonBuilder::jsop_getelem_typed(MDefinition *obj, MDefinition *index, - ScalarTypeRepresentation::Type arrayType) + ScalarTypeDescr::Type arrayType) { types::TemporaryTypeSet *types = bytecodeTypes(pc); @@ -7356,18 +7355,18 @@ IonBuilder::jsop_getelem_typed(MDefinition *obj, MDefinition *index, // will bailout when we read a double. bool needsBarrier = true; switch (arrayType) { - case ScalarTypeRepresentation::TYPE_INT8: - case ScalarTypeRepresentation::TYPE_UINT8: - case ScalarTypeRepresentation::TYPE_UINT8_CLAMPED: - case ScalarTypeRepresentation::TYPE_INT16: - case ScalarTypeRepresentation::TYPE_UINT16: - case ScalarTypeRepresentation::TYPE_INT32: - case ScalarTypeRepresentation::TYPE_UINT32: + 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: if (types->hasType(types::Type::Int32Type())) needsBarrier = false; break; - case ScalarTypeRepresentation::TYPE_FLOAT32: - case ScalarTypeRepresentation::TYPE_FLOAT64: + case ScalarTypeDescr::TYPE_FLOAT32: + case ScalarTypeDescr::TYPE_FLOAT64: if (allowDouble) needsBarrier = false; break; @@ -7444,25 +7443,25 @@ IonBuilder::setElemTryTypedObject(bool *emitted, MDefinition *obj, if (elemTypeDescrs.empty()) return true; - JS_ASSERT(TypeRepresentation::isSized(elemTypeDescrs.kind())); + JS_ASSERT(TypeDescr::isSized(elemTypeDescrs.kind())); size_t elemSize; if (!elemTypeDescrs.allHaveSameSize(&elemSize)) return true; switch (elemTypeDescrs.kind()) { - case TypeRepresentation::X4: + case TypeDescr::X4: // FIXME (bug 894105): store a MIRType_float32x4 etc return true; - case TypeRepresentation::Reference: - case TypeRepresentation::Struct: - case TypeRepresentation::SizedArray: - case TypeRepresentation::UnsizedArray: + case TypeDescr::Reference: + case TypeDescr::Struct: + case TypeDescr::SizedArray: + case TypeDescr::UnsizedArray: // For now, only optimize storing scalars. return true; - case TypeRepresentation::Scalar: + case TypeDescr::Scalar: return setElemTryScalarPropOfTypedObject(emitted, obj, index, @@ -7485,10 +7484,10 @@ IonBuilder::setElemTryScalarPropOfTypedObject(bool *emitted, size_t elemSize) { // Must always be loading the same scalar type - ScalarTypeRepresentation::Type elemType; + ScalarTypeDescr::Type elemType; if (!elemTypeDescrs.scalarType(&elemType)) return true; - JS_ASSERT(elemSize == ScalarTypeRepresentation::alignment(elemType)); + JS_ASSERT(elemSize == ScalarTypeDescr::alignment(elemType)); MDefinition *indexAsByteOffset; if (!checkTypedObjectIndexInBounds(elemSize, obj, index, &indexAsByteOffset, objTypeDescrs)) @@ -7510,7 +7509,7 @@ IonBuilder::setElemTryTypedStatic(bool *emitted, MDefinition *object, { JS_ASSERT(*emitted == false); - ScalarTypeRepresentation::Type arrayType; + ScalarTypeDescr::Type arrayType; if (!ElementAccessIsTypedArray(object, index, &arrayType)) return true; @@ -7561,7 +7560,7 @@ IonBuilder::setElemTryTypedArray(bool *emitted, MDefinition *object, { JS_ASSERT(*emitted == false); - ScalarTypeRepresentation::Type arrayType; + ScalarTypeDescr::Type arrayType; if (!ElementAccessIsTypedArray(object, index, &arrayType)) return true; @@ -7781,7 +7780,7 @@ IonBuilder::jsop_setelem_dense(types::TemporaryTypeSet::DoubleConversion convers bool -IonBuilder::jsop_setelem_typed(ScalarTypeRepresentation::Type arrayType, +IonBuilder::jsop_setelem_typed(ScalarTypeDescr::Type arrayType, SetElemSafety safety, MDefinition *obj, MDefinition *id, MDefinition *value) { @@ -7816,7 +7815,7 @@ IonBuilder::jsop_setelem_typed(ScalarTypeRepresentation::Type arrayType, // Clamp value to [0, 255] for Uint8ClampedArray. MDefinition *toWrite = value; - if (arrayType == ScalarTypeRepresentation::TYPE_UINT8_CLAMPED) { + if (arrayType == ScalarTypeDescr::TYPE_UINT8_CLAMPED) { toWrite = MClampToUint8::New(alloc(), value); current->add(toWrite->toInstruction()); } @@ -7889,7 +7888,7 @@ IonBuilder::jsop_length_fastPath() return true; } - if (objTypes && objTypes->getTypedArrayType() != ScalarTypeRepresentation::TYPE_MAX) { + if (objTypes && objTypes->getTypedArrayType() != ScalarTypeDescr::TYPE_MAX) { current->pop(); MInstruction *length = getTypedArrayLength(obj); current->add(length); @@ -8453,28 +8452,28 @@ IonBuilder::getPropTryTypedObject(bool *emitted, PropertyName *name, return true; switch (fieldDescrs.kind()) { - case TypeRepresentation::Reference: + case TypeDescr::Reference: return true; - case TypeRepresentation::X4: + case TypeDescr::X4: // FIXME (bug 894104): load into a MIRType_float32x4 etc return true; - case TypeRepresentation::Struct: - case TypeRepresentation::SizedArray: + case TypeDescr::Struct: + case TypeDescr::SizedArray: return getPropTryComplexPropOfTypedObject(emitted, fieldOffset, fieldDescrs, fieldIndex, resultTypes); - case TypeRepresentation::Scalar: + case TypeDescr::Scalar: return getPropTryScalarPropOfTypedObject(emitted, fieldOffset, fieldDescrs, resultTypes); - case TypeRepresentation::UnsizedArray: + case TypeDescr::UnsizedArray: MOZ_ASSUME_UNREACHABLE("Field of unsized array type"); } @@ -8488,7 +8487,7 @@ IonBuilder::getPropTryScalarPropOfTypedObject(bool *emitted, types::TemporaryTypeSet *resultTypes) { // Must always be loading the same scalar type - ScalarTypeRepresentation::Type fieldType; + ScalarTypeDescr::Type fieldType; if (!fieldDescrs.scalarType(&fieldType)) return true; @@ -8985,18 +8984,18 @@ IonBuilder::setPropTryTypedObject(bool *emitted, MDefinition *obj, return true; switch (fieldDescrs.kind()) { - case TypeRepresentation::X4: + case TypeDescr::X4: // FIXME (bug 894104): store into a MIRType_float32x4 etc return true; - case TypeRepresentation::Reference: - case TypeRepresentation::Struct: - case TypeRepresentation::SizedArray: - case TypeRepresentation::UnsizedArray: + case TypeDescr::Reference: + case TypeDescr::Struct: + case TypeDescr::SizedArray: + case TypeDescr::UnsizedArray: // For now, only optimize storing scalars. return true; - case TypeRepresentation::Scalar: + case TypeDescr::Scalar: return setPropTryScalarPropOfTypedObject(emitted, obj, fieldOffset, value, fieldDescrs); } @@ -9012,7 +9011,7 @@ IonBuilder::setPropTryScalarPropOfTypedObject(bool *emitted, TypeDescrSet fieldDescrs) { // Must always be loading the same scalar type - ScalarTypeRepresentation::Type fieldType; + ScalarTypeDescr::Type fieldType; if (!fieldDescrs.scalarType(&fieldType)) return true; @@ -9961,7 +9960,7 @@ IonBuilder::lookupTypedObjectField(MDefinition *typedObj, return false; // Must be accessing a struct. - if (!objDescrs.allOfKind(TypeRepresentation::Struct)) + if (!objDescrs.allOfKind(TypeDescr::Struct)) return true; // Determine the type/offset of the field `name`, if any. @@ -10027,17 +10026,17 @@ IonBuilder::typeObjectForFieldFromStructType(MDefinition *typeObj, bool IonBuilder::storeScalarTypedObjectValue(MDefinition *typedObj, MDefinition *offset, - ScalarTypeRepresentation::Type type, + ScalarTypeDescr::Type type, MDefinition *value) { // Find location within the owner object. MDefinition *elements, *scaledOffset; - size_t alignment = ScalarTypeRepresentation::alignment(type); + size_t alignment = ScalarTypeDescr::alignment(type); loadTypedObjectElements(typedObj, offset, alignment, &elements, &scaledOffset); // Clamp value to [0, 255] when type is Uint8Clamped MDefinition *toWrite = value; - if (type == ScalarTypeRepresentation::TYPE_UINT8_CLAMPED) { + if (type == ScalarTypeDescr::TYPE_UINT8_CLAMPED) { toWrite = MClampToUint8::New(alloc(), value); current->add(toWrite->toInstruction()); } diff --git a/js/src/jit/IonBuilder.h b/js/src/jit/IonBuilder.h index bad4069db2a..8dc3cb9ed79 100644 --- a/js/src/jit/IonBuilder.h +++ b/js/src/jit/IonBuilder.h @@ -454,7 +454,7 @@ class IonBuilder : public MIRGenerator size_t fieldIndex); bool storeScalarTypedObjectValue(MDefinition *typedObj, MDefinition *offset, - ScalarTypeRepresentation::Type type, + ScalarTypeDescr::Type type, MDefinition *value); bool checkTypedObjectIndexInBounds(size_t elemSize, MDefinition *obj, @@ -469,7 +469,7 @@ class IonBuilder : public MIRGenerator bool pushScalarLoadFromTypedObject(bool *emitted, MDefinition *obj, MDefinition *offset, - ScalarTypeRepresentation::Type type); + ScalarTypeDescr::Type type); // jsop_setelem() helpers. bool setElemTryTypedArray(bool *emitted, MDefinition *object, @@ -549,12 +549,12 @@ class IonBuilder : public MIRGenerator bool jsop_bindname(PropertyName *name); bool jsop_getelem(); bool jsop_getelem_dense(MDefinition *obj, MDefinition *index); - bool jsop_getelem_typed(MDefinition *obj, MDefinition *index, ScalarTypeRepresentation::Type arrayType); + bool jsop_getelem_typed(MDefinition *obj, MDefinition *index, ScalarTypeDescr::Type arrayType); bool jsop_setelem(); bool jsop_setelem_dense(types::TemporaryTypeSet::DoubleConversion conversion, SetElemSafety safety, MDefinition *object, MDefinition *index, MDefinition *value); - bool jsop_setelem_typed(ScalarTypeRepresentation::Type arrayType, + bool jsop_setelem_typed(ScalarTypeDescr::Type arrayType, SetElemSafety safety, MDefinition *object, MDefinition *index, MDefinition *value); bool jsop_length(); @@ -658,7 +658,7 @@ class IonBuilder : public MIRGenerator InliningStatus inlineUnsafePutElements(CallInfo &callInfo); bool inlineUnsafeSetDenseArrayElement(CallInfo &callInfo, uint32_t base); bool inlineUnsafeSetTypedArrayElement(CallInfo &callInfo, uint32_t base, - ScalarTypeRepresentation::Type arrayType); + ScalarTypeDescr::Type arrayType); InliningStatus inlineNewDenseArray(CallInfo &callInfo); InliningStatus inlineNewDenseArrayForSequentialExecution(CallInfo &callInfo); InliningStatus inlineNewDenseArrayForParallelExecution(CallInfo &callInfo); diff --git a/js/src/jit/IonCaches.cpp b/js/src/jit/IonCaches.cpp index cde23d5f1d8..9476c84b426 100644 --- a/js/src/jit/IonCaches.cpp +++ b/js/src/jit/IonCaches.cpp @@ -12,7 +12,7 @@ #include "jsproxy.h" #include "jstypes.h" -#include "builtin/TypeRepresentation.h" +#include "builtin/TypedObject.h" #include "jit/Ion.h" #include "jit/IonLinker.h" #include "jit/IonSpewer.h" @@ -1089,7 +1089,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[ScalarTypeRepresentation::TYPE_MAX]), + ImmPtr(&TypedArrayObject::classes[ScalarTypeDescr::TYPE_MAX]), &failures); // Load length. @@ -3161,8 +3161,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().type(); - if (arrayType == ScalarTypeRepresentation::TYPE_FLOAT32 || - arrayType == ScalarTypeRepresentation::TYPE_FLOAT64) + if (arrayType == ScalarTypeDescr::TYPE_FLOAT32 || + arrayType == ScalarTypeDescr::TYPE_FLOAT64) { return output.hasValue(); } @@ -3721,7 +3721,7 @@ GenerateSetTypedArrayElement(JSContext *cx, MacroAssembler &masm, IonCache::Stub int width = TypedArrayObject::slotWidth(arrayType); BaseIndex target(elements, index, ScaleFromElemWidth(width)); - if (arrayType == ScalarTypeRepresentation::TYPE_FLOAT32) { + if (arrayType == ScalarTypeDescr::TYPE_FLOAT32) { if (LIRGenerator::allowFloat32Optimizations()) { if (!masm.convertConstantOrRegisterToFloat(cx, value, tempFloat, &failures)) return false; @@ -3730,7 +3730,7 @@ GenerateSetTypedArrayElement(JSContext *cx, MacroAssembler &masm, IonCache::Stub return false; } masm.storeToTypedFloatArray(arrayType, tempFloat, target); - } else if (arrayType == ScalarTypeRepresentation::TYPE_FLOAT64) { + } else if (arrayType == ScalarTypeDescr::TYPE_FLOAT64) { if (!masm.convertConstantOrRegisterToDouble(cx, value, tempFloat, &failures)) return false; masm.storeToTypedFloatArray(arrayType, tempFloat, target); @@ -3740,7 +3740,7 @@ GenerateSetTypedArrayElement(JSContext *cx, MacroAssembler &masm, IonCache::Stub // afterwards. masm.push(object); - if (arrayType == ScalarTypeRepresentation::TYPE_UINT8_CLAMPED) { + if (arrayType == ScalarTypeDescr::TYPE_UINT8_CLAMPED) { if (!masm.clampConstantOrRegisterToUint8(cx, value, tempFloat, object, &popObjectAndFail)) { diff --git a/js/src/jit/IonMacroAssembler.cpp b/js/src/jit/IonMacroAssembler.cpp index 3f10669e4f2..894f9b5d390 100644 --- a/js/src/jit/IonMacroAssembler.cpp +++ b/js/src/jit/IonMacroAssembler.cpp @@ -9,7 +9,7 @@ #include "jsinfer.h" #include "jsprf.h" -#include "builtin/TypeRepresentation.h" +#include "builtin/TypedObject.h" #include "jit/Bailouts.h" #include "jit/BaselineFrame.h" #include "jit/BaselineIC.h" @@ -375,7 +375,7 @@ static void StoreToTypedFloatArray(MacroAssembler &masm, int arrayType, const S &value, const T &dest) { switch (arrayType) { - case ScalarTypeRepresentation::TYPE_FLOAT32: + case ScalarTypeDescr::TYPE_FLOAT32: if (LIRGenerator::allowFloat32Optimizations()) { masm.storeFloat32(value, dest); } else { @@ -387,7 +387,7 @@ StoreToTypedFloatArray(MacroAssembler &masm, int arrayType, const S &value, cons masm.storeFloat32(ScratchFloatReg, dest); } break; - case ScalarTypeRepresentation::TYPE_FLOAT64: + case ScalarTypeDescr::TYPE_FLOAT64: #ifdef JS_MORE_DETERMINISTIC // See the comment in ToDoubleForTypedArray. masm.canonicalizeDouble(value); @@ -418,23 +418,23 @@ MacroAssembler::loadFromTypedArray(int arrayType, const T &src, AnyRegister dest Label *fail) { switch (arrayType) { - case ScalarTypeRepresentation::TYPE_INT8: + case ScalarTypeDescr::TYPE_INT8: load8SignExtend(src, dest.gpr()); break; - case ScalarTypeRepresentation::TYPE_UINT8: - case ScalarTypeRepresentation::TYPE_UINT8_CLAMPED: + case ScalarTypeDescr::TYPE_UINT8: + case ScalarTypeDescr::TYPE_UINT8_CLAMPED: load8ZeroExtend(src, dest.gpr()); break; - case ScalarTypeRepresentation::TYPE_INT16: + case ScalarTypeDescr::TYPE_INT16: load16SignExtend(src, dest.gpr()); break; - case ScalarTypeRepresentation::TYPE_UINT16: + case ScalarTypeDescr::TYPE_UINT16: load16ZeroExtend(src, dest.gpr()); break; - case ScalarTypeRepresentation::TYPE_INT32: + case ScalarTypeDescr::TYPE_INT32: load32(src, dest.gpr()); break; - case ScalarTypeRepresentation::TYPE_UINT32: + case ScalarTypeDescr::TYPE_UINT32: if (dest.isFloat()) { load32(src, temp); convertUInt32ToDouble(temp, dest.fpu()); @@ -448,7 +448,7 @@ MacroAssembler::loadFromTypedArray(int arrayType, const T &src, AnyRegister dest j(Assembler::Signed, fail); } break; - case ScalarTypeRepresentation::TYPE_FLOAT32: + case ScalarTypeDescr::TYPE_FLOAT32: if (LIRGenerator::allowFloat32Optimizations()) { loadFloat32(src, dest.fpu()); canonicalizeFloat(dest.fpu()); @@ -457,7 +457,7 @@ MacroAssembler::loadFromTypedArray(int arrayType, const T &src, AnyRegister dest canonicalizeDouble(dest.fpu()); } break; - case ScalarTypeRepresentation::TYPE_FLOAT64: + case ScalarTypeDescr::TYPE_FLOAT64: loadDouble(src, dest.fpu()); canonicalizeDouble(dest.fpu()); break; @@ -477,16 +477,16 @@ MacroAssembler::loadFromTypedArray(int arrayType, const T &src, const ValueOpera bool allowDouble, Register temp, Label *fail) { switch (arrayType) { - case ScalarTypeRepresentation::TYPE_INT8: - case ScalarTypeRepresentation::TYPE_UINT8: - case ScalarTypeRepresentation::TYPE_UINT8_CLAMPED: - case ScalarTypeRepresentation::TYPE_INT16: - case ScalarTypeRepresentation::TYPE_UINT16: - case ScalarTypeRepresentation::TYPE_INT32: + 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: loadFromTypedArray(arrayType, src, AnyRegister(dest.scratchReg()), InvalidReg, nullptr); tagValue(JSVAL_TYPE_INT32, dest.scratchReg(), dest); break; - case ScalarTypeRepresentation::TYPE_UINT32: + case ScalarTypeDescr::TYPE_UINT32: // Don't clobber dest when we could fail, instead use temp. load32(src, temp); test32(temp, temp); @@ -511,14 +511,14 @@ MacroAssembler::loadFromTypedArray(int arrayType, const T &src, const ValueOpera tagValue(JSVAL_TYPE_INT32, temp, dest); } break; - case ScalarTypeRepresentation::TYPE_FLOAT32: + case ScalarTypeDescr::TYPE_FLOAT32: loadFromTypedArray(arrayType, src, AnyRegister(ScratchFloatReg), dest.scratchReg(), nullptr); if (LIRGenerator::allowFloat32Optimizations()) convertFloat32ToDouble(ScratchFloatReg, ScratchFloatReg); boxDouble(ScratchFloatReg, dest); break; - case ScalarTypeRepresentation::TYPE_FLOAT64: + case ScalarTypeDescr::TYPE_FLOAT64: loadFromTypedArray(arrayType, src, AnyRegister(ScratchFloatReg), dest.scratchReg(), nullptr); boxDouble(ScratchFloatReg, dest); diff --git a/js/src/jit/IonMacroAssembler.h b/js/src/jit/IonMacroAssembler.h index a61d9b649f2..9d230292c25 100644 --- a/js/src/jit/IonMacroAssembler.h +++ b/js/src/jit/IonMacroAssembler.h @@ -698,17 +698,17 @@ class MacroAssembler : public MacroAssemblerSpecific template void storeToTypedIntArray(int arrayType, const S &value, const T &dest) { switch (arrayType) { - case ScalarTypeRepresentation::TYPE_INT8: - case ScalarTypeRepresentation::TYPE_UINT8: - case ScalarTypeRepresentation::TYPE_UINT8_CLAMPED: + case ScalarTypeDescr::TYPE_INT8: + case ScalarTypeDescr::TYPE_UINT8: + case ScalarTypeDescr::TYPE_UINT8_CLAMPED: store8(value, dest); break; - case ScalarTypeRepresentation::TYPE_INT16: - case ScalarTypeRepresentation::TYPE_UINT16: + case ScalarTypeDescr::TYPE_INT16: + case ScalarTypeDescr::TYPE_UINT16: store16(value, dest); break; - case ScalarTypeRepresentation::TYPE_INT32: - case ScalarTypeRepresentation::TYPE_UINT32: + case ScalarTypeDescr::TYPE_INT32: + case ScalarTypeDescr::TYPE_UINT32: store32(value, dest); break; default: diff --git a/js/src/jit/Lowering.cpp b/js/src/jit/Lowering.cpp index c21cfcf6d61..44df0e88151 100644 --- a/js/src/jit/Lowering.cpp +++ b/js/src/jit/Lowering.cpp @@ -2652,7 +2652,7 @@ LIRGenerator::visitLoadTypedArrayElement(MLoadTypedArrayElement *ins) // We need a temp register for Uint32Array with known double result. LDefinition tempDef = LDefinition::BogusTemp(); - if (ins->arrayType() == ScalarTypeRepresentation::TYPE_UINT32 && IsFloatingPointType(ins->type())) + if (ins->arrayType() == ScalarTypeDescr::TYPE_UINT32 && IsFloatingPointType(ins->type())) tempDef = temp(); LLoadTypedArrayElement *lir = new(alloc()) LLoadTypedArrayElement(elements, index, tempDef); @@ -2725,9 +2725,9 @@ LIRGenerator::visitStoreTypedArrayElement(MStoreTypedArrayElement *ins) if (ins->isFloatArray()) { DebugOnly optimizeFloat32 = allowFloat32Optimizations(); - JS_ASSERT_IF(optimizeFloat32 && ins->arrayType() == ScalarTypeRepresentation::TYPE_FLOAT32, + JS_ASSERT_IF(optimizeFloat32 && ins->arrayType() == ScalarTypeDescr::TYPE_FLOAT32, ins->value()->type() == MIRType_Float32); - JS_ASSERT_IF(!optimizeFloat32 || ins->arrayType() == ScalarTypeRepresentation::TYPE_FLOAT64, + JS_ASSERT_IF(!optimizeFloat32 || ins->arrayType() == ScalarTypeDescr::TYPE_FLOAT64, ins->value()->type() == MIRType_Double); } else { JS_ASSERT(ins->value()->type() == MIRType_Int32); @@ -2754,9 +2754,9 @@ LIRGenerator::visitStoreTypedArrayElementHole(MStoreTypedArrayElementHole *ins) if (ins->isFloatArray()) { DebugOnly optimizeFloat32 = allowFloat32Optimizations(); - JS_ASSERT_IF(optimizeFloat32 && ins->arrayType() == ScalarTypeRepresentation::TYPE_FLOAT32, + JS_ASSERT_IF(optimizeFloat32 && ins->arrayType() == ScalarTypeDescr::TYPE_FLOAT32, ins->value()->type() == MIRType_Float32); - JS_ASSERT_IF(!optimizeFloat32 || ins->arrayType() == ScalarTypeRepresentation::TYPE_FLOAT64, + JS_ASSERT_IF(!optimizeFloat32 || ins->arrayType() == ScalarTypeDescr::TYPE_FLOAT64, ins->value()->type() == MIRType_Double); } else { JS_ASSERT(ins->value()->type() == MIRType_Int32); diff --git a/js/src/jit/MCallOptimize.cpp b/js/src/jit/MCallOptimize.cpp index 9c4b0c4c884..1beef8c1879 100644 --- a/js/src/jit/MCallOptimize.cpp +++ b/js/src/jit/MCallOptimize.cpp @@ -1257,7 +1257,7 @@ IonBuilder::inlineUnsafePutElements(CallInfo &callInfo) // We can only inline setelem on dense arrays that do not need type // barriers and on typed arrays. - ScalarTypeRepresentation::Type arrayType; + ScalarTypeDescr::Type arrayType; if ((!isDenseNative || writeNeedsBarrier) && !ElementAccessIsTypedArray(obj, id, &arrayType)) { @@ -1286,7 +1286,7 @@ IonBuilder::inlineUnsafePutElements(CallInfo &callInfo) continue; } - ScalarTypeRepresentation::Type arrayType; + ScalarTypeDescr::Type arrayType; if (ElementAccessIsTypedArray(obj, id, &arrayType)) { if (!inlineUnsafeSetTypedArrayElement(callInfo, base, arrayType)) return InliningStatus_Error; @@ -1323,7 +1323,7 @@ IonBuilder::inlineUnsafeSetDenseArrayElement(CallInfo &callInfo, uint32_t base) bool IonBuilder::inlineUnsafeSetTypedArrayElement(CallInfo &callInfo, uint32_t base, - ScalarTypeRepresentation::Type arrayType) + ScalarTypeDescr::Type arrayType) { // Note: we do not check the conditions that are asserted as true // in intrinsic_UnsafePutElements(): diff --git a/js/src/jit/MIR.cpp b/js/src/jit/MIR.cpp index a0598f8b3d5..ca27229b038 100644 --- a/js/src/jit/MIR.cpp +++ b/js/src/jit/MIR.cpp @@ -571,7 +571,7 @@ void MLoadTypedArrayElement::printOpcode(FILE *fp) const { MDefinition::printOpcode(fp); - fprintf(fp, " %s", ScalarTypeRepresentation::typeName(arrayType())); + fprintf(fp, " %s", ScalarTypeDescr::typeName(arrayType())); } void @@ -2926,7 +2926,7 @@ jit::ElementAccessIsDenseNative(MDefinition *obj, MDefinition *id) bool jit::ElementAccessIsTypedArray(MDefinition *obj, MDefinition *id, - ScalarTypeRepresentation::Type *arrayType) + ScalarTypeDescr::Type *arrayType) { if (obj->mightBeType(MIRType_String)) return false; @@ -2938,8 +2938,8 @@ jit::ElementAccessIsTypedArray(MDefinition *obj, MDefinition *id, if (!types) return false; - *arrayType = (ScalarTypeRepresentation::Type) types->getTypedArrayType(); - return *arrayType != ScalarTypeRepresentation::TYPE_MAX; + *arrayType = (ScalarTypeDescr::Type) types->getTypedArrayType(); + return *arrayType != ScalarTypeDescr::TYPE_MAX; } bool diff --git a/js/src/jit/MIR.h b/js/src/jit/MIR.h index a3a1a61a92a..d91a610587b 100644 --- a/js/src/jit/MIR.h +++ b/js/src/jit/MIR.h @@ -6107,34 +6107,34 @@ class MArrayConcat class MLoadTypedArrayElement : public MBinaryInstruction { - ScalarTypeRepresentation::Type arrayType_; + ScalarTypeDescr::Type arrayType_; MLoadTypedArrayElement(MDefinition *elements, MDefinition *index, - ScalarTypeRepresentation::Type arrayType) + ScalarTypeDescr::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 < ScalarTypeRepresentation::TYPE_MAX); + JS_ASSERT(arrayType >= 0 && arrayType < ScalarTypeDescr::TYPE_MAX); } public: INSTRUCTION_HEADER(LoadTypedArrayElement) static MLoadTypedArrayElement *New(TempAllocator &alloc, MDefinition *elements, MDefinition *index, - ScalarTypeRepresentation::Type arrayType) + ScalarTypeDescr::Type arrayType) { return new(alloc) MLoadTypedArrayElement(elements, index, arrayType); } - ScalarTypeRepresentation::Type arrayType() const { + ScalarTypeDescr::Type arrayType() const { return arrayType_; } bool fallible() const { // Bailout if the result does not fit in an int32. - return arrayType_ == ScalarTypeRepresentation::TYPE_UINT32 && type() == MIRType_Int32; + return arrayType_ == ScalarTypeDescr::TYPE_UINT32 && type() == MIRType_Int32; } MDefinition *elements() const { return getOperand(0); @@ -6150,7 +6150,7 @@ class MLoadTypedArrayElement void computeRange(TempAllocator &alloc); - bool canProduceFloat32() const { return arrayType_ == ScalarTypeRepresentation::TYPE_FLOAT32; } + bool canProduceFloat32() const { return arrayType_ == ScalarTypeDescr::TYPE_FLOAT32; } }; // Load a value from a typed array. Out-of-bounds accesses are handled using @@ -6168,7 +6168,7 @@ class MLoadTypedArrayElementHole setResultType(MIRType_Value); setMovable(); JS_ASSERT(index->type() == MIRType_Int32); - JS_ASSERT(arrayType >= 0 && arrayType < ScalarTypeRepresentation::TYPE_MAX); + JS_ASSERT(arrayType >= 0 && arrayType < ScalarTypeDescr::TYPE_MAX); } public: @@ -6187,7 +6187,7 @@ class MLoadTypedArrayElementHole return allowDouble_; } bool fallible() const { - return arrayType_ == ScalarTypeRepresentation::TYPE_UINT32 && !allowDouble_; + return arrayType_ == ScalarTypeDescr::TYPE_UINT32 && !allowDouble_; } TypePolicy *typePolicy() { return this; @@ -6201,7 +6201,7 @@ class MLoadTypedArrayElementHole AliasSet getAliasSet() const { return AliasSet::Load(AliasSet::TypedArrayElement); } - bool canProduceFloat32() const { return arrayType_ == ScalarTypeRepresentation::TYPE_FLOAT32; } + bool canProduceFloat32() const { return arrayType_ == ScalarTypeDescr::TYPE_FLOAT32; } }; // Load a value fallibly or infallibly from a statically known typed array. @@ -6213,9 +6213,9 @@ class MLoadTypedArrayElementStatic : MUnaryInstruction(ptr), typedArray_(typedArray), fallible_(true) { int type = typedArray_->type(); - if (type == ScalarTypeRepresentation::TYPE_FLOAT32) + if (type == ScalarTypeDescr::TYPE_FLOAT32) setResultType(MIRType_Float32); - else if (type == ScalarTypeRepresentation::TYPE_FLOAT64) + else if (type == ScalarTypeDescr::TYPE_FLOAT64) setResultType(MIRType_Double); else setResultType(MIRType_Int32); @@ -6258,7 +6258,7 @@ class MLoadTypedArrayElementStatic void computeRange(TempAllocator &alloc); bool truncate(); - bool canProduceFloat32() const { return typedArray_->type() == ScalarTypeRepresentation::TYPE_FLOAT32; } + bool canProduceFloat32() const { return typedArray_->type() == ScalarTypeDescr::TYPE_FLOAT32; } }; class MStoreTypedArrayElement @@ -6277,7 +6277,7 @@ class MStoreTypedArrayElement setMovable(); JS_ASSERT(elements->type() == MIRType_Elements); JS_ASSERT(index->type() == MIRType_Int32); - JS_ASSERT(arrayType >= 0 && arrayType < ScalarTypeRepresentation::TYPE_MAX); + JS_ASSERT(arrayType >= 0 && arrayType < ScalarTypeDescr::TYPE_MAX); } public: @@ -6293,13 +6293,13 @@ class MStoreTypedArrayElement return arrayType_; } bool isByteArray() const { - return (arrayType_ == ScalarTypeRepresentation::TYPE_INT8 || - arrayType_ == ScalarTypeRepresentation::TYPE_UINT8 || - arrayType_ == ScalarTypeRepresentation::TYPE_UINT8_CLAMPED); + return (arrayType_ == ScalarTypeDescr::TYPE_INT8 || + arrayType_ == ScalarTypeDescr::TYPE_UINT8 || + arrayType_ == ScalarTypeDescr::TYPE_UINT8_CLAMPED); } bool isFloatArray() const { - return (arrayType_ == ScalarTypeRepresentation::TYPE_FLOAT32 || - arrayType_ == ScalarTypeRepresentation::TYPE_FLOAT64); + return (arrayType_ == ScalarTypeDescr::TYPE_FLOAT32 || + arrayType_ == ScalarTypeDescr::TYPE_FLOAT64); } TypePolicy *typePolicy() { return this; @@ -6324,7 +6324,7 @@ class MStoreTypedArrayElement } bool isOperandTruncated(size_t index) const; - bool canConsumeFloat32() const { return arrayType_ == ScalarTypeRepresentation::TYPE_FLOAT32; } + bool canConsumeFloat32() const { return arrayType_ == ScalarTypeDescr::TYPE_FLOAT32; } }; class MStoreTypedArrayElementHole @@ -6345,7 +6345,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 < ScalarTypeRepresentation::TYPE_MAX); + JS_ASSERT(arrayType >= 0 && arrayType < ScalarTypeDescr::TYPE_MAX); } public: @@ -6362,13 +6362,13 @@ class MStoreTypedArrayElementHole return arrayType_; } bool isByteArray() const { - return (arrayType_ == ScalarTypeRepresentation::TYPE_INT8 || - arrayType_ == ScalarTypeRepresentation::TYPE_UINT8 || - arrayType_ == ScalarTypeRepresentation::TYPE_UINT8_CLAMPED); + return (arrayType_ == ScalarTypeDescr::TYPE_INT8 || + arrayType_ == ScalarTypeDescr::TYPE_UINT8 || + arrayType_ == ScalarTypeDescr::TYPE_UINT8_CLAMPED); } bool isFloatArray() const { - return (arrayType_ == ScalarTypeRepresentation::TYPE_FLOAT32 || - arrayType_ == ScalarTypeRepresentation::TYPE_FLOAT64); + return (arrayType_ == ScalarTypeDescr::TYPE_FLOAT32 || + arrayType_ == ScalarTypeDescr::TYPE_FLOAT64); } TypePolicy *typePolicy() { return this; @@ -6390,7 +6390,7 @@ class MStoreTypedArrayElementHole } bool isOperandTruncated(size_t index) const; - bool canConsumeFloat32() const { return arrayType_ == ScalarTypeRepresentation::TYPE_FLOAT32; } + bool canConsumeFloat32() const { return arrayType_ == ScalarTypeDescr::TYPE_FLOAT32; } }; // Store a value infallibly to a statically known typed array. @@ -6435,7 +6435,7 @@ class MStoreTypedArrayElementStatic : } bool isOperandTruncated(size_t index) const; - bool canConsumeFloat32() const { return typedArray_->type() == ScalarTypeRepresentation::TYPE_FLOAT32; } + bool canConsumeFloat32() const { return typedArray_->type() == ScalarTypeDescr::TYPE_FLOAT32; } }; // Compute an "effective address", i.e., a compound computation of the form: @@ -9764,7 +9764,7 @@ typedef Vector MDefinitionVector; bool ElementAccessIsDenseNative(MDefinition *obj, MDefinition *id); bool ElementAccessIsTypedArray(MDefinition *obj, MDefinition *id, - ScalarTypeRepresentation::Type *arrayType); + ScalarTypeDescr::Type *arrayType); bool ElementAccessIsPacked(types::CompilerConstraintList *constraints, MDefinition *obj); bool ElementAccessHasExtraIndexedProperty(types::CompilerConstraintList *constraints, MDefinition *obj); diff --git a/js/src/jit/RangeAnalysis.cpp b/js/src/jit/RangeAnalysis.cpp index 86fe44982bb..4d0a8b461b0 100644 --- a/js/src/jit/RangeAnalysis.cpp +++ b/js/src/jit/RangeAnalysis.cpp @@ -1392,23 +1392,23 @@ MToInt32::computeRange(TempAllocator &alloc) static Range *GetTypedArrayRange(TempAllocator &alloc, int type) { switch (type) { - case ScalarTypeRepresentation::TYPE_UINT8_CLAMPED: - case ScalarTypeRepresentation::TYPE_UINT8: + case ScalarTypeDescr::TYPE_UINT8_CLAMPED: + case ScalarTypeDescr::TYPE_UINT8: return Range::NewUInt32Range(alloc, 0, UINT8_MAX); - case ScalarTypeRepresentation::TYPE_UINT16: + case ScalarTypeDescr::TYPE_UINT16: return Range::NewUInt32Range(alloc, 0, UINT16_MAX); - case ScalarTypeRepresentation::TYPE_UINT32: + case ScalarTypeDescr::TYPE_UINT32: return Range::NewUInt32Range(alloc, 0, UINT32_MAX); - case ScalarTypeRepresentation::TYPE_INT8: + case ScalarTypeDescr::TYPE_INT8: return Range::NewInt32Range(alloc, INT8_MIN, INT8_MAX); - case ScalarTypeRepresentation::TYPE_INT16: + case ScalarTypeDescr::TYPE_INT16: return Range::NewInt32Range(alloc, INT16_MIN, INT16_MAX); - case ScalarTypeRepresentation::TYPE_INT32: + case ScalarTypeDescr::TYPE_INT32: return Range::NewInt32Range(alloc, INT32_MIN, INT32_MAX); - case ScalarTypeRepresentation::TYPE_FLOAT32: - case ScalarTypeRepresentation::TYPE_FLOAT64: + case ScalarTypeDescr::TYPE_FLOAT32: + case ScalarTypeDescr::TYPE_FLOAT64: break; } @@ -1428,7 +1428,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() != ScalarTypeRepresentation::TYPE_UINT32); + JS_ASSERT(typedArray_->type() != ScalarTypeDescr::TYPE_UINT32); setRange(GetTypedArrayRange(alloc, typedArray_->type())); } diff --git a/js/src/jit/TypeDescrSet.cpp b/js/src/jit/TypeDescrSet.cpp index 5c54fec9922..38c57ded21d 100644 --- a/js/src/jit/TypeDescrSet.cpp +++ b/js/src/jit/TypeDescrSet.cpp @@ -176,14 +176,14 @@ TypeDescrSet::allOfArrayKind() return false; switch (kind()) { - case TypeRepresentation::SizedArray: - case TypeRepresentation::UnsizedArray: + case TypeDescr::SizedArray: + case TypeDescr::UnsizedArray: return true; - case TypeRepresentation::X4: - case TypeRepresentation::Reference: - case TypeRepresentation::Scalar: - case TypeRepresentation::Struct: + case TypeDescr::X4: + case TypeDescr::Reference: + case TypeDescr::Scalar: + case TypeDescr::Struct: return false; } @@ -191,7 +191,7 @@ TypeDescrSet::allOfArrayKind() } bool -TypeDescrSet::allOfKind(TypeRepresentation::Kind aKind) +TypeDescrSet::allOfKind(TypeDescr::Kind aKind) { if (empty()) return false; @@ -205,7 +205,7 @@ TypeDescrSet::allHaveSameSize(size_t *out) if (empty()) return false; - JS_ASSERT(TypeRepresentation::isSized(kind())); + JS_ASSERT(TypeDescr::isSized(kind())); size_t size = get(0)->as().size(); for (size_t i = 1; i < length(); i++) { @@ -217,7 +217,7 @@ TypeDescrSet::allHaveSameSize(size_t *out) return true; } -TypeRepresentation::Kind +TypeDescr::Kind TypeDescrSet::kind() { JS_ASSERT(!empty()); @@ -226,11 +226,11 @@ TypeDescrSet::kind() template bool -TypeDescrSet::genericType(typename T::TypeRepr::Type *out) +TypeDescrSet::genericType(typename T::Type *out) { - JS_ASSERT(allOfKind(TypeRepresentation::Scalar)); + JS_ASSERT(allOfKind(TypeDescr::Scalar)); - typename T::TypeRepr::Type type = get(0)->as().type(); + typename T::Type type = get(0)->as().type(); for (size_t i = 1; i < length(); i++) { if (get(i)->as().type() != type) return false; @@ -241,19 +241,19 @@ TypeDescrSet::genericType(typename T::TypeRepr::Type *out) } bool -TypeDescrSet::scalarType(ScalarTypeRepresentation::Type *out) +TypeDescrSet::scalarType(ScalarTypeDescr::Type *out) { return genericType(out); } bool -TypeDescrSet::referenceType(ReferenceTypeRepresentation::Type *out) +TypeDescrSet::referenceType(ReferenceTypeDescr::Type *out) { return genericType(out); } bool -TypeDescrSet::x4Type(X4TypeRepresentation::Type *out) +TypeDescrSet::x4Type(X4TypeDescr::Type *out) { return genericType(out); } @@ -262,10 +262,10 @@ bool TypeDescrSet::hasKnownArrayLength(size_t *l) { switch (kind()) { - case TypeRepresentation::UnsizedArray: + case TypeDescr::UnsizedArray: return false; - case TypeRepresentation::SizedArray: + case TypeDescr::SizedArray: { const size_t result = get(0)->as().length(); for (size_t i = 1; i < length(); i++) { @@ -288,12 +288,12 @@ TypeDescrSet::arrayElementType(IonBuilder &builder, TypeDescrSet *out) TypeDescrSetBuilder elementTypes; for (size_t i = 0; i < length(); i++) { switch (kind()) { - case TypeRepresentation::UnsizedArray: + case TypeDescr::UnsizedArray: if (!elementTypes.insert(&get(i)->as().elementType())) return false; break; - case TypeRepresentation::SizedArray: + case TypeDescr::SizedArray: if (!elementTypes.insert(&get(i)->as().elementType())) return false; break; @@ -312,7 +312,7 @@ TypeDescrSet::fieldNamed(IonBuilder &builder, TypeDescrSet *out, size_t *index) { - JS_ASSERT(kind() == TypeRepresentation::Struct); + JS_ASSERT(kind() == TypeDescr::Struct); // Initialize `*offset` and `*out` for the case where incompatible // or absent fields are found. diff --git a/js/src/jit/TypeDescrSet.h b/js/src/jit/TypeDescrSet.h index 37f41ba2fab..e30e0b6ca9b 100644 --- a/js/src/jit/TypeDescrSet.h +++ b/js/src/jit/TypeDescrSet.h @@ -7,7 +7,7 @@ #ifndef jit_TypeRepresentationSet_h #define jit_TypeRepresentationSet_h -#include "builtin/TypeRepresentation.h" +#include "builtin/TypedObject.h" #include "jit/IonAllocPolicy.h" #include "js/HashTable.h" @@ -70,7 +70,7 @@ class TypeDescrSet { } template - bool genericType(typename T::TypeRepr::Type *out); + bool genericType(typename T::Type *out); public: ////////////////////////////////////////////////////////////////////// @@ -86,10 +86,10 @@ class TypeDescrSet { // Query the set bool empty(); - bool allOfKind(TypeRepresentation::Kind kind); + bool allOfKind(TypeDescr::Kind kind); // Returns true only when non-empty and `kind()` is - // `TypeRepresentation::Array` + // `TypeDescr::Array` bool allOfArrayKind(); // Returns true only if (1) non-empty, (2) for all types t in this @@ -105,39 +105,39 @@ class TypeDescrSet { ////////////////////////////////////////////////////////////////////// // The following operations are only valid on a non-empty set: - TypeRepresentation::Kind kind(); + TypeDescr::Kind kind(); ////////////////////////////////////////////////////////////////////// // Scalar operations // - // Only valid when `kind() == TypeRepresentation::Scalar` + // Only valid when `kind() == TypeDescr::Scalar` // If all type descrs in this set have a single type, returns true // and sets *out. Else returns false. - bool scalarType(ScalarTypeRepresentation::Type *out); + bool scalarType(ScalarTypeDescr::Type *out); ////////////////////////////////////////////////////////////////////// // Reference operations // - // Only valid when `kind() == TypeRepresentation::Reference` + // Only valid when `kind() == TypeDescr::Reference` // If all type descrs in this set have a single type, returns true // and sets *out. Else returns false. - bool referenceType(ReferenceTypeRepresentation::Type *out); + bool referenceType(ReferenceTypeDescr::Type *out); ////////////////////////////////////////////////////////////////////// // Reference operations // - // Only valid when `kind() == TypeRepresentation::X4` + // Only valid when `kind() == TypeDescr::X4` // If all type descrs in this set have a single type, returns true // and sets *out. Else returns false. - bool x4Type(X4TypeRepresentation::Type *out); + bool x4Type(X4TypeDescr::Type *out); ////////////////////////////////////////////////////////////////////// // SizedArray operations // - // Only valid when `kind() == TypeRepresentation::SizedArray` + // Only valid when `kind() == TypeDescr::SizedArray` // Determines whether all arrays in this set have the same, // statically known, array length and return that length @@ -152,7 +152,7 @@ class TypeDescrSet { ////////////////////////////////////////////////////////////////////// // Struct operations // - // Only valid when `kind() == TypeRepresentation::Struct` + // Only valid when `kind() == TypeDescr::Struct` // Searches the type in the set for a field named `id`. All // possible types must agree on the offset of the field within the diff --git a/js/src/jit/TypePolicy.cpp b/js/src/jit/TypePolicy.cpp index 34d142c3bbb..6b305c7a531 100644 --- a/js/src/jit/TypePolicy.cpp +++ b/js/src/jit/TypePolicy.cpp @@ -733,22 +733,22 @@ StoreTypedArrayPolicy::adjustValueInput(TempAllocator &alloc, MInstruction *ins, value->type() == MIRType_Value); switch (arrayType) { - case ScalarTypeRepresentation::TYPE_INT8: - case ScalarTypeRepresentation::TYPE_UINT8: - case ScalarTypeRepresentation::TYPE_INT16: - case ScalarTypeRepresentation::TYPE_UINT16: - case ScalarTypeRepresentation::TYPE_INT32: - case ScalarTypeRepresentation::TYPE_UINT32: + case ScalarTypeDescr::TYPE_INT8: + case ScalarTypeDescr::TYPE_UINT8: + case ScalarTypeDescr::TYPE_INT16: + case ScalarTypeDescr::TYPE_UINT16: + case ScalarTypeDescr::TYPE_INT32: + case ScalarTypeDescr::TYPE_UINT32: if (value->type() != MIRType_Int32) { value = MTruncateToInt32::New(alloc, value); ins->block()->insertBefore(ins, value->toInstruction()); } break; - case ScalarTypeRepresentation::TYPE_UINT8_CLAMPED: + case ScalarTypeDescr::TYPE_UINT8_CLAMPED: // IonBuilder should have inserted ClampToUint8. JS_ASSERT(value->type() == MIRType_Int32); break; - case ScalarTypeRepresentation::TYPE_FLOAT32: + case ScalarTypeDescr::TYPE_FLOAT32: if (LIRGenerator::allowFloat32Optimizations()) { if (value->type() != MIRType_Float32) { value = MToFloat32::New(alloc, value); @@ -758,7 +758,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 ScalarTypeRepresentation::TYPE_FLOAT64: + case ScalarTypeDescr::TYPE_FLOAT64: if (value->type() != MIRType_Double) { value = MToDouble::New(alloc, value); ins->block()->insertBefore(ins, value->toInstruction()); diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index a939a297706..b8cef048dd6 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -1139,7 +1139,7 @@ JS_InitStandardClasses(JSContext *cx, HandleObject obj) #define CLASP(name) (&name##Class) #define OCLASP(name) (&name##Object::class_) -#define TYPED_ARRAY_CLASP(type) (&TypedArrayObject::classes[ScalarTypeRepresentation::type]) +#define TYPED_ARRAY_CLASP(type) (&TypedArrayObject::classes[ScalarTypeDescr::type]) #define EAGER_ATOM(name) NAME_OFFSET(name) #define EAGER_CLASS_ATOM(name) NAME_OFFSET(name) diff --git a/js/src/jscompartment.h b/js/src/jscompartment.h index 117701dcfc0..5e363bab32d 100644 --- a/js/src/jscompartment.h +++ b/js/src/jscompartment.h @@ -9,6 +9,7 @@ #include "mozilla/MemoryReporting.h" +#include "builtin/TypedObject.h" #include "builtin/TypeRepresentation.h" #include "gc/Zone.h" #include "vm/GlobalObject.h" diff --git a/js/src/jsinfer.cpp b/js/src/jsinfer.cpp index 08997ee0a08..4661247d556 100644 --- a/js/src/jsinfer.cpp +++ b/js/src/jsinfer.cpp @@ -21,7 +21,6 @@ #include "jsworkers.h" #include "prmjtime.h" -#include "builtin/TypedObject.h" #include "gc/Marking.h" #ifdef JS_ION #include "jit/BaselineJIT.h" @@ -1713,7 +1712,7 @@ TemporaryTypeSet::getTypedArrayType() if (clasp && IsTypedArrayClass(clasp)) return clasp - &TypedArrayObject::classes[0]; - return ScalarTypeRepresentation::TYPE_MAX; + return ScalarTypeDescr::TYPE_MAX; } bool diff --git a/js/src/jsprototypes.h b/js/src/jsprototypes.h index f85f30782f0..b3dbe0eef30 100644 --- a/js/src/jsprototypes.h +++ b/js/src/jsprototypes.h @@ -34,7 +34,7 @@ #define CLASP(name) (&name##Class) #define OCLASP(name) (&name##Object::class_) -#define TYPED_ARRAY_CLASP(type) (&TypedArrayObject::classes[ScalarTypeRepresentation::type]) +#define TYPED_ARRAY_CLASP(type) (&TypedArrayObject::classes[ScalarTypeDescr::type]) #ifdef ENABLE_PARALLEL_JS #define IF_PJS(real,imaginary) real diff --git a/js/src/vm/StructuredClone.cpp b/js/src/vm/StructuredClone.cpp index 09b957a786a..8b7a627c1fc 100644 --- a/js/src/vm/StructuredClone.cpp +++ b/js/src/vm/StructuredClone.cpp @@ -73,16 +73,16 @@ enum StructuredDataType { SCTAG_DO_NOT_USE_2, SCTAG_TYPED_ARRAY_OBJECT, SCTAG_TYPED_ARRAY_V1_MIN = 0xFFFF0100, - SCTAG_TYPED_ARRAY_V1_INT8 = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeRepresentation::TYPE_INT8, - SCTAG_TYPED_ARRAY_V1_UINT8 = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeRepresentation::TYPE_UINT8, - SCTAG_TYPED_ARRAY_V1_INT16 = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeRepresentation::TYPE_INT16, - SCTAG_TYPED_ARRAY_V1_UINT16 = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeRepresentation::TYPE_UINT16, - SCTAG_TYPED_ARRAY_V1_INT32 = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeRepresentation::TYPE_INT32, - SCTAG_TYPED_ARRAY_V1_UINT32 = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeRepresentation::TYPE_UINT32, - SCTAG_TYPED_ARRAY_V1_FLOAT32 = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeRepresentation::TYPE_FLOAT32, - SCTAG_TYPED_ARRAY_V1_FLOAT64 = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeRepresentation::TYPE_FLOAT64, - SCTAG_TYPED_ARRAY_V1_UINT8_CLAMPED = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeRepresentation::TYPE_UINT8_CLAMPED, - SCTAG_TYPED_ARRAY_V1_MAX = SCTAG_TYPED_ARRAY_V1_MIN + ScalarTypeRepresentation::TYPE_MAX - 1, + 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, /* * Define a separate range of numbers for Transferable-only tags, since @@ -308,7 +308,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(ScalarTypeRepresentation::TYPE_INT8 == 0); +JS_STATIC_ASSERT(ScalarTypeDescr::TYPE_INT8 == 0); namespace js { @@ -1125,7 +1125,7 @@ bool JSStructuredCloneReader::readTypedArray(uint32_t arrayType, uint32_t nelems, Value *vp, bool v1Read) { - if (arrayType > ScalarTypeRepresentation::TYPE_UINT8_CLAMPED) { + if (arrayType > ScalarTypeDescr::TYPE_UINT8_CLAMPED) { JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, "unhandled typed array element type"); return false; @@ -1156,31 +1156,31 @@ JSStructuredCloneReader::readTypedArray(uint32_t arrayType, uint32_t nelems, Val RootedObject obj(context(), nullptr); switch (arrayType) { - case ScalarTypeRepresentation::TYPE_INT8: + case ScalarTypeDescr::TYPE_INT8: obj = JS_NewInt8ArrayWithBuffer(context(), buffer, byteOffset, nelems); break; - case ScalarTypeRepresentation::TYPE_UINT8: + case ScalarTypeDescr::TYPE_UINT8: obj = JS_NewUint8ArrayWithBuffer(context(), buffer, byteOffset, nelems); break; - case ScalarTypeRepresentation::TYPE_INT16: + case ScalarTypeDescr::TYPE_INT16: obj = JS_NewInt16ArrayWithBuffer(context(), buffer, byteOffset, nelems); break; - case ScalarTypeRepresentation::TYPE_UINT16: + case ScalarTypeDescr::TYPE_UINT16: obj = JS_NewUint16ArrayWithBuffer(context(), buffer, byteOffset, nelems); break; - case ScalarTypeRepresentation::TYPE_INT32: + case ScalarTypeDescr::TYPE_INT32: obj = JS_NewInt32ArrayWithBuffer(context(), buffer, byteOffset, nelems); break; - case ScalarTypeRepresentation::TYPE_UINT32: + case ScalarTypeDescr::TYPE_UINT32: obj = JS_NewUint32ArrayWithBuffer(context(), buffer, byteOffset, nelems); break; - case ScalarTypeRepresentation::TYPE_FLOAT32: + case ScalarTypeDescr::TYPE_FLOAT32: obj = JS_NewFloat32ArrayWithBuffer(context(), buffer, byteOffset, nelems); break; - case ScalarTypeRepresentation::TYPE_FLOAT64: + case ScalarTypeDescr::TYPE_FLOAT64: obj = JS_NewFloat64ArrayWithBuffer(context(), buffer, byteOffset, nelems); break; - case ScalarTypeRepresentation::TYPE_UINT8_CLAMPED: + case ScalarTypeDescr::TYPE_UINT8_CLAMPED: obj = JS_NewUint8ClampedArrayWithBuffer(context(), buffer, byteOffset, nelems); break; default: @@ -1212,18 +1212,18 @@ static size_t bytesPerTypedArrayElement(uint32_t arrayType) { switch (arrayType) { - case ScalarTypeRepresentation::TYPE_INT8: - case ScalarTypeRepresentation::TYPE_UINT8: - case ScalarTypeRepresentation::TYPE_UINT8_CLAMPED: + case ScalarTypeDescr::TYPE_INT8: + case ScalarTypeDescr::TYPE_UINT8: + case ScalarTypeDescr::TYPE_UINT8_CLAMPED: return sizeof(uint8_t); - case ScalarTypeRepresentation::TYPE_INT16: - case ScalarTypeRepresentation::TYPE_UINT16: + case ScalarTypeDescr::TYPE_INT16: + case ScalarTypeDescr::TYPE_UINT16: return sizeof(uint16_t); - case ScalarTypeRepresentation::TYPE_INT32: - case ScalarTypeRepresentation::TYPE_UINT32: - case ScalarTypeRepresentation::TYPE_FLOAT32: + case ScalarTypeDescr::TYPE_INT32: + case ScalarTypeDescr::TYPE_UINT32: + case ScalarTypeDescr::TYPE_FLOAT32: return sizeof(uint32_t); - case ScalarTypeRepresentation::TYPE_FLOAT64: + case ScalarTypeDescr::TYPE_FLOAT64: return sizeof(uint64_t); default: MOZ_ASSUME_UNREACHABLE("unknown TypedArrayObject type"); @@ -1237,7 +1237,7 @@ bytesPerTypedArrayElement(uint32_t arrayType) bool JSStructuredCloneReader::readV1ArrayBuffer(uint32_t arrayType, uint32_t nelems, Value *vp) { - JS_ASSERT(arrayType <= ScalarTypeRepresentation::TYPE_UINT8_CLAMPED); + JS_ASSERT(arrayType <= ScalarTypeDescr::TYPE_UINT8_CLAMPED); uint32_t nbytes = nelems * bytesPerTypedArrayElement(arrayType); JSObject *obj = ArrayBufferObject::create(context(), nbytes); @@ -1248,18 +1248,18 @@ JSStructuredCloneReader::readV1ArrayBuffer(uint32_t arrayType, uint32_t nelems, JS_ASSERT(buffer.byteLength() == nbytes); switch (arrayType) { - case ScalarTypeRepresentation::TYPE_INT8: - case ScalarTypeRepresentation::TYPE_UINT8: - case ScalarTypeRepresentation::TYPE_UINT8_CLAMPED: + case ScalarTypeDescr::TYPE_INT8: + case ScalarTypeDescr::TYPE_UINT8: + case ScalarTypeDescr::TYPE_UINT8_CLAMPED: return in.readArray((uint8_t*) buffer.dataPointer(), nelems); - case ScalarTypeRepresentation::TYPE_INT16: - case ScalarTypeRepresentation::TYPE_UINT16: + case ScalarTypeDescr::TYPE_INT16: + case ScalarTypeDescr::TYPE_UINT16: return in.readArray((uint16_t*) buffer.dataPointer(), nelems); - case ScalarTypeRepresentation::TYPE_INT32: - case ScalarTypeRepresentation::TYPE_UINT32: - case ScalarTypeRepresentation::TYPE_FLOAT32: + case ScalarTypeDescr::TYPE_INT32: + case ScalarTypeDescr::TYPE_UINT32: + case ScalarTypeDescr::TYPE_FLOAT32: return in.readArray((uint32_t*) buffer.dataPointer(), nelems); - case ScalarTypeRepresentation::TYPE_FLOAT64: + case ScalarTypeDescr::TYPE_FLOAT64: return in.readArray((uint64_t*) buffer.dataPointer(), nelems); default: MOZ_ASSUME_UNREACHABLE("unknown TypedArrayObject type"); diff --git a/js/src/vm/TypedArrayObject.cpp b/js/src/vm/TypedArrayObject.cpp index b0801315d45..e6720e59a05 100644 --- a/js/src/vm/TypedArrayObject.cpp +++ b/js/src/vm/TypedArrayObject.cpp @@ -1397,15 +1397,15 @@ ArrayBufferViewObject::trace(JSTracer *trc, JSObject *obj) } template static inline const int TypeIDOfType(); -template<> inline const int TypeIDOfType() { return ScalarTypeRepresentation::TYPE_INT8; } -template<> inline const int TypeIDOfType() { return ScalarTypeRepresentation::TYPE_UINT8; } -template<> inline const int TypeIDOfType() { return ScalarTypeRepresentation::TYPE_INT16; } -template<> inline const int TypeIDOfType() { return ScalarTypeRepresentation::TYPE_UINT16; } -template<> inline const int TypeIDOfType() { return ScalarTypeRepresentation::TYPE_INT32; } -template<> inline const int TypeIDOfType() { return ScalarTypeRepresentation::TYPE_UINT32; } -template<> inline const int TypeIDOfType() { return ScalarTypeRepresentation::TYPE_FLOAT32; } -template<> inline const int TypeIDOfType() { return ScalarTypeRepresentation::TYPE_FLOAT64; } -template<> inline const int TypeIDOfType() { return ScalarTypeRepresentation::TYPE_UINT8_CLAMPED; } +template<> inline const int TypeIDOfType() { return ScalarTypeDescr::TYPE_INT8; } +template<> inline const int TypeIDOfType() { return ScalarTypeDescr::TYPE_UINT8; } +template<> inline const int TypeIDOfType() { return ScalarTypeDescr::TYPE_INT16; } +template<> inline const int TypeIDOfType() { return ScalarTypeDescr::TYPE_UINT16; } +template<> inline const int TypeIDOfType() { return ScalarTypeDescr::TYPE_INT32; } +template<> inline const int TypeIDOfType() { return ScalarTypeDescr::TYPE_UINT32; } +template<> inline const int TypeIDOfType() { return ScalarTypeDescr::TYPE_FLOAT32; } +template<> inline const int TypeIDOfType() { return ScalarTypeDescr::TYPE_FLOAT64; } +template<> inline const int TypeIDOfType() { return ScalarTypeDescr::TYPE_UINT8_CLAMPED; } template static inline JSObject * @@ -1542,7 +1542,7 @@ class TypedArrayObjectTemplate : public TypedArrayObject JS_ASSERT(sizeof(NativeType) <= 4); uint32_t n = ToUint32(d); setIndex(tarray, index, NativeType(n)); - } else if (ArrayTypeID() == ScalarTypeRepresentation::TYPE_UINT8_CLAMPED) { + } else if (ArrayTypeID() == ScalarTypeDescr::TYPE_UINT8_CLAMPED) { // The uint8_clamped type has a special rounding converter // for doubles. setIndex(tarray, index, NativeType(d)); @@ -2403,50 +2403,50 @@ class TypedArrayObjectTemplate : public TypedArrayObject unsigned srclen = tarray->length(); switch (tarray->type()) { - case ScalarTypeRepresentation::TYPE_INT8: { + case ScalarTypeDescr::TYPE_INT8: { int8_t *src = static_cast(tarray->viewData()); for (unsigned i = 0; i < srclen; ++i) *dest++ = NativeType(*src++); break; } - case ScalarTypeRepresentation::TYPE_UINT8: - case ScalarTypeRepresentation::TYPE_UINT8_CLAMPED: { + case ScalarTypeDescr::TYPE_UINT8: + case ScalarTypeDescr::TYPE_UINT8_CLAMPED: { uint8_t *src = static_cast(tarray->viewData()); for (unsigned i = 0; i < srclen; ++i) *dest++ = NativeType(*src++); break; } - case ScalarTypeRepresentation::TYPE_INT16: { + case ScalarTypeDescr::TYPE_INT16: { int16_t *src = static_cast(tarray->viewData()); for (unsigned i = 0; i < srclen; ++i) *dest++ = NativeType(*src++); break; } - case ScalarTypeRepresentation::TYPE_UINT16: { + case ScalarTypeDescr::TYPE_UINT16: { uint16_t *src = static_cast(tarray->viewData()); for (unsigned i = 0; i < srclen; ++i) *dest++ = NativeType(*src++); break; } - case ScalarTypeRepresentation::TYPE_INT32: { + case ScalarTypeDescr::TYPE_INT32: { int32_t *src = static_cast(tarray->viewData()); for (unsigned i = 0; i < srclen; ++i) *dest++ = NativeType(*src++); break; } - case ScalarTypeRepresentation::TYPE_UINT32: { + case ScalarTypeDescr::TYPE_UINT32: { uint32_t *src = static_cast(tarray->viewData()); for (unsigned i = 0; i < srclen; ++i) *dest++ = NativeType(*src++); break; } - case ScalarTypeRepresentation::TYPE_FLOAT32: { + case ScalarTypeDescr::TYPE_FLOAT32: { float *src = static_cast(tarray->viewData()); for (unsigned i = 0; i < srclen; ++i) *dest++ = NativeType(*src++); break; } - case ScalarTypeRepresentation::TYPE_FLOAT64: { + case ScalarTypeDescr::TYPE_FLOAT64: { double *src = static_cast(tarray->viewData()); for (unsigned i = 0; i < srclen; ++i) *dest++ = NativeType(*src++); @@ -2483,50 +2483,50 @@ class TypedArrayObjectTemplate : public TypedArrayObject js_memcpy(srcbuf, tarray->viewData(), byteLength); switch (tarray->type()) { - case ScalarTypeRepresentation::TYPE_INT8: { + case ScalarTypeDescr::TYPE_INT8: { int8_t *src = (int8_t*) srcbuf; for (unsigned i = 0; i < tarray->length(); ++i) *dest++ = NativeType(*src++); break; } - case ScalarTypeRepresentation::TYPE_UINT8: - case ScalarTypeRepresentation::TYPE_UINT8_CLAMPED: { + case ScalarTypeDescr::TYPE_UINT8: + case ScalarTypeDescr::TYPE_UINT8_CLAMPED: { uint8_t *src = (uint8_t*) srcbuf; for (unsigned i = 0; i < tarray->length(); ++i) *dest++ = NativeType(*src++); break; } - case ScalarTypeRepresentation::TYPE_INT16: { + case ScalarTypeDescr::TYPE_INT16: { int16_t *src = (int16_t*) srcbuf; for (unsigned i = 0; i < tarray->length(); ++i) *dest++ = NativeType(*src++); break; } - case ScalarTypeRepresentation::TYPE_UINT16: { + case ScalarTypeDescr::TYPE_UINT16: { uint16_t *src = (uint16_t*) srcbuf; for (unsigned i = 0; i < tarray->length(); ++i) *dest++ = NativeType(*src++); break; } - case ScalarTypeRepresentation::TYPE_INT32: { + case ScalarTypeDescr::TYPE_INT32: { int32_t *src = (int32_t*) srcbuf; for (unsigned i = 0; i < tarray->length(); ++i) *dest++ = NativeType(*src++); break; } - case ScalarTypeRepresentation::TYPE_UINT32: { + case ScalarTypeDescr::TYPE_UINT32: { uint32_t *src = (uint32_t*) srcbuf; for (unsigned i = 0; i < tarray->length(); ++i) *dest++ = NativeType(*src++); break; } - case ScalarTypeRepresentation::TYPE_FLOAT32: { + case ScalarTypeDescr::TYPE_FLOAT32: { float *src = (float*) srcbuf; for (unsigned i = 0; i < tarray->length(); ++i) *dest++ = NativeType(*src++); break; } - case ScalarTypeRepresentation::TYPE_FLOAT64: { + case ScalarTypeDescr::TYPE_FLOAT64: { double *src = (double*) srcbuf; for (unsigned i = 0; i < tarray->length(); ++i) *dest++ = NativeType(*src++); @@ -2557,55 +2557,55 @@ class TypedArrayObjectTemplate : public TypedArrayObject class Int8ArrayObject : public TypedArrayObjectTemplate { public: - enum { ACTUAL_TYPE = ScalarTypeRepresentation::TYPE_INT8 }; + enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_INT8 }; static const JSProtoKey key = JSProto_Int8Array; static const JSFunctionSpec jsfuncs[]; }; class Uint8ArrayObject : public TypedArrayObjectTemplate { public: - enum { ACTUAL_TYPE = ScalarTypeRepresentation::TYPE_UINT8 }; + enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_UINT8 }; static const JSProtoKey key = JSProto_Uint8Array; static const JSFunctionSpec jsfuncs[]; }; class Int16ArrayObject : public TypedArrayObjectTemplate { public: - enum { ACTUAL_TYPE = ScalarTypeRepresentation::TYPE_INT16 }; + enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_INT16 }; static const JSProtoKey key = JSProto_Int16Array; static const JSFunctionSpec jsfuncs[]; }; class Uint16ArrayObject : public TypedArrayObjectTemplate { public: - enum { ACTUAL_TYPE = ScalarTypeRepresentation::TYPE_UINT16 }; + enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_UINT16 }; static const JSProtoKey key = JSProto_Uint16Array; static const JSFunctionSpec jsfuncs[]; }; class Int32ArrayObject : public TypedArrayObjectTemplate { public: - enum { ACTUAL_TYPE = ScalarTypeRepresentation::TYPE_INT32 }; + enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_INT32 }; static const JSProtoKey key = JSProto_Int32Array; static const JSFunctionSpec jsfuncs[]; }; class Uint32ArrayObject : public TypedArrayObjectTemplate { public: - enum { ACTUAL_TYPE = ScalarTypeRepresentation::TYPE_UINT32 }; + enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_UINT32 }; static const JSProtoKey key = JSProto_Uint32Array; static const JSFunctionSpec jsfuncs[]; }; class Float32ArrayObject : public TypedArrayObjectTemplate { public: - enum { ACTUAL_TYPE = ScalarTypeRepresentation::TYPE_FLOAT32 }; + enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_FLOAT32 }; static const JSProtoKey key = JSProto_Float32Array; static const JSFunctionSpec jsfuncs[]; }; class Float64ArrayObject : public TypedArrayObjectTemplate { public: - enum { ACTUAL_TYPE = ScalarTypeRepresentation::TYPE_FLOAT64 }; + enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_FLOAT64 }; static const JSProtoKey key = JSProto_Float64Array; static const JSFunctionSpec jsfuncs[]; }; class Uint8ClampedArrayObject : public TypedArrayObjectTemplate { public: - enum { ACTUAL_TYPE = ScalarTypeRepresentation::TYPE_UINT8_CLAMPED }; + enum { ACTUAL_TYPE = ScalarTypeDescr::TYPE_UINT8_CLAMPED }; static const JSProtoKey key = JSProto_Uint8ClampedArray; static const JSFunctionSpec jsfuncs[]; }; @@ -3391,31 +3391,31 @@ TypedArrayObject::copyTypedArrayElement(uint32_t index, MutableHandleValue vp) JS_ASSERT(index < length()); switch (type()) { - case ScalarTypeRepresentation::TYPE_INT8: + case ScalarTypeDescr::TYPE_INT8: TypedArrayObjectTemplate::copyIndexToValue(this, index, vp); break; - case ScalarTypeRepresentation::TYPE_UINT8: + case ScalarTypeDescr::TYPE_UINT8: TypedArrayObjectTemplate::copyIndexToValue(this, index, vp); break; - case ScalarTypeRepresentation::TYPE_UINT8_CLAMPED: + case ScalarTypeDescr::TYPE_UINT8_CLAMPED: TypedArrayObjectTemplate::copyIndexToValue(this, index, vp); break; - case ScalarTypeRepresentation::TYPE_INT16: + case ScalarTypeDescr::TYPE_INT16: TypedArrayObjectTemplate::copyIndexToValue(this, index, vp); break; - case ScalarTypeRepresentation::TYPE_UINT16: + case ScalarTypeDescr::TYPE_UINT16: TypedArrayObjectTemplate::copyIndexToValue(this, index, vp); break; - case ScalarTypeRepresentation::TYPE_INT32: + case ScalarTypeDescr::TYPE_INT32: TypedArrayObjectTemplate::copyIndexToValue(this, index, vp); break; - case ScalarTypeRepresentation::TYPE_UINT32: + case ScalarTypeDescr::TYPE_UINT32: TypedArrayObjectTemplate::copyIndexToValue(this, index, vp); break; - case ScalarTypeRepresentation::TYPE_FLOAT32: + case ScalarTypeDescr::TYPE_FLOAT32: TypedArrayObjectTemplate::copyIndexToValue(this, index, vp); break; - case ScalarTypeRepresentation::TYPE_FLOAT64: + case ScalarTypeDescr::TYPE_FLOAT64: TypedArrayObjectTemplate::copyIndexToValue(this, index, vp); break; default: @@ -3720,7 +3720,7 @@ IMPL_TYPED_ARRAY_STATICS(Float32Array); IMPL_TYPED_ARRAY_STATICS(Float64Array); IMPL_TYPED_ARRAY_STATICS(Uint8ClampedArray); -const Class TypedArrayObject::classes[ScalarTypeRepresentation::TYPE_MAX] = { +const Class TypedArrayObject::classes[ScalarTypeDescr::TYPE_MAX] = { IMPL_TYPED_ARRAY_FAST_CLASS(Int8Array), IMPL_TYPED_ARRAY_FAST_CLASS(Uint8Array), IMPL_TYPED_ARRAY_FAST_CLASS(Int16Array), @@ -3732,7 +3732,7 @@ const Class TypedArrayObject::classes[ScalarTypeRepresentation::TYPE_MAX] = { IMPL_TYPED_ARRAY_FAST_CLASS(Uint8ClampedArray) }; -const Class TypedArrayObject::protoClasses[ScalarTypeRepresentation::TYPE_MAX] = { +const Class TypedArrayObject::protoClasses[ScalarTypeDescr::TYPE_MAX] = { IMPL_TYPED_ARRAY_PROTO_CLASS(Int8Array), IMPL_TYPED_ARRAY_PROTO_CLASS(Uint8Array), IMPL_TYPED_ARRAY_PROTO_CLASS(Int16Array), @@ -3978,23 +3978,23 @@ bool js::IsTypedArrayConstructor(HandleValue v, uint32_t type) { switch (type) { - case ScalarTypeRepresentation::TYPE_INT8: + case ScalarTypeDescr::TYPE_INT8: return IsNativeFunction(v, Int8ArrayObject::class_constructor); - case ScalarTypeRepresentation::TYPE_UINT8: + case ScalarTypeDescr::TYPE_UINT8: return IsNativeFunction(v, Uint8ArrayObject::class_constructor); - case ScalarTypeRepresentation::TYPE_INT16: + case ScalarTypeDescr::TYPE_INT16: return IsNativeFunction(v, Int16ArrayObject::class_constructor); - case ScalarTypeRepresentation::TYPE_UINT16: + case ScalarTypeDescr::TYPE_UINT16: return IsNativeFunction(v, Uint16ArrayObject::class_constructor); - case ScalarTypeRepresentation::TYPE_INT32: + case ScalarTypeDescr::TYPE_INT32: return IsNativeFunction(v, Int32ArrayObject::class_constructor); - case ScalarTypeRepresentation::TYPE_UINT32: + case ScalarTypeDescr::TYPE_UINT32: return IsNativeFunction(v, Uint32ArrayObject::class_constructor); - case ScalarTypeRepresentation::TYPE_FLOAT32: + case ScalarTypeDescr::TYPE_FLOAT32: return IsNativeFunction(v, Float32ArrayObject::class_constructor); - case ScalarTypeRepresentation::TYPE_FLOAT64: + case ScalarTypeDescr::TYPE_FLOAT64: return IsNativeFunction(v, Float64ArrayObject::class_constructor); - case ScalarTypeRepresentation::TYPE_UINT8_CLAMPED: + case ScalarTypeDescr::TYPE_UINT8_CLAMPED: return IsNativeFunction(v, Uint8ClampedArrayObject::class_constructor); } MOZ_ASSUME_UNREACHABLE("unexpected typed array type"); diff --git a/js/src/vm/TypedArrayObject.h b/js/src/vm/TypedArrayObject.h index 82909d1b5ae..7ec12ce938b 100644 --- a/js/src/vm/TypedArrayObject.h +++ b/js/src/vm/TypedArrayObject.h @@ -9,7 +9,7 @@ #include "jsobj.h" -#include "builtin/TypeRepresentation.h" +#include "builtin/TypedObject.h" #include "gc/Barrier.h" #include "js/Class.h" @@ -303,8 +303,8 @@ class TypedArrayObject : public ArrayBufferViewObject static const size_t DATA_SLOT = 7; // private slot, based on alloc kind public: - static const Class classes[ScalarTypeRepresentation::TYPE_MAX]; - static const Class protoClasses[ScalarTypeRepresentation::TYPE_MAX]; + static const Class classes[ScalarTypeDescr::TYPE_MAX]; + static const Class protoClasses[ScalarTypeDescr::TYPE_MAX]; static bool obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, MutableHandleObject objp, MutableHandleShape propp); @@ -364,18 +364,18 @@ class TypedArrayObject : public ArrayBufferViewObject static uint32_t slotWidth(int atype) { switch (atype) { - case ScalarTypeRepresentation::TYPE_INT8: - case ScalarTypeRepresentation::TYPE_UINT8: - case ScalarTypeRepresentation::TYPE_UINT8_CLAMPED: + case ScalarTypeDescr::TYPE_INT8: + case ScalarTypeDescr::TYPE_UINT8: + case ScalarTypeDescr::TYPE_UINT8_CLAMPED: return 1; - case ScalarTypeRepresentation::TYPE_INT16: - case ScalarTypeRepresentation::TYPE_UINT16: + case ScalarTypeDescr::TYPE_INT16: + case ScalarTypeDescr::TYPE_UINT16: return 2; - case ScalarTypeRepresentation::TYPE_INT32: - case ScalarTypeRepresentation::TYPE_UINT32: - case ScalarTypeRepresentation::TYPE_FLOAT32: + case ScalarTypeDescr::TYPE_INT32: + case ScalarTypeDescr::TYPE_UINT32: + case ScalarTypeDescr::TYPE_FLOAT32: return 4; - case ScalarTypeRepresentation::TYPE_FLOAT64: + case ScalarTypeDescr::TYPE_FLOAT64: return 8; default: MOZ_ASSUME_UNREACHABLE("invalid typed array type"); @@ -400,14 +400,14 @@ inline bool IsTypedArrayClass(const Class *clasp) { return &TypedArrayObject::classes[0] <= clasp && - clasp < &TypedArrayObject::classes[ScalarTypeRepresentation::TYPE_MAX]; + clasp < &TypedArrayObject::classes[ScalarTypeDescr::TYPE_MAX]; } inline bool IsTypedArrayProtoClass(const Class *clasp) { return &TypedArrayObject::protoClasses[0] <= clasp && - clasp < &TypedArrayObject::protoClasses[ScalarTypeRepresentation::TYPE_MAX]; + clasp < &TypedArrayObject::protoClasses[ScalarTypeDescr::TYPE_MAX]; } bool