--- a/js/src/builtin/SIMD.cpp
+++ b/js/src/builtin/SIMD.cpp
@@ -146,250 +146,138 @@ const Class SimdTypeDescr::class_ = {
};
namespace {
// These classes just exist to group together various properties and so on.
class Int8x16Defn {
public:
static const SimdTypeDescr::Type type = SimdTypeDescr::Int8x16;
- static const JSFunctionSpec TypeDescriptorMethods[];
- static const JSFunctionSpec TypedObjectMethods[];
static const JSFunctionSpec Methods[];
};
class Int16x8Defn {
public:
static const SimdTypeDescr::Type type = SimdTypeDescr::Int16x8;
- static const JSFunctionSpec TypeDescriptorMethods[];
- static const JSFunctionSpec TypedObjectMethods[];
static const JSFunctionSpec Methods[];
};
class Int32x4Defn {
public:
static const SimdTypeDescr::Type type = SimdTypeDescr::Int32x4;
- static const JSFunctionSpec TypeDescriptorMethods[];
- static const JSFunctionSpec TypedObjectMethods[];
static const JSFunctionSpec Methods[];
};
class Float32x4Defn {
public:
static const SimdTypeDescr::Type type = SimdTypeDescr::Float32x4;
- static const JSFunctionSpec TypeDescriptorMethods[];
- static const JSFunctionSpec TypedObjectMethods[];
static const JSFunctionSpec Methods[];
};
class Float64x2Defn {
public:
static const SimdTypeDescr::Type type = SimdTypeDescr::Float64x2;
- static const JSFunctionSpec TypeDescriptorMethods[];
- static const JSFunctionSpec TypedObjectMethods[];
static const JSFunctionSpec Methods[];
};
class Bool8x16Defn {
public:
static const SimdTypeDescr::Type type = SimdTypeDescr::Bool8x16;
- static const JSFunctionSpec TypeDescriptorMethods[];
- static const JSFunctionSpec TypedObjectMethods[];
static const JSFunctionSpec Methods[];
};
class Bool16x8Defn {
public:
static const SimdTypeDescr::Type type = SimdTypeDescr::Bool16x8;
- static const JSFunctionSpec TypeDescriptorMethods[];
- static const JSFunctionSpec TypedObjectMethods[];
static const JSFunctionSpec Methods[];
};
class Bool32x4Defn {
public:
static const SimdTypeDescr::Type type = SimdTypeDescr::Bool32x4;
- static const JSFunctionSpec TypeDescriptorMethods[];
- static const JSFunctionSpec TypedObjectMethods[];
static const JSFunctionSpec Methods[];
};
class Bool64x2Defn {
public:
static const SimdTypeDescr::Type type = SimdTypeDescr::Bool64x2;
- static const JSFunctionSpec TypeDescriptorMethods[];
- static const JSFunctionSpec TypedObjectMethods[];
static const JSFunctionSpec Methods[];
};
} // namespace
-const JSFunctionSpec Float32x4Defn::TypeDescriptorMethods[] = {
+// Shared type descriptor methods for all SIMD types.
+static const JSFunctionSpec TypeDescriptorMethods[] = {
JS_SELF_HOSTED_FN("toSource", "DescrToSource", 0, 0),
JS_SELF_HOSTED_FN("array", "ArrayShorthand", 1, 0),
JS_SELF_HOSTED_FN("equivalent", "TypeDescrEquivalent", 1, 0),
JS_FS_END
};
-const JSFunctionSpec Float32x4Defn::TypedObjectMethods[] = {
+// Shared TypedObject methods for all SIMD types.
+static const JSFunctionSpec TypedObjectMethods[] = {
JS_SELF_HOSTED_FN("toSource", "SimdToSource", 0, 0),
JS_FS_END
};
const JSFunctionSpec Float32x4Defn::Methods[] = {
#define SIMD_FLOAT32X4_FUNCTION_ITEM(Name, Func, Operands) \
JS_INLINABLE_FN(#Name, js::simd_float32x4_##Name, Operands, 0, SimdFloat32x4),
FLOAT32X4_FUNCTION_LIST(SIMD_FLOAT32X4_FUNCTION_ITEM)
#undef SIMD_FLOAT32x4_FUNCTION_ITEM
JS_FS_END
};
-const JSFunctionSpec Float64x2Defn::TypeDescriptorMethods[] = {
- JS_SELF_HOSTED_FN("toSource", "DescrToSource", 0, 0),
- JS_SELF_HOSTED_FN("array", "ArrayShorthand", 1, 0),
- JS_SELF_HOSTED_FN("equivalent", "TypeDescrEquivalent", 1, 0),
- JS_FS_END
-};
-
-const JSFunctionSpec Float64x2Defn::TypedObjectMethods[] = {
- JS_SELF_HOSTED_FN("toSource", "SimdToSource", 0, 0),
- JS_FS_END
-};
-
const JSFunctionSpec Float64x2Defn::Methods[] = {
#define SIMD_FLOAT64X2_FUNCTION_ITEM(Name, Func, Operands) \
JS_FN(#Name, js::simd_float64x2_##Name, Operands, 0),
FLOAT64X2_FUNCTION_LIST(SIMD_FLOAT64X2_FUNCTION_ITEM)
#undef SIMD_FLOAT64X2_FUNCTION_ITEM
JS_FS_END
};
-const JSFunctionSpec Int8x16Defn::TypeDescriptorMethods[] = {
- JS_SELF_HOSTED_FN("toSource", "DescrToSource", 0, 0),
- JS_SELF_HOSTED_FN("array", "ArrayShorthand", 1, 0),
- JS_SELF_HOSTED_FN("equivalent", "TypeDescrEquivalent", 1, 0),
- JS_FS_END,
-};
-
-const JSFunctionSpec Int8x16Defn::TypedObjectMethods[] = {
- JS_SELF_HOSTED_FN("toSource", "SimdToSource", 0, 0),
- JS_FS_END
-};
-
const JSFunctionSpec Int8x16Defn::Methods[] = {
#define SIMD_INT8X16_FUNCTION_ITEM(Name, Func, Operands) \
JS_FN(#Name, js::simd_int8x16_##Name, Operands, 0),
INT8X16_FUNCTION_LIST(SIMD_INT8X16_FUNCTION_ITEM)
#undef SIMD_INT8X16_FUNCTION_ITEM
JS_FS_END
};
-const JSFunctionSpec Int16x8Defn::TypeDescriptorMethods[] = {
- JS_SELF_HOSTED_FN("toSource", "DescrToSource", 0, 0),
- JS_SELF_HOSTED_FN("array", "ArrayShorthand", 1, 0),
- JS_SELF_HOSTED_FN("equivalent", "TypeDescrEquivalent", 1, 0),
- JS_FS_END,
-};
-
-const JSFunctionSpec Int16x8Defn::TypedObjectMethods[] = {
- JS_SELF_HOSTED_FN("toSource", "SimdToSource", 0, 0),
- JS_FS_END
-};
-
const JSFunctionSpec Int16x8Defn::Methods[] = {
#define SIMD_INT16X8_FUNCTION_ITEM(Name, Func, Operands) \
JS_FN(#Name, js::simd_int16x8_##Name, Operands, 0),
INT16X8_FUNCTION_LIST(SIMD_INT16X8_FUNCTION_ITEM)
#undef SIMD_INT16X8_FUNCTION_ITEM
JS_FS_END
};
-const JSFunctionSpec Int32x4Defn::TypeDescriptorMethods[] = {
- JS_SELF_HOSTED_FN("toSource", "DescrToSource", 0, 0),
- JS_SELF_HOSTED_FN("array", "ArrayShorthand", 1, 0),
- JS_SELF_HOSTED_FN("equivalent", "TypeDescrEquivalent", 1, 0),
- JS_FS_END,
-};
-
-const JSFunctionSpec Int32x4Defn::TypedObjectMethods[] = {
- JS_SELF_HOSTED_FN("toSource", "SimdToSource", 0, 0),
- JS_FS_END
-};
-
const JSFunctionSpec Int32x4Defn::Methods[] = {
#define SIMD_INT32X4_FUNCTION_ITEM(Name, Func, Operands) \
JS_INLINABLE_FN(#Name, js::simd_int32x4_##Name, Operands, 0, SimdInt32x4),
INT32X4_FUNCTION_LIST(SIMD_INT32X4_FUNCTION_ITEM)
#undef SIMD_INT32X4_FUNCTION_ITEM
JS_FS_END
};
-const JSFunctionSpec Bool8x16Defn::TypeDescriptorMethods[] = {
- JS_SELF_HOSTED_FN("toSource", "DescrToSource", 0, 0),
- JS_SELF_HOSTED_FN("array", "ArrayShorthand", 1, 0),
- JS_SELF_HOSTED_FN("equivalent", "TypeDescrEquivalent", 1, 0),
- JS_FS_END,
-};
-
-const JSFunctionSpec Bool8x16Defn::TypedObjectMethods[] = {
- JS_SELF_HOSTED_FN("toSource", "SimdToSource", 0, 0),
- JS_FS_END
-};
-
const JSFunctionSpec Bool8x16Defn::Methods[] = {
#define SIMD_BOOL8X16_FUNCTION_ITEM(Name, Func, Operands) \
JS_FN(#Name, js::simd_bool8x16_##Name, Operands, 0),
BOOL8X16_FUNCTION_LIST(SIMD_BOOL8X16_FUNCTION_ITEM)
#undef SIMD_BOOL8X16_FUNCTION_ITEM
JS_FS_END
};
-const JSFunctionSpec Bool16x8Defn::TypeDescriptorMethods[] = {
- JS_SELF_HOSTED_FN("toSource", "DescrToSource", 0, 0),
- JS_SELF_HOSTED_FN("array", "ArrayShorthand", 1, 0),
- JS_SELF_HOSTED_FN("equivalent", "TypeDescrEquivalent", 1, 0),
- JS_FS_END,
-};
-
-const JSFunctionSpec Bool16x8Defn::TypedObjectMethods[] = {
- JS_SELF_HOSTED_FN("toSource", "SimdToSource", 0, 0),
- JS_FS_END
-};
-
const JSFunctionSpec Bool16x8Defn::Methods[] = {
#define SIMD_BOOL16X8_FUNCTION_ITEM(Name, Func, Operands) \
JS_FN(#Name, js::simd_bool16x8_##Name, Operands, 0),
BOOL16X8_FUNCTION_LIST(SIMD_BOOL16X8_FUNCTION_ITEM)
#undef SIMD_BOOL16X8_FUNCTION_ITEM
JS_FS_END
};
-const JSFunctionSpec Bool32x4Defn::TypeDescriptorMethods[] = {
- JS_SELF_HOSTED_FN("toSource", "DescrToSource", 0, 0),
- JS_SELF_HOSTED_FN("array", "ArrayShorthand", 1, 0),
- JS_SELF_HOSTED_FN("equivalent", "TypeDescrEquivalent", 1, 0),
- JS_FS_END,
-};
-
-const JSFunctionSpec Bool32x4Defn::TypedObjectMethods[] = {
- JS_SELF_HOSTED_FN("toSource", "SimdToSource", 0, 0),
- JS_FS_END
-};
-
const JSFunctionSpec Bool32x4Defn::Methods[] = {
#define SIMD_BOOL32X4_FUNCTION_ITEM(Name, Func, Operands) \
JS_FN(#Name, js::simd_bool32x4_##Name, Operands, 0),
BOOL32X4_FUNCTION_LIST(SIMD_BOOL32X4_FUNCTION_ITEM)
#undef SIMD_BOOL32X4_FUNCTION_ITEM
JS_FS_END
};
-const JSFunctionSpec Bool64x2Defn::TypeDescriptorMethods[] = {
- JS_SELF_HOSTED_FN("toSource", "DescrToSource", 0, 0),
- JS_SELF_HOSTED_FN("array", "ArrayShorthand", 1, 0),
- JS_SELF_HOSTED_FN("equivalent", "TypeDescrEquivalent", 1, 0),
- JS_FS_END,
-};
-
-const JSFunctionSpec Bool64x2Defn::TypedObjectMethods[] = {
- JS_SELF_HOSTED_FN("toSource", "SimdToSource", 0, 0),
- JS_FS_END
-};
-
const JSFunctionSpec Bool64x2Defn::Methods[] = {
#define SIMD_BOOL64X2_FUNCTION_ITEM(Name, Func, Operands) \
JS_FN(#Name, js::simd_bool64x2_##Name, Operands, 0),
BOOL64X2_FUNCTION_LIST(SIMD_BOOL64X2_FUNCTION_ITEM)
#undef SIMD_BOOL64x2_FUNCTION_ITEM
JS_FS_END
};
@@ -426,21 +314,21 @@ CreateAndBindSimdClass(JSContext* cx, Ha
return nullptr;
Rooted<TypedProto*> proto(cx);
proto = NewObjectWithGivenProto<TypedProto>(cx, objProto, SingletonObject);
if (!proto)
return nullptr;
typeDescr->initReservedSlot(JS_DESCR_SLOT_TYPROTO, ObjectValue(*proto));
// Link constructor to prototype and install properties.
- if (!JS_DefineFunctions(cx, typeDescr, T::TypeDescriptorMethods))
+ if (!JS_DefineFunctions(cx, typeDescr, TypeDescriptorMethods))
return nullptr;
if (!LinkConstructorAndPrototype(cx, typeDescr, proto) ||
- !JS_DefineFunctions(cx, proto, T::TypedObjectMethods))
+ !JS_DefineFunctions(cx, proto, TypedObjectMethods))
{
return nullptr;
}
// Bind type descriptor to the global SIMD object
RootedValue typeValue(cx, ObjectValue(*typeDescr));
if (!JS_DefineFunctions(cx, typeDescr, T::Methods) ||
!DefineProperty(cx, globalSimdObject, stringRepr, typeValue, nullptr, nullptr,