зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1233111 - Share method lists for SIMD types. r=bbouvier
The lists TypeDescriptorMethods and TypedObjectMethods are identical for all SIMD types, so save a bit of memory and source code by sharing a single list. --HG-- extra : rebase_source : 01f65e7eac8c8c99fb6c869206d75d2e5875002b
This commit is contained in:
Родитель
8d6b23cb6b
Коммит
02e0bb6c58
|
@ -151,76 +151,60 @@ namespace {
|
|||
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
|
||||
};
|
||||
|
@ -233,18 +217,6 @@ const JSFunctionSpec Float32x4Defn::Methods[] = {
|
|||
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),
|
||||
|
@ -253,18 +225,6 @@ const JSFunctionSpec Float64x2Defn::Methods[] = {
|
|||
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),
|
||||
|
@ -273,18 +233,6 @@ const JSFunctionSpec Int8x16Defn::Methods[] = {
|
|||
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),
|
||||
|
@ -293,18 +241,6 @@ const JSFunctionSpec Int16x8Defn::Methods[] = {
|
|||
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),
|
||||
|
@ -313,18 +249,6 @@ const JSFunctionSpec Int32x4Defn::Methods[] = {
|
|||
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),
|
||||
|
@ -333,18 +257,6 @@ const JSFunctionSpec Bool8x16Defn::Methods[] = {
|
|||
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),
|
||||
|
@ -353,18 +265,6 @@ const JSFunctionSpec Bool16x8Defn::Methods[] = {
|
|||
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),
|
||||
|
@ -373,18 +273,6 @@ const JSFunctionSpec Bool32x4Defn::Methods[] = {
|
|||
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),
|
||||
|
@ -431,11 +319,11 @@ CreateAndBindSimdClass(JSContext* cx, Handle<GlobalObject*> global, HandleObject
|
|||
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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче