зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changesets 178c7164a3cd and 9a7ee9cb2247 (bug 1031203) for bustage.
CLOSED TREE --HG-- extra : amend_source : 89f9ffb338e7305ae3c3c7f100744570aec95d06
This commit is contained in:
Родитель
60518417a7
Коммит
c04595cbcf
|
@ -462,7 +462,7 @@ struct JSClass {
|
|||
// the beginning of every global object's slots for use by the
|
||||
// application.
|
||||
#define JSCLASS_GLOBAL_APPLICATION_SLOTS 4
|
||||
#define JSCLASS_GLOBAL_SLOT_COUNT (JSCLASS_GLOBAL_APPLICATION_SLOTS + JSProto_LIMIT * 3 + 31)
|
||||
#define JSCLASS_GLOBAL_SLOT_COUNT (JSCLASS_GLOBAL_APPLICATION_SLOTS + JSProto_LIMIT * 3 + 30)
|
||||
#define JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(n) \
|
||||
(JSCLASS_IS_GLOBAL | JSCLASS_HAS_RESERVED_SLOTS(JSCLASS_GLOBAL_SLOT_COUNT + (n)))
|
||||
#define JSCLASS_GLOBAL_FLAGS \
|
||||
|
|
|
@ -31,7 +31,6 @@ using mozilla::FloorLog2;
|
|||
|
||||
namespace js {
|
||||
extern const JSFunctionSpec Float32x4Methods[];
|
||||
extern const JSFunctionSpec Float64x2Methods[];
|
||||
extern const JSFunctionSpec Int32x4Methods[];
|
||||
}
|
||||
|
||||
|
@ -66,7 +65,6 @@ js::IsVectorObject(HandleValue v)
|
|||
|
||||
template bool js::IsVectorObject<Int32x4>(HandleValue v);
|
||||
template bool js::IsVectorObject<Float32x4>(HandleValue v);
|
||||
template bool js::IsVectorObject<Float64x2>(HandleValue v);
|
||||
|
||||
template<typename V>
|
||||
bool
|
||||
|
@ -126,9 +124,6 @@ static bool type##Lane##lane(JSContext *cx, unsigned argc, Value *vp) { \
|
|||
FOUR_LANES_ACCESSOR(Int32x4);
|
||||
FOUR_LANES_ACCESSOR(Float32x4);
|
||||
#undef FOUR_LANES_ACCESSOR
|
||||
|
||||
LANE_ACCESSOR(Float64x2, 0);
|
||||
LANE_ACCESSOR(Float64x2, 1);
|
||||
#undef LANE_ACCESSOR
|
||||
|
||||
template<typename SimdType>
|
||||
|
@ -173,7 +168,6 @@ static bool type##SignMask(JSContext *cx, unsigned argc, Value *vp) { \
|
|||
return SignMask<type>(cx, argc, vp); \
|
||||
}
|
||||
SIGN_MASK(Float32x4);
|
||||
SIGN_MASK(Float64x2);
|
||||
SIGN_MASK(Int32x4);
|
||||
#undef SIGN_MASK
|
||||
|
||||
|
@ -207,13 +201,6 @@ class Float32x4Defn {
|
|||
static const JSPropertySpec TypedObjectProperties[];
|
||||
static const JSFunctionSpec TypedObjectMethods[];
|
||||
};
|
||||
class Float64x2Defn {
|
||||
public:
|
||||
static const SimdTypeDescr::Type type = SimdTypeDescr::TYPE_FLOAT64;
|
||||
static const JSFunctionSpec TypeDescriptorMethods[];
|
||||
static const JSPropertySpec TypedObjectProperties[];
|
||||
static const JSFunctionSpec TypedObjectMethods[];
|
||||
};
|
||||
} // namespace js
|
||||
|
||||
const JSFunctionSpec js::Float32x4Defn::TypeDescriptorMethods[] = {
|
||||
|
@ -237,25 +224,6 @@ const JSFunctionSpec js::Float32x4Defn::TypedObjectMethods[] = {
|
|||
JS_FS_END
|
||||
};
|
||||
|
||||
const JSFunctionSpec js::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 JSPropertySpec js::Float64x2Defn::TypedObjectProperties[] = {
|
||||
JS_PSG("x", Float64x2Lane0, JSPROP_PERMANENT),
|
||||
JS_PSG("y", Float64x2Lane1, JSPROP_PERMANENT),
|
||||
JS_PSG("signMask", Float64x2SignMask, JSPROP_PERMANENT),
|
||||
JS_PS_END
|
||||
};
|
||||
|
||||
const JSFunctionSpec js::Float64x2Defn::TypedObjectMethods[] = {
|
||||
JS_SELF_HOSTED_FN("toSource", "SimdToSource", 0, 0),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
const JSFunctionSpec js::Int32x4Defn::TypeDescriptorMethods[] = {
|
||||
JS_SELF_HOSTED_FN("toSource", "DescrToSource", 0, 0),
|
||||
JS_SELF_HOSTED_FN("array", "ArrayShorthand", 1, 0),
|
||||
|
@ -300,7 +268,6 @@ CreateSimdClass(JSContext *cx, Handle<GlobalObject*> global, HandlePropertyName
|
|||
typeDescr->initReservedSlot(JS_DESCR_SLOT_SIZE, Int32Value(SimdTypeDescr::size(type)));
|
||||
typeDescr->initReservedSlot(JS_DESCR_SLOT_OPAQUE, BooleanValue(false));
|
||||
typeDescr->initReservedSlot(JS_DESCR_SLOT_TYPE, Int32Value(T::type));
|
||||
typeDescr->initReservedSlot(JS_DESCR_SLOT_LANES, Int32Value(SimdTypeDescr::lanes(type)));
|
||||
|
||||
if (!CreateUserSizeAndAlignmentProperties(cx, typeDescr))
|
||||
return nullptr;
|
||||
|
@ -331,18 +298,6 @@ CreateSimdClass(JSContext *cx, Handle<GlobalObject*> global, HandlePropertyName
|
|||
return typeDescr;
|
||||
}
|
||||
|
||||
const char*
|
||||
SimdTypeToMinimumLanesNumber(SimdTypeDescr &descr) {
|
||||
switch (descr.type()) {
|
||||
case SimdTypeDescr::TYPE_INT32:
|
||||
case SimdTypeDescr::TYPE_FLOAT32:
|
||||
return "3";
|
||||
case SimdTypeDescr::TYPE_FLOAT64:
|
||||
return "1";
|
||||
}
|
||||
MOZ_CRASH("Unexpected SIMD type description.");
|
||||
}
|
||||
|
||||
bool
|
||||
SimdTypeDescr::call(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
|
@ -381,13 +336,6 @@ SimdTypeDescr::call(JSContext *cx, unsigned argc, Value *vp)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case SimdTypeDescr::TYPE_FLOAT64: {
|
||||
double *mem = reinterpret_cast<double*>(result->typedMem());
|
||||
for (unsigned i = 0; i < 2; i++) {
|
||||
if (!ToNumber(cx, args[i], &mem[i]))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
args.rval().setObject(*result);
|
||||
return true;
|
||||
|
@ -438,23 +386,6 @@ SIMDObject::initClass(JSContext *cx, Handle<GlobalObject *> global)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
// float64x2
|
||||
RootedObject float64x2Object(cx);
|
||||
float64x2Object = CreateSimdClass<Float64x2Defn>(cx, global,
|
||||
cx->names().float64x2);
|
||||
if (!float64x2Object)
|
||||
return nullptr;
|
||||
|
||||
// Define float64x2 functions and install as a property of the SIMD object.
|
||||
RootedValue float64x2Value(cx, ObjectValue(*float64x2Object));
|
||||
if (!JS_DefineFunctions(cx, float64x2Object, Float64x2Methods) ||
|
||||
!JSObject::defineProperty(cx, SIMD, cx->names().float64x2,
|
||||
float64x2Value, nullptr, nullptr,
|
||||
JSPROP_READONLY | JSPROP_PERMANENT))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// int32x4
|
||||
RootedObject int32x4Object(cx);
|
||||
int32x4Object = CreateSimdClass<Int32x4Defn>(cx, global,
|
||||
|
@ -480,7 +411,6 @@ SIMDObject::initClass(JSContext *cx, Handle<GlobalObject *> global)
|
|||
|
||||
global->setConstructor(JSProto_SIMD, SIMDValue);
|
||||
global->setFloat32x4TypeDescr(*float32x4Object);
|
||||
global->setFloat64x2TypeDescr(*float64x2Object);
|
||||
global->setInt32x4TypeDescr(*int32x4Object);
|
||||
return SIMD;
|
||||
}
|
||||
|
@ -511,7 +441,6 @@ js::CreateSimd(JSContext *cx, typename V::Elem *data)
|
|||
}
|
||||
|
||||
template JSObject *js::CreateSimd<Float32x4>(JSContext *cx, Float32x4::Elem *data);
|
||||
template JSObject *js::CreateSimd<Float64x2>(JSContext *cx, Float64x2::Elem *data);
|
||||
template JSObject *js::CreateSimd<Int32x4>(JSContext *cx, Int32x4::Elem *data);
|
||||
|
||||
namespace js {
|
||||
|
@ -838,10 +767,8 @@ CompareFunc(JSContext *cx, unsigned argc, Value *vp)
|
|||
int32_t result[Int32x4::lanes];
|
||||
InElem *left = TypedObjectMemory<InElem *>(args[0]);
|
||||
InElem *right = TypedObjectMemory<InElem *>(args[1]);
|
||||
for (unsigned i = 0; i < Int32x4::lanes; i++) {
|
||||
unsigned j = (i * In::lanes) / Int32x4::lanes;
|
||||
result[i] = Op<InElem>::apply(left[j], right[j]);
|
||||
}
|
||||
for (unsigned i = 0; i < Int32x4::lanes; i++)
|
||||
result[i] = Op<InElem>::apply(left[i], right[i]);
|
||||
|
||||
return StoreResult<Int32x4>(cx, args, result);
|
||||
}
|
||||
|
@ -860,8 +787,7 @@ FuncConvert(JSContext *cx, unsigned argc, Value *vp)
|
|||
Elem *val = TypedObjectMemory<Elem *>(args[0]);
|
||||
RetElem result[Vret::lanes];
|
||||
for (unsigned i = 0; i < Vret::lanes; i++)
|
||||
result[i] = i < V::lanes ? ConvertScalar<RetElem>(val[i]) : 0;
|
||||
|
||||
result[i] = ConvertScalar<RetElem>(val[i]);
|
||||
return StoreResult<Vret>(cx, args, result);
|
||||
}
|
||||
|
||||
|
@ -932,29 +858,27 @@ Int32x4Bool(JSContext *cx, unsigned argc, Value *vp)
|
|||
return StoreResult<Int32x4>(cx, args, result);
|
||||
}
|
||||
|
||||
template<typename In>
|
||||
static bool
|
||||
Clamp(JSContext *cx, unsigned argc, Value *vp)
|
||||
Float32x4Clamp(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
typedef typename In::Elem InElem;
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
if (args.length() != 3 || !IsVectorObject<In>(args[0]) ||
|
||||
!IsVectorObject<In>(args[1]) || !IsVectorObject<In>(args[2]))
|
||||
if (args.length() != 3 || !IsVectorObject<Float32x4>(args[0]) ||
|
||||
!IsVectorObject<Float32x4>(args[1]) || !IsVectorObject<Float32x4>(args[2]))
|
||||
{
|
||||
return ErrorBadArgs(cx);
|
||||
}
|
||||
|
||||
InElem *val = TypedObjectMemory<InElem *>(args[0]);
|
||||
InElem *lowerLimit = TypedObjectMemory<InElem *>(args[1]);
|
||||
InElem *upperLimit = TypedObjectMemory<InElem *>(args[2]);
|
||||
float *val = TypedObjectMemory<float *>(args[0]);
|
||||
float *lowerLimit = TypedObjectMemory<float *>(args[1]);
|
||||
float *upperLimit = TypedObjectMemory<float *>(args[2]);
|
||||
|
||||
InElem result[In::lanes];
|
||||
for (unsigned i = 0; i < In::lanes; i++) {
|
||||
float result[Float32x4::lanes];
|
||||
for (unsigned i = 0; i < Float32x4::lanes; i++) {
|
||||
result[i] = val[i] < lowerLimit[i] ? lowerLimit[i] : val[i];
|
||||
result[i] = result[i] > upperLimit[i] ? upperLimit[i] : result[i];
|
||||
}
|
||||
|
||||
return StoreResult<In>(cx, args, result);
|
||||
return StoreResult<Float32x4>(cx, args, result);
|
||||
}
|
||||
|
||||
template<typename V>
|
||||
|
@ -1063,7 +987,8 @@ Load(JSContext *cx, unsigned argc, Value *vp)
|
|||
return false;
|
||||
|
||||
Elem *dest = reinterpret_cast<Elem*>(result->typedMem());
|
||||
memcpy(dest, typedArrayData, sizeof(Elem) * NumElem);
|
||||
for (unsigned i = 0; i < NumElem; i++)
|
||||
dest[i] = typedArrayData[i];
|
||||
|
||||
args.rval().setObject(*result);
|
||||
return true;
|
||||
|
@ -1087,7 +1012,8 @@ Store(JSContext *cx, unsigned argc, Value *vp)
|
|||
return ErrorBadArgs(cx);
|
||||
|
||||
Elem *src = TypedObjectMemory<Elem*>(args[2]);
|
||||
memcpy(typedArrayData, src, sizeof(Elem) * NumElem);
|
||||
for (unsigned i = 0; i < NumElem; i++)
|
||||
typedArrayData[i] = src[i];
|
||||
|
||||
args.rval().setObject(args[2].toObject());
|
||||
return true;
|
||||
|
@ -1100,16 +1026,7 @@ js::simd_float32x4_##Name(JSContext *cx, unsigned argc, Value *vp) \
|
|||
return Func(cx, argc, vp); \
|
||||
}
|
||||
FLOAT32X4_FUNCTION_LIST(DEFINE_SIMD_FLOAT32X4_FUNCTION)
|
||||
#undef DEFINE_SIMD_FLOAT32X4_FUNCTION
|
||||
|
||||
#define DEFINE_SIMD_FLOAT64X2_FUNCTION(Name, Func, Operands, Flags) \
|
||||
bool \
|
||||
js::simd_float64x2_##Name(JSContext *cx, unsigned argc, Value *vp) \
|
||||
{ \
|
||||
return Func(cx, argc, vp); \
|
||||
}
|
||||
FLOAT64X2_FUNCTION_LIST(DEFINE_SIMD_FLOAT64X2_FUNCTION)
|
||||
#undef DEFINE_SIMD_FLOAT64X2_FUNCTION
|
||||
#undef DEFINE_SIMD_FLOAT32x4_FUNCTION
|
||||
|
||||
#define DEFINE_SIMD_INT32X4_FUNCTION(Name, Func, Operands, Flags) \
|
||||
bool \
|
||||
|
@ -1128,14 +1045,6 @@ const JSFunctionSpec js::Float32x4Methods[] = {
|
|||
JS_FS_END
|
||||
};
|
||||
|
||||
const JSFunctionSpec js::Float64x2Methods[] = {
|
||||
#define SIMD_FLOAT64X2_FUNCTION_ITEM(Name, Func, Operands, Flags) \
|
||||
JS_FN(#Name, js::simd_float64x2_##Name, Operands, Flags),
|
||||
FLOAT64X2_FUNCTION_LIST(SIMD_FLOAT64X2_FUNCTION_ITEM)
|
||||
#undef SIMD_FLOAT64X2_FUNCTION_ITEM
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
const JSFunctionSpec js::Int32x4Methods[] = {
|
||||
#define SIMD_INT32X4_FUNCTION_ITEM(Name, Func, Operands, Flags) \
|
||||
JS_FN(#Name, js::simd_int32x4_##Name, Operands, Flags),
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
|
||||
#define FLOAT32X4_UNARY_FUNCTION_LIST(V) \
|
||||
V(abs, (UnaryFunc<Float32x4, Abs, Float32x4>), 1, 0) \
|
||||
V(fromFloat64x2, (FuncConvert<Float64x2, Float32x4> ), 1, 0) \
|
||||
V(fromFloat64x2Bits, (FuncConvertBits<Float64x2, Float32x4>), 1, 0) \
|
||||
V(fromInt32x4, (FuncConvert<Int32x4, Float32x4> ), 1, 0) \
|
||||
V(fromInt32x4Bits, (FuncConvertBits<Int32x4, Float32x4>), 1, 0) \
|
||||
V(neg, (UnaryFunc<Float32x4, Neg, Float32x4>), 1, 0) \
|
||||
|
@ -66,7 +64,7 @@
|
|||
|
||||
#define FLOAT32X4_TERNARY_FUNCTION_LIST(V) \
|
||||
V(bitselect, BitSelect<Float32x4>, 3, 0) \
|
||||
V(clamp, Clamp<Float32x4>, 3, 0) \
|
||||
V(clamp, Float32x4Clamp, 3, 0) \
|
||||
V(select, Select<Float32x4>, 3, 0)
|
||||
|
||||
#define FLOAT32X4_SHUFFLE_FUNCTION_LIST(V) \
|
||||
|
@ -79,60 +77,9 @@
|
|||
FLOAT32X4_TERNARY_FUNCTION_LIST(V) \
|
||||
FLOAT32X4_SHUFFLE_FUNCTION_LIST(V)
|
||||
|
||||
#define FLOAT64X2_UNARY_FUNCTION_LIST(V) \
|
||||
V(abs, (UnaryFunc<Float64x2, Abs, Float64x2>), 1, 0) \
|
||||
V(fromFloat32x4, (FuncConvert<Float32x4, Float64x2> ), 1, 0) \
|
||||
V(fromFloat32x4Bits, (FuncConvertBits<Float32x4, Float64x2>), 1, 0) \
|
||||
V(fromInt32x4, (FuncConvert<Int32x4, Float64x2> ), 1, 0) \
|
||||
V(fromInt32x4Bits, (FuncConvertBits<Int32x4, Float64x2>), 1, 0) \
|
||||
V(neg, (UnaryFunc<Float64x2, Neg, Float64x2>), 1, 0) \
|
||||
V(reciprocal, (UnaryFunc<Float64x2, Rec, Float64x2>), 1, 0) \
|
||||
V(reciprocalSqrt, (UnaryFunc<Float64x2, RecSqrt, Float64x2>), 1, 0) \
|
||||
V(splat, (FuncSplat<Float64x2>), 1, 0) \
|
||||
V(sqrt, (UnaryFunc<Float64x2, Sqrt, Float64x2>), 1, 0)
|
||||
|
||||
#define FLOAT64X2_BINARY_FUNCTION_LIST(V) \
|
||||
V(add, (BinaryFunc<Float64x2, Add, Float64x2>), 2, 0) \
|
||||
V(div, (BinaryFunc<Float64x2, Div, Float64x2>), 2, 0) \
|
||||
V(equal, (CompareFunc<Float64x2, Equal>), 2, 0) \
|
||||
V(greaterThan, (CompareFunc<Float64x2, GreaterThan>), 2, 0) \
|
||||
V(greaterThanOrEqual, (CompareFunc<Float64x2, GreaterThanOrEqual>), 2, 0) \
|
||||
V(lessThan, (CompareFunc<Float64x2, LessThan>), 2, 0) \
|
||||
V(lessThanOrEqual, (CompareFunc<Float64x2, LessThanOrEqual>), 2, 0) \
|
||||
V(load, (Load<Float64x2, 2>), 2, 0) \
|
||||
V(loadX, (Load<Float64x2, 1>), 2, 0) \
|
||||
V(max, (BinaryFunc<Float64x2, Maximum, Float64x2>), 2, 0) \
|
||||
V(maxNum, (BinaryFunc<Float64x2, MaxNum, Float64x2>), 2, 0) \
|
||||
V(min, (BinaryFunc<Float64x2, Minimum, Float64x2>), 2, 0) \
|
||||
V(minNum, (BinaryFunc<Float64x2, MinNum, Float64x2>), 2, 0) \
|
||||
V(mul, (BinaryFunc<Float64x2, Mul, Float64x2>), 2, 0) \
|
||||
V(notEqual, (CompareFunc<Float64x2, NotEqual>), 2, 0) \
|
||||
V(store, (Store<Float64x2, 2>), 3, 0) \
|
||||
V(storeX, (Store<Float64x2, 1>), 3, 0) \
|
||||
V(sub, (BinaryFunc<Float64x2, Sub, Float64x2>), 2, 0) \
|
||||
V(withX, (FuncWith<Float64x2, WithX>), 2, 0) \
|
||||
V(withY, (FuncWith<Float64x2, WithY>), 2, 0)
|
||||
|
||||
#define FLOAT64X2_TERNARY_FUNCTION_LIST(V) \
|
||||
V(bitselect, BitSelect<Float64x2>, 3, 0) \
|
||||
V(clamp, Clamp<Float64x2>, 3, 0) \
|
||||
V(select, Select<Float64x2>, 3, 0)
|
||||
|
||||
#define FLOAT64X2_SHUFFLE_FUNCTION_LIST(V) \
|
||||
V(swizzle, Swizzle<Float64x2>, 2, 0) \
|
||||
V(shuffle, Shuffle<Float64x2>, 3, 0)
|
||||
|
||||
#define FLOAT64X2_FUNCTION_LIST(V) \
|
||||
FLOAT64X2_UNARY_FUNCTION_LIST(V) \
|
||||
FLOAT64X2_BINARY_FUNCTION_LIST(V) \
|
||||
FLOAT64X2_TERNARY_FUNCTION_LIST(V) \
|
||||
FLOAT64X2_SHUFFLE_FUNCTION_LIST(V)
|
||||
|
||||
#define INT32X4_UNARY_FUNCTION_LIST(V) \
|
||||
V(fromFloat32x4, (FuncConvert<Float32x4, Int32x4>), 1, 0) \
|
||||
V(fromFloat32x4Bits, (FuncConvertBits<Float32x4, Int32x4>), 1, 0) \
|
||||
V(fromFloat64x2, (FuncConvert<Float64x2, Int32x4>), 1, 0) \
|
||||
V(fromFloat64x2Bits, (FuncConvertBits<Float64x2, Int32x4>), 1, 0) \
|
||||
V(neg, (UnaryFunc<Int32x4, Neg, Int32x4>), 1, 0) \
|
||||
V(not, (UnaryFunc<Int32x4, Not, Int32x4>), 1, 0) \
|
||||
V(splat, (FuncSplat<Int32x4>), 0, 0)
|
||||
|
@ -265,26 +212,6 @@ struct Float32x4 {
|
|||
}
|
||||
};
|
||||
|
||||
struct Float64x2 {
|
||||
typedef double Elem;
|
||||
static const unsigned lanes = 2;
|
||||
static const SimdTypeDescr::Type type = SimdTypeDescr::TYPE_FLOAT64;
|
||||
|
||||
static TypeDescr &GetTypeDescr(GlobalObject &global) {
|
||||
return global.float64x2TypeDescr().as<TypeDescr>();
|
||||
}
|
||||
static Elem toType(Elem a) {
|
||||
return a;
|
||||
}
|
||||
static bool toType(JSContext *cx, JS::HandleValue v, Elem *out) {
|
||||
*out = v.toNumber();
|
||||
return true;
|
||||
}
|
||||
static void setReturn(CallArgs &args, Elem value) {
|
||||
args.rval().setDouble(JS::CanonicalizeNaN(value));
|
||||
}
|
||||
};
|
||||
|
||||
struct Int32x4 {
|
||||
typedef int32_t Elem;
|
||||
static const unsigned lanes = 4;
|
||||
|
@ -319,12 +246,6 @@ simd_float32x4_##Name(JSContext *cx, unsigned argc, Value *vp);
|
|||
FLOAT32X4_FUNCTION_LIST(DECLARE_SIMD_FLOAT32X4_FUNCTION)
|
||||
#undef DECLARE_SIMD_FLOAT32X4_FUNCTION
|
||||
|
||||
#define DECLARE_SIMD_FLOAT64X2_FUNCTION(Name, Func, Operands, Flags) \
|
||||
extern bool \
|
||||
simd_float64x2_##Name(JSContext *cx, unsigned argc, Value *vp);
|
||||
FLOAT64X2_FUNCTION_LIST(DECLARE_SIMD_FLOAT64X2_FUNCTION)
|
||||
#undef DECLARE_SIMD_FLOAT64X2_FUNCTION
|
||||
|
||||
#define DECLARE_SIMD_INT32x4_FUNCTION(Name, Func, Operands, Flags) \
|
||||
extern bool \
|
||||
simd_int32x4_##Name(JSContext *cx, unsigned argc, Value *vp);
|
||||
|
|
|
@ -406,25 +406,18 @@ js::ReferenceTypeDescr::call(JSContext *cx, unsigned argc, Value *vp)
|
|||
}
|
||||
|
||||
/***************************************************************************
|
||||
* SIMD type objects
|
||||
* X4 type objects
|
||||
*
|
||||
* Note: these are partially defined in SIMD.cpp
|
||||
*/
|
||||
|
||||
static const int32_t SimdSizes[] = {
|
||||
#define SIMD_SIZE(_kind, _type, _name, _lanes) \
|
||||
sizeof(_type) * _lanes,
|
||||
#define SIMD_SIZE(_kind, _type, _name) \
|
||||
sizeof(_type) * 4,
|
||||
JS_FOR_EACH_SIMD_TYPE_REPR(SIMD_SIZE) 0
|
||||
#undef SIMD_SIZE
|
||||
};
|
||||
|
||||
static int32_t SimdLanes[] = {
|
||||
#define SIMD_LANE(_kind, _type, _name, _lanes) \
|
||||
_lanes,
|
||||
JS_FOR_EACH_SIMD_TYPE_REPR(SIMD_LANE) 0
|
||||
#undef SIMD_LANE
|
||||
};
|
||||
|
||||
int32_t
|
||||
SimdTypeDescr::size(Type t)
|
||||
{
|
||||
|
@ -437,12 +430,6 @@ SimdTypeDescr::alignment(Type t)
|
|||
return SimdSizes[t];
|
||||
}
|
||||
|
||||
int32_t
|
||||
SimdTypeDescr::lanes(Type t)
|
||||
{
|
||||
return SimdLanes[t];
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* ArrayMetaTypeDescr class
|
||||
*/
|
||||
|
@ -2707,16 +2694,6 @@ js::GetFloat32x4TypeDescr(JSContext *cx, unsigned argc, Value *vp)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
js::GetFloat64x2TypeDescr(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
Rooted<GlobalObject*> global(cx, cx->global());
|
||||
MOZ_ASSERT(global);
|
||||
args.rval().setObject(global->float64x2TypeDescr());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
js::GetInt32x4TypeDescr(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
|
|
|
@ -325,7 +325,7 @@ class ComplexTypeDescr : public TypeDescr
|
|||
};
|
||||
|
||||
/*
|
||||
* Type descriptors `float32x4`, `int32x4` and `float64x2`
|
||||
* Type descriptors `float32x4` and `int32x4`
|
||||
*/
|
||||
class SimdTypeDescr : public ComplexTypeDescr
|
||||
{
|
||||
|
@ -333,7 +333,6 @@ class SimdTypeDescr : public ComplexTypeDescr
|
|||
enum Type {
|
||||
TYPE_INT32 = JS_SIMDTYPEREPR_INT32,
|
||||
TYPE_FLOAT32 = JS_SIMDTYPEREPR_FLOAT32,
|
||||
TYPE_FLOAT64 = JS_SIMDTYPEREPR_FLOAT64
|
||||
};
|
||||
|
||||
static const type::Kind Kind = type::Simd;
|
||||
|
@ -341,7 +340,6 @@ class SimdTypeDescr : public ComplexTypeDescr
|
|||
static const Class class_;
|
||||
static int32_t size(Type t);
|
||||
static int32_t alignment(Type t);
|
||||
static int32_t lanes(Type t);
|
||||
|
||||
SimdTypeDescr::Type type() const {
|
||||
return (SimdTypeDescr::Type) getReservedSlot(JS_DESCR_SLOT_TYPE).toInt32();
|
||||
|
@ -352,9 +350,8 @@ class SimdTypeDescr : public ComplexTypeDescr
|
|||
};
|
||||
|
||||
#define JS_FOR_EACH_SIMD_TYPE_REPR(macro_) \
|
||||
macro_(SimdTypeDescr::TYPE_INT32, int32_t, int32, 4) \
|
||||
macro_(SimdTypeDescr::TYPE_FLOAT32, float, float32, 4) \
|
||||
macro_(SimdTypeDescr::TYPE_FLOAT64, double, float64, 2)
|
||||
macro_(SimdTypeDescr::TYPE_INT32, int32_t, int32) \
|
||||
macro_(SimdTypeDescr::TYPE_FLOAT32, float, float32)
|
||||
|
||||
bool IsTypedObjectClass(const Class *clasp); // Defined below
|
||||
bool IsTypedObjectArray(JSObject& obj);
|
||||
|
@ -883,14 +880,6 @@ bool GetTypedObjectModule(JSContext *cx, unsigned argc, Value *vp);
|
|||
*/
|
||||
bool GetFloat32x4TypeDescr(JSContext *cx, unsigned argc, Value *vp);
|
||||
|
||||
/*
|
||||
* Usage: GetFloat64x2TypeDescr()
|
||||
*
|
||||
* Returns the float64x2 type object. SIMD pseudo-module must have
|
||||
* been initialized for this to be safe.
|
||||
*/
|
||||
bool GetFloat64x2TypeDescr(JSContext *cx, unsigned argc, Value *vp);
|
||||
|
||||
/*
|
||||
* Usage: GetInt32x4TypeDescr()
|
||||
*
|
||||
|
|
|
@ -152,11 +152,6 @@ function TypedObjectGetSimd(descr, typedObj, offset) {
|
|||
var w = Load_float32(typedObj, offset + 12);
|
||||
return GetFloat32x4TypeDescr()(x, y, z, w);
|
||||
|
||||
case JS_SIMDTYPEREPR_FLOAT64:
|
||||
var x = Load_float64(typedObj, offset + 0);
|
||||
var y = Load_float64(typedObj, offset + 8);
|
||||
return GetFloat64x2TypeDescr()(x, y);
|
||||
|
||||
case JS_SIMDTYPEREPR_INT32:
|
||||
var x = Load_int32(typedObj, offset + 0);
|
||||
var y = Load_int32(typedObj, offset + 4);
|
||||
|
@ -327,10 +322,6 @@ function TypedObjectSetSimd(descr, typedObj, offset, fromValue) {
|
|||
Store_float32(typedObj, offset + 8, Load_float32(fromValue, 8));
|
||||
Store_float32(typedObj, offset + 12, Load_float32(fromValue, 12));
|
||||
break;
|
||||
case JS_SIMDTYPEREPR_FLOAT64:
|
||||
Store_float64(typedObj, offset + 0, Load_float64(fromValue, 0));
|
||||
Store_float64(typedObj, offset + 8, Load_float64(fromValue, 8));
|
||||
break;
|
||||
case JS_SIMDTYPEREPR_INT32:
|
||||
Store_int32(typedObj, offset + 0, Load_int32(fromValue, 0));
|
||||
Store_int32(typedObj, offset + 4, Load_int32(fromValue, 4));
|
||||
|
@ -466,21 +457,6 @@ function SimdProtoString(type) {
|
|||
return "int32x4";
|
||||
case JS_SIMDTYPEREPR_FLOAT32:
|
||||
return "float32x4";
|
||||
case JS_SIMDTYPEREPR_FLOAT64:
|
||||
return "float64x2";
|
||||
}
|
||||
|
||||
assert(false, "Unhandled type constant");
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function SimdTypeToLength(type) {
|
||||
switch (type) {
|
||||
case JS_SIMDTYPEREPR_INT32:
|
||||
case JS_SIMDTYPEREPR_FLOAT32:
|
||||
return 4;
|
||||
case JS_SIMDTYPEREPR_FLOAT64:
|
||||
return 2;
|
||||
}
|
||||
|
||||
assert(false, "Unhandled type constant");
|
||||
|
@ -497,12 +473,7 @@ function SimdToSource() {
|
|||
ThrowError(JSMSG_INCOMPATIBLE_PROTO, "SIMD", "toSource", typeof this);
|
||||
|
||||
var type = DESCR_TYPE(descr);
|
||||
var protoString = SimdProtoString(type);
|
||||
var length = SimdTypeToLength(type);
|
||||
if (length == 4)
|
||||
return protoString+"("+this.x+", "+this.y+", "+this.z+", "+this.w+")";
|
||||
else if (length == 2)
|
||||
return protoString+"("+this.x+", "+this.y+")";
|
||||
return SimdProtoString(type)+"("+this.x+", "+this.y+", "+this.z+", "+this.w+")";
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -32,9 +32,8 @@
|
|||
#define JS_DESCR_SLOT_ARRAYPROTO 6 // Lazily created prototype for arrays
|
||||
#define JS_DESCR_SLOT_TRACE_LIST 7 // List of references for use in tracing
|
||||
|
||||
// Slots on scalars, references, and SIMD objects
|
||||
// Slots on scalars, references, and x4s
|
||||
#define JS_DESCR_SLOT_TYPE 8 // Type code
|
||||
#define JS_DESCR_SLOT_LANES 9
|
||||
|
||||
// Slots on array descriptors
|
||||
#define JS_DESCR_SLOT_ARRAY_ELEM_TYPE 8
|
||||
|
@ -86,6 +85,5 @@
|
|||
// case.
|
||||
#define JS_SIMDTYPEREPR_INT32 0
|
||||
#define JS_SIMDTYPEREPR_FLOAT32 1
|
||||
#define JS_SIMDTYPEREPR_FLOAT64 2
|
||||
|
||||
#endif
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
*/
|
||||
|
||||
var float32x4 = SIMD.float32x4;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
var int32x4 = SIMD.int32x4;
|
||||
|
||||
var fround = Math.fround;
|
||||
|
@ -16,60 +15,41 @@ function boolToSimdLogical(b) {
|
|||
}
|
||||
|
||||
function testEqualFloat32x4(v, w) {
|
||||
testBinaryCompare(v, w, float32x4.equal, (x, y) => boolToSimdLogical(fround(x) == fround(y)));
|
||||
testBinaryFunc(v, w, float32x4.equal, (x, y) => boolToSimdLogical(fround(x) == fround(y)));
|
||||
}
|
||||
function testNotEqualFloat32x4(v, w) {
|
||||
testBinaryCompare(v, w, float32x4.notEqual, (x, y) => boolToSimdLogical(fround(x) != fround(y)));
|
||||
testBinaryFunc(v, w, float32x4.notEqual, (x, y) => boolToSimdLogical(fround(x) != fround(y)));
|
||||
}
|
||||
function testLessThanFloat32x4(v, w) {
|
||||
testBinaryCompare(v, w, float32x4.lessThan, (x, y) => boolToSimdLogical(fround(x) < fround(y)));
|
||||
testBinaryFunc(v, w, float32x4.lessThan, (x, y) => boolToSimdLogical(fround(x) < fround(y)));
|
||||
}
|
||||
function testLessThanOrEqualFloat32x4(v, w) {
|
||||
testBinaryCompare(v, w, float32x4.lessThanOrEqual, (x, y) => boolToSimdLogical(fround(x) <= fround(y)));
|
||||
testBinaryFunc(v, w, float32x4.lessThanOrEqual, (x, y) => boolToSimdLogical(fround(x) <= fround(y)));
|
||||
}
|
||||
function testGreaterThanFloat32x4(v, w) {
|
||||
testBinaryCompare(v, w, float32x4.greaterThan, (x, y) => boolToSimdLogical(fround(x) > fround(y)));
|
||||
testBinaryFunc(v, w, float32x4.greaterThan, (x, y) => boolToSimdLogical(fround(x) > fround(y)));
|
||||
}
|
||||
function testGreaterThanOrEqualFloat32x4(v, w) {
|
||||
testBinaryCompare(v, w, float32x4.greaterThanOrEqual, (x, y) => boolToSimdLogical(fround(x) >= fround(y)));
|
||||
}
|
||||
|
||||
function testEqualFloat64x2(v, w) {
|
||||
testBinaryCompare(v, w, float64x2.equal, (x, y) => boolToSimdLogical(x == y));
|
||||
}
|
||||
function testNotEqualFloat64x2(v, w) {
|
||||
testBinaryCompare(v, w, float64x2.notEqual, (x, y) => boolToSimdLogical(x != y));
|
||||
}
|
||||
function testLessThanFloat64x2(v, w) {
|
||||
testBinaryCompare(v, w, float64x2.lessThan, (x, y) => boolToSimdLogical(x < y));
|
||||
}
|
||||
function testLessThanOrEqualFloat64x2(v, w) {
|
||||
testBinaryCompare(v, w, float64x2.lessThanOrEqual, (x, y) => boolToSimdLogical(x <= y));
|
||||
}
|
||||
function testGreaterThanFloat64x2(v, w) {
|
||||
testBinaryCompare(v, w, float64x2.greaterThan, (x, y) => boolToSimdLogical(x > y));
|
||||
}
|
||||
function testGreaterThanOrEqualFloat64x2(v, w) {
|
||||
testBinaryCompare(v, w, float64x2.greaterThanOrEqual, (x, y) => boolToSimdLogical(x >= y));
|
||||
testBinaryFunc(v, w, float32x4.greaterThanOrEqual, (x, y) => boolToSimdLogical(fround(x) >= fround(y)));
|
||||
}
|
||||
|
||||
function testEqualInt32x4(v, w) {
|
||||
testBinaryCompare(v, w, int32x4.equal, (x, y) => boolToSimdLogical(x == y));
|
||||
testBinaryFunc(v, w, int32x4.equal, (x, y) => boolToSimdLogical(x == y));
|
||||
}
|
||||
function testNotEqualInt32x4(v, w) {
|
||||
testBinaryCompare(v, w, int32x4.notEqual, (x, y) => boolToSimdLogical(x != y));
|
||||
testBinaryFunc(v, w, int32x4.notEqual, (x, y) => boolToSimdLogical(x != y));
|
||||
}
|
||||
function testLessThanInt32x4(v, w) {
|
||||
testBinaryCompare(v, w, int32x4.lessThan, (x, y) => boolToSimdLogical(x < y));
|
||||
testBinaryFunc(v, w, int32x4.lessThan, (x, y) => boolToSimdLogical(x < y));
|
||||
}
|
||||
function testLessThanOrEqualInt32x4(v, w) {
|
||||
testBinaryCompare(v, w, int32x4.lessThanOrEqual, (x, y) => boolToSimdLogical(x <= y));
|
||||
testBinaryFunc(v, w, int32x4.lessThanOrEqual, (x, y) => boolToSimdLogical(x <= y));
|
||||
}
|
||||
function testGreaterThanInt32x4(v, w) {
|
||||
testBinaryCompare(v, w, int32x4.greaterThan, (x, y) => boolToSimdLogical(x > y));
|
||||
testBinaryFunc(v, w, int32x4.greaterThan, (x, y) => boolToSimdLogical(x > y));
|
||||
}
|
||||
function testGreaterThanOrEqualInt32x4(v, w) {
|
||||
testBinaryCompare(v, w, int32x4.greaterThanOrEqual, (x, y) => boolToSimdLogical(x >= y));
|
||||
testBinaryFunc(v, w, int32x4.greaterThanOrEqual, (x, y) => boolToSimdLogical(x >= y));
|
||||
}
|
||||
|
||||
function test() {
|
||||
|
@ -95,32 +75,6 @@ function test() {
|
|||
}
|
||||
}
|
||||
|
||||
var float64x2val = [
|
||||
float64x2(1, 20),
|
||||
float64x2(10, 2),
|
||||
float64x2(9.999, 2.1234),
|
||||
float64x2(10, 2.1233),
|
||||
float64x2(30.4443, 4),
|
||||
float64x2(30.4444, 4.0001),
|
||||
float64x2(NaN, -Infinity),
|
||||
float64x2(+Infinity, NaN),
|
||||
float64x2(+Infinity, -0),
|
||||
float64x2(-0, -Infinity),
|
||||
float64x2(13.37, 42.42),
|
||||
float64x2(NaN, 0)
|
||||
];
|
||||
|
||||
for (v of float64x2val) {
|
||||
for (w of float64x2val) {
|
||||
testEqualFloat64x2(v, w);
|
||||
testNotEqualFloat64x2(v, w);
|
||||
testLessThanFloat64x2(v, w);
|
||||
testLessThanOrEqualFloat64x2(v, w);
|
||||
testGreaterThanFloat64x2(v, w);
|
||||
testGreaterThanOrEqualFloat64x2(v, w);
|
||||
}
|
||||
}
|
||||
|
||||
var int32x4val = [
|
||||
int32x4(1, 2, 3, 4),
|
||||
int32x4(-1, -2, -3, -4),
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
var BUGNUMBER = 946042;
|
||||
|
||||
var float32x4 = SIMD.float32x4;
|
||||
|
||||
function testMaxFloat32(v, w) {
|
||||
return testBinaryFunc(v, w, float32x4.max, (x, y) => Math.fround(Math.max(x, y)));
|
||||
}
|
||||
function testMinFloat32(v, w) {
|
||||
return testBinaryFunc(v, w, float32x4.min, (x, y) => Math.fround(Math.min(x, y)));
|
||||
}
|
||||
|
||||
function maxNum(x, y) {
|
||||
if (x != x)
|
||||
return y;
|
||||
if (y != y)
|
||||
return x;
|
||||
return Math.max(x, y);
|
||||
}
|
||||
|
||||
function minNum(x, y) {
|
||||
if (x != x)
|
||||
return y;
|
||||
if (y != y)
|
||||
return x;
|
||||
return Math.min(x, y);
|
||||
}
|
||||
|
||||
function testMaxNumFloat32(v, w) {
|
||||
return testBinaryFunc(v, w, float32x4.maxNum, maxNum);
|
||||
}
|
||||
function testMinNumFloat32(v, w) {
|
||||
return testBinaryFunc(v, w, float32x4.minNum, minNum);
|
||||
}
|
||||
|
||||
function test() {
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
for ([v, w] of [[float32x4(1, 20, 30, 4), float32x4(10, 2, 3, 40)],
|
||||
[float32x4(9.999, 2.1234, 30.4443, 4), float32x4(10, 2.1233, 30.4444, 4.0001)],
|
||||
[float32x4(NaN, -Infinity, +Infinity, -0), float32x4(13.37, 42.42, NaN, 0)]])
|
||||
{
|
||||
testMinFloat32(v, w);
|
||||
testMaxFloat32(v, w);
|
||||
testMinNumFloat32(v, w);
|
||||
testMaxNumFloat32(v, w);
|
||||
}
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
||||
test();
|
||||
|
|
@ -1,11 +1,14 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
var BUGNUMBER = 946042;
|
||||
var float32x4 = SIMD.float32x4;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
var int32x4 = SIMD.int32x4;
|
||||
|
||||
var summary = 'float32x4/float64x2 clamp';
|
||||
var summary = 'float32x4 clamp';
|
||||
|
||||
function test() {
|
||||
// FIXME -- Bug 1068028: Amend to check for correctness of NaN/-0 border cases once the semantics are defined.
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
// FIXME -- Bug 1068028: Amend to check for correctness of NaN border cases once the semantics are defined.
|
||||
|
||||
var a = float32x4(-20, 10, 30, 0.5);
|
||||
var lower = float32x4(2, 1, 50, 0);
|
||||
|
@ -34,24 +37,6 @@ function test() {
|
|||
assertEq(i.z, 10);
|
||||
assertEq(i.w, -10);
|
||||
|
||||
var j = float64x2(-20, 10);
|
||||
var k = float64x2(2.125, 3);
|
||||
var lower3 = float64x2(2, 1);
|
||||
var upper3 = float64x2(2.5, 5);
|
||||
var l = float64x2.clamp(j, lower3, upper3);
|
||||
assertEq(l.x, 2);
|
||||
assertEq(l.y, 5);
|
||||
var m = float64x2.clamp(k, lower3, upper3);
|
||||
assertEq(m.x, 2.125);
|
||||
assertEq(m.y, 3);
|
||||
|
||||
var n = float64x2(-5, 5);
|
||||
var lower4 = float64x2(-Infinity, 0);
|
||||
var upper4 = float64x2(+Infinity, +Infinity);
|
||||
var p = float64x2.clamp(n, lower4, upper4);
|
||||
assertEq(p.x, -5);
|
||||
assertEq(p.y, 5);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
var BUGNUMBER = 1031203;
|
||||
var float32x4 = SIMD.float32x4;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
|
||||
var summary = 'float32x4 fromFloat64x2';
|
||||
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
function test() {
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
var a = float64x2(1, 2);
|
||||
var c = float32x4.fromFloat64x2(a);
|
||||
assertEq(c.x, 1);
|
||||
assertEq(c.y, 2);
|
||||
assertEq(c.z, 0);
|
||||
assertEq(c.w, 0);
|
||||
|
||||
var d = float64x2(-0, NaN);
|
||||
var f = float32x4.fromFloat64x2(d);
|
||||
assertEq(f.x, -0);
|
||||
assertEq(f.y, NaN);
|
||||
assertEq(f.z, 0);
|
||||
assertEq(f.w, 0);
|
||||
|
||||
var g = float64x2(Infinity, -Infinity);
|
||||
var i = float32x4.fromFloat64x2(g);
|
||||
assertEq(i.x, Infinity);
|
||||
assertEq(i.y, -Infinity);
|
||||
assertEq(i.z, 0);
|
||||
assertEq(i.w, 0);
|
||||
|
||||
var j = Math.pow(2, 25) - 1;
|
||||
var k = -Math.pow(2, 25);
|
||||
var l = float64x2(j, k);
|
||||
var m = float32x4.fromFloat64x2(l);
|
||||
assertEq(m.x, Math.fround(j));
|
||||
assertEq(m.y, Math.fround(k));
|
||||
assertEq(m.z, 0);
|
||||
assertEq(m.w, 0);
|
||||
|
||||
var o = Math.pow(2, 1000);
|
||||
var p = Math.pow(2, -1000);
|
||||
var q = float64x2(o, p);
|
||||
var r = float32x4.fromFloat64x2(q);
|
||||
assertEq(r.x, Math.fround(o));
|
||||
assertEq(r.y, Math.fround(p));
|
||||
assertEq(r.z, 0);
|
||||
assertEq(r.w, 0);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
||||
test();
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
var BUGNUMBER = 1031203;
|
||||
var float32x4 = SIMD.float32x4;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
var int32x4 = SIMD.int32x4;
|
||||
|
||||
var summary = 'float32x4 fromFloat64x2Bits';
|
||||
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
function test() {
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
var a = float64x2(2.000000473111868, 512.0001225471497);
|
||||
var b = float32x4.fromFloat64x2Bits(a);
|
||||
assertEq(b.x, 1.0);
|
||||
assertEq(b.y, 2.0);
|
||||
assertEq(b.z, 3.0);
|
||||
assertEq(b.w, 4.0);
|
||||
|
||||
var c = float64x2(-0, NaN);
|
||||
var d = float32x4.fromFloat64x2Bits(c);
|
||||
assertEq(d.x, 0);
|
||||
assertEq(d.y, -0);
|
||||
assertEq(d.z, 0);
|
||||
assertEq(d.w, NaN);
|
||||
|
||||
var e = float64x2(Infinity, -Infinity);
|
||||
var f = float32x4.fromFloat64x2Bits(e);
|
||||
assertEq(f.x, 0);
|
||||
assertEq(f.y, NaN);
|
||||
assertEq(f.z, 0);
|
||||
assertEq(f.w, NaN);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
||||
test();
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
var BUGNUMBER = 1031203;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
|
||||
var summary = 'float64x2 arithmetic';
|
||||
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
function add(a, b) { return a + b; }
|
||||
function sub(a, b) { return a - b; }
|
||||
function mul(a, b) { return a * b; }
|
||||
function div(a, b) { return a / b; }
|
||||
function neg(a) { return -a; }
|
||||
function reciprocal(a) { return 1 / a; }
|
||||
function reciprocalSqrt(a) { return 1 / Math.sqrt(a); }
|
||||
|
||||
function testAdd(v, w) {
|
||||
return testBinaryFunc(v, w, float64x2.add, add);
|
||||
}
|
||||
function testSub(v, w) {
|
||||
return testBinaryFunc(v, w, float64x2.sub, sub);
|
||||
}
|
||||
function testMul(v, w) {
|
||||
return testBinaryFunc(v, w, float64x2.mul, mul);
|
||||
}
|
||||
function testDiv(v, w) {
|
||||
return testBinaryFunc(v, w, float64x2.div, div);
|
||||
}
|
||||
function testAbs(v) {
|
||||
return testUnaryFunc(v, float64x2.abs, Math.abs);
|
||||
}
|
||||
function testNeg(v) {
|
||||
return testUnaryFunc(v, float64x2.neg, neg);
|
||||
}
|
||||
function testReciprocal(v) {
|
||||
return testUnaryFunc(v, float64x2.reciprocal, reciprocal);
|
||||
}
|
||||
function testReciprocalSqrt(v) {
|
||||
return testUnaryFunc(v, float64x2.reciprocalSqrt, reciprocalSqrt);
|
||||
}
|
||||
function testSqrt(v) {
|
||||
return testUnaryFunc(v, float64x2.sqrt, Math.sqrt);
|
||||
}
|
||||
|
||||
function test() {
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
var v, w;
|
||||
for ([v, w] of [[float64x2(1, 2), float64x2(3, 4)],
|
||||
[float64x2(1.894, 2.8909), float64x2(100.764, 200.987)],
|
||||
[float64x2(-1, -2), float64x2(-14.54, 57)],
|
||||
[float64x2(+Infinity, -Infinity), float64x2(NaN, -0)]])
|
||||
{
|
||||
testAdd(v, w);
|
||||
testSub(v, w);
|
||||
testMul(v, w);
|
||||
testDiv(v, w);
|
||||
testAbs(v);
|
||||
testNeg(v);
|
||||
testReciprocal(v);
|
||||
testSqrt(v);
|
||||
}
|
||||
for (v of [float64x2(1, 0.25), float64x2(3, 0.5),
|
||||
float64x2(-0, NaN), float64x2(+Infinity, -Infinity)])
|
||||
{
|
||||
testReciprocalSqrt(v);
|
||||
}
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
||||
test();
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
var BUGNUMBER = 1031203;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
|
||||
var summary = 'float64x2 alignment';
|
||||
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
var StructType = TypedObject.StructType;
|
||||
var uint8 = TypedObject.uint8;
|
||||
|
||||
function test() {
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
assertEq(float64x2.byteLength, 16);
|
||||
assertEq(float64x2.byteAlignment, 16);
|
||||
|
||||
var Compound = new StructType({c: uint8, d: uint8, f: float64x2});
|
||||
assertEq(Compound.fieldOffsets["c"], 0);
|
||||
assertEq(Compound.fieldOffsets["d"], 1);
|
||||
assertEq(Compound.fieldOffsets["f"], 16);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
||||
test();
|
|
@ -1,41 +0,0 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
var BUGNUMBER = 1031203;
|
||||
var float32x4 = SIMD.float32x4;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
|
||||
var summary = 'float64x2 fromFloat32x4';
|
||||
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
function test() {
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
var a = float32x4(100, 200, 300, 400);
|
||||
var c = float64x2.fromFloat32x4(a);
|
||||
assertEq(c.x, 100);
|
||||
assertEq(c.y, 200);
|
||||
|
||||
var d = float32x4(NaN, -0, NaN, -0);
|
||||
var f = float64x2.fromFloat32x4(d);
|
||||
assertEq(f.x, NaN);
|
||||
assertEq(f.y, -0);
|
||||
|
||||
var g = float32x4(Infinity, -Infinity, Infinity, -Infinity);
|
||||
var i = float64x2.fromFloat32x4(g);
|
||||
assertEq(i.x, Infinity);
|
||||
assertEq(i.y, -Infinity);
|
||||
|
||||
var j = float32x4(13.37, 12.853, 49.97, 53.124);
|
||||
var l = float64x2.fromFloat32x4(j);
|
||||
assertEq(l.x, Math.fround(13.37));
|
||||
assertEq(l.y, Math.fround(12.853));
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
||||
test();
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
var BUGNUMBER = 1031203;
|
||||
var float32x4 = SIMD.float32x4;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
var int32x4 = SIMD.int32x4;
|
||||
|
||||
var summary = 'float64x2 fromFloat32x4Bits';
|
||||
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
function test() {
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
var a = float32x4(0, 1.875, 0, 2);
|
||||
var c = float64x2.fromFloat32x4Bits(a);
|
||||
assertEq(c.x, 1.0);
|
||||
assertEq(c.y, 2.0);
|
||||
|
||||
var d = float32x4(NaN, -0, Infinity, -Infinity);
|
||||
var f = float64x2.fromFloat32x4Bits(d);
|
||||
assertEq(f.x, -1.058925634e-314);
|
||||
assertEq(f.y, -1.404448428688076e+306);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
||||
test();
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
var BUGNUMBER = 1031203;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
var int32x4 = SIMD.int32x4;
|
||||
|
||||
var summary = 'float64x2 fromInt32x4';
|
||||
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
function test() {
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
var a = int32x4(1, 2, 3, 4);
|
||||
var c = float64x2.fromInt32x4(a);
|
||||
assertEq(c.x, 1);
|
||||
assertEq(c.y, 2);
|
||||
|
||||
var d = int32x4(INT32_MAX, INT32_MIN, 0, 0);
|
||||
var f = float64x2.fromInt32x4(d);
|
||||
assertEq(f.x, INT32_MAX);
|
||||
assertEq(f.y, INT32_MIN);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
||||
test();
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
var BUGNUMBER = 1031203;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
var int32x4 = SIMD.int32x4;
|
||||
|
||||
var summary = 'float64x2 fromInt32x4Bits';
|
||||
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
function test() {
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
var a = int32x4(0x00000000, 0x3ff00000, 0x0000000, 0x40000000);
|
||||
var c = float64x2.fromInt32x4Bits(a);
|
||||
assertEq(c.x, 1.0);
|
||||
assertEq(c.y, 2.0);
|
||||
|
||||
var d = int32x4(0xabcdef12, 0x3ff00000, 0x21fedcba, 0x40000000);
|
||||
var f = float64x2.fromInt32x4Bits(d);
|
||||
assertEq(f.x, 1.0000006400213732);
|
||||
assertEq(f.y, 2.0000002532866263);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
||||
test();
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
var BUGNUMBER = 1031203;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
var int32x4 = SIMD.int32x4;
|
||||
|
||||
var summary = 'float64x2 getters';
|
||||
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
function test() {
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
// Create a float64x2 and check that the getters work:
|
||||
var f = float64x2(11, 22);
|
||||
assertEq(f.x, 11);
|
||||
assertEq(f.y, 22);
|
||||
|
||||
// Test that the getters work when called reflectively:
|
||||
var g = f.__lookupGetter__("x");
|
||||
assertEq(g.call(f), 11);
|
||||
|
||||
// Test that getters cannot be applied to various incorrect things:
|
||||
assertThrowsInstanceOf(function() {
|
||||
g.call({})
|
||||
}, TypeError, "Getter applicable to random objects");
|
||||
assertThrowsInstanceOf(function() {
|
||||
g.call(0xDEADBEEF)
|
||||
}, TypeError, "Getter applicable to integers");
|
||||
assertThrowsInstanceOf(function() {
|
||||
var T = new TypedObject.StructType({x: TypedObject.float64,
|
||||
y: TypedObject.float64});
|
||||
var v = new T({x: 11, y: 22});
|
||||
g.call(v)
|
||||
}, TypeError, "Getter applicable to structs");
|
||||
assertThrowsInstanceOf(function() {
|
||||
var t = new int32x4(1, 2, 3, 4);
|
||||
g.call(t)
|
||||
}, TypeError, "Getter applicable to int32x4");
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
||||
test();
|
|
@ -1,51 +0,0 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
var BUGNUMBER = 1031203;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
var int32x4 = SIMD.int32x4;
|
||||
|
||||
var summary = 'float64x2 handles';
|
||||
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
var ArrayType = TypedObject.ArrayType;
|
||||
|
||||
var float64 = TypedObject.float64;
|
||||
var Handle = TypedObject.Handle;
|
||||
|
||||
function test() {
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
var Array = float64x2.array(3);
|
||||
var array = new Array([float64x2(1, 2),
|
||||
float64x2(3, 4),
|
||||
float64x2(5, 6)]);
|
||||
|
||||
// Test that trying to create handle into the interior of a
|
||||
// float64x2 fails.
|
||||
|
||||
assertThrowsInstanceOf(function() {
|
||||
var h = float64.handle(array, 1, "w");
|
||||
}, TypeError, "Creating a float64 handle to prop via ctor");
|
||||
|
||||
assertThrowsInstanceOf(function() {
|
||||
var h = float64.handle();
|
||||
Handle.move(h, array, 1, "w");
|
||||
}, TypeError, "Creating a float64 handle to prop via move");
|
||||
|
||||
assertThrowsInstanceOf(function() {
|
||||
var h = float64.handle(array, 1, 0);
|
||||
}, TypeError, "Creating a float64 handle to elem via ctor");
|
||||
|
||||
assertThrowsInstanceOf(function() {
|
||||
var h = float64.handle();
|
||||
Handle.move(h, array, 1, 0);
|
||||
}, TypeError, "Creating a float64 handle to elem via move");
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
||||
test();
|
|
@ -1,36 +0,0 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
var BUGNUMBER = 1031203;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
|
||||
var summary = 'float64x2 reify';
|
||||
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
var ArrayType = TypedObject.ArrayType;
|
||||
|
||||
function test() {
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
var Array = float64x2.array(3);
|
||||
var array = new Array([float64x2(1, 2),
|
||||
float64x2(3, 4),
|
||||
float64x2(5, 6)]);
|
||||
|
||||
// Test that reading array[1] produces a *copy* of float64x2, not an
|
||||
// alias into the array.
|
||||
|
||||
var f = array[1];
|
||||
assertEq(f.y, 4);
|
||||
assertEq(array[1].y, 4);
|
||||
array[1] = float64x2(7, 8);
|
||||
assertEq(f.y, 4);
|
||||
assertEq(array[1].y, 8);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
||||
test();
|
|
@ -1,45 +0,0 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
var BUGNUMBER = 1031203;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
|
||||
var summary = 'float64x2 setter';
|
||||
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
var ArrayType = TypedObject.ArrayType;
|
||||
|
||||
function test() {
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
var Array = float64x2.array(3);
|
||||
var array = new Array([float64x2(1, 2),
|
||||
float64x2(3, 4),
|
||||
float64x2(5, 6)]);
|
||||
assertEq(array[1].y, 4);
|
||||
|
||||
// Test that we are allowed to write float64x2 values into array,
|
||||
// but not other things.
|
||||
|
||||
array[1] = float64x2(7, 8);
|
||||
assertEq(array[1].y, 8);
|
||||
|
||||
assertThrowsInstanceOf(function() {
|
||||
array[1] = {x: 7, y: 8 };
|
||||
}, TypeError, "Setting float64x2 from an object");
|
||||
|
||||
assertThrowsInstanceOf(function() {
|
||||
array[1] = [ 7, 8 ];
|
||||
}, TypeError, "Setting float64x2 from an array");
|
||||
|
||||
assertThrowsInstanceOf(function() {
|
||||
array[1] = 9;
|
||||
}, TypeError, "Setting float64x2 from a number");
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
||||
test();
|
|
@ -1,36 +0,0 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
var BUGNUMBER = 1031203;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
|
||||
var summary = 'float64x2 with';
|
||||
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
function test() {
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
var a = float64x2(1, 2);
|
||||
var x = float64x2.withX(a, 5);
|
||||
var y = float64x2.withY(a, 5);
|
||||
assertEq(x.x, 5);
|
||||
assertEq(x.y, 2);
|
||||
assertEq(y.x, 1);
|
||||
assertEq(y.y, 5);
|
||||
|
||||
var b = float64x2(NaN, -0);
|
||||
var x1 = float64x2.withX(b, Infinity);
|
||||
var y1 = float64x2.withY(b, -Infinity);
|
||||
assertEq(x1.x, Infinity);
|
||||
assertEq(x1.y, -0);
|
||||
assertEq(y1.x, NaN);
|
||||
assertEq(y1.y, -Infinity);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
||||
test();
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
var BUGNUMBER = 1031203;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
var int32x4 = SIMD.int32x4;
|
||||
|
||||
var summary = 'int32x4 fromFloat64x2';
|
||||
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
function test() {
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
var a = float64x2(1, 2.2);
|
||||
var c = int32x4.fromFloat64x2(a);
|
||||
assertEq(c.x, 1);
|
||||
assertEq(c.y, 2);
|
||||
assertEq(c.z, 0);
|
||||
assertEq(c.w, 0);
|
||||
|
||||
var d = float64x2(NaN, -0);
|
||||
var f = int32x4.fromFloat64x2(d);
|
||||
assertEq(f.x, 0);
|
||||
assertEq(f.y, 0);
|
||||
assertEq(f.z, 0);
|
||||
assertEq(f.w, 0);
|
||||
|
||||
var g = float64x2(Infinity, -Infinity);
|
||||
var i = int32x4.fromFloat64x2(g);
|
||||
assertEq(i.x, 0);
|
||||
assertEq(i.y, 0);
|
||||
assertEq(i.z, 0);
|
||||
assertEq(i.w, 0);
|
||||
|
||||
var j = Math.pow(2, 31);
|
||||
var k = -Math.pow(2, 31) - 1;
|
||||
var m = float64x2(j, k);
|
||||
var l = int32x4.fromFloat64x2(m);
|
||||
assertEq(l.x, INT32_MIN);
|
||||
assertEq(l.y, INT32_MAX);
|
||||
assertEq(l.z, 0);
|
||||
assertEq(l.w, 0);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
||||
test();
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
var BUGNUMBER = 1031203;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
var int32x4 = SIMD.int32x4;
|
||||
|
||||
var summary = 'int32x4 fromFloat64x2Bits';
|
||||
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
function test() {
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
var a = float64x2(1.0, 2.0);
|
||||
var c = int32x4.fromFloat64x2Bits(a);
|
||||
assertEq(c.x, 0x00000000);
|
||||
assertEq(c.y, 0x3FF00000);
|
||||
assertEq(c.z, 0x00000000);
|
||||
assertEq(c.w, 0x40000000);
|
||||
|
||||
var d = float64x2(+Infinity, -Infinity);
|
||||
var f = int32x4.fromFloat64x2Bits(d);
|
||||
assertEq(f.x, 0x00000000);
|
||||
assertEq(f.y, 0x7ff00000);
|
||||
assertEq(f.z, 0x00000000);
|
||||
assertEq(f.w, -0x100000);
|
||||
|
||||
var g = float64x2(-0, NaN);
|
||||
var i = int32x4.fromFloat64x2Bits(g);
|
||||
assertEq(i.x, 0x00000000);
|
||||
assertEq(i.y, -0x80000000);
|
||||
assertEq(i.z, 0x00000000);
|
||||
assertEq(i.w, 0x7ff80000);
|
||||
|
||||
var j = float64x2(1.0000006400213732, 2.0000002532866263);
|
||||
var l = int32x4.fromFloat64x2Bits(j);
|
||||
assertEq(l.x, -0x543210ee);
|
||||
assertEq(l.y, 0x3ff00000);
|
||||
assertEq(l.z, 0x21fedcba);
|
||||
assertEq(l.w, 0x40000000);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
||||
test();
|
||||
|
|
@ -5,11 +5,11 @@
|
|||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Our array for int32x4 and float32x4 will have 16 elements
|
||||
const SIZE_32_ARRAY = 16;
|
||||
const SIZE_64_ARRAY = 8;
|
||||
// Our float32array will have 16 elements
|
||||
const SIZE_ARRAY = 16;
|
||||
|
||||
const SIZE_BYTES = SIZE_32_ARRAY * 4;
|
||||
// 1 float32 == 4 bytes
|
||||
const SIZE_BYTES = SIZE_ARRAY * 4;
|
||||
|
||||
function MakeComparator(kind, arr) {
|
||||
var bpe = arr.BYTES_PER_ELEMENT;
|
||||
|
@ -28,14 +28,10 @@ function MakeComparator(kind, arr) {
|
|||
sizeOfLaneElem = 4;
|
||||
typedArrayCtor = Float32Array;
|
||||
break;
|
||||
case 'float64x2':
|
||||
sizeOfLaneElem = 8;
|
||||
typedArrayCtor = Float64Array;
|
||||
break;
|
||||
default:
|
||||
assertEq(true, false, "unknown SIMD kind");
|
||||
}
|
||||
var lanes = 16 / sizeOfLaneElem;
|
||||
|
||||
// Reads (numElemToRead * sizeOfLaneElem) bytes in arr, and reinterprets
|
||||
// these bytes as a typed array equivalent to the typed SIMD vector.
|
||||
var slice = function(start, numElemToRead) {
|
||||
|
@ -53,38 +49,31 @@ function MakeComparator(kind, arr) {
|
|||
return new typedArrayCtor(new Uint8Array(asArray).buffer);
|
||||
}
|
||||
|
||||
var assertFunc = (lanes == 2) ? assertEqX2 : assertEqX4;
|
||||
var type = SIMD[kind];
|
||||
return {
|
||||
loadX: function(index) {
|
||||
var v = type.loadX(arr, index);
|
||||
assertFunc(v, slice(index, 1));
|
||||
var v = SIMD[kind].loadX(arr, index);
|
||||
assertEqX4(v, slice(index, 1));
|
||||
},
|
||||
|
||||
loadXY: function(index) {
|
||||
if (lanes < 4)
|
||||
return;
|
||||
var v = type.loadXY(arr, index);
|
||||
assertFunc(v, slice(index, 2));
|
||||
var v = SIMD[kind].loadXY(arr, index);
|
||||
assertEqX4(v, slice(index, 2));
|
||||
},
|
||||
|
||||
loadXYZ: function(index) {
|
||||
if (lanes < 4)
|
||||
return;
|
||||
var v = type.loadXYZ(arr, index);
|
||||
assertFunc(v, slice(index, 3));
|
||||
loadXYZ: function(index) {
|
||||
var v = SIMD[kind].loadXYZ(arr, index);
|
||||
assertEqX4(v, slice(index, 3));
|
||||
},
|
||||
|
||||
load: function(index) {
|
||||
var v = type.load(arr, index);
|
||||
assertFunc(v, slice(index, 4));
|
||||
var v = SIMD[kind].load(arr, index);
|
||||
assertEqX4(v, slice(index, 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function testLoad(kind, TA) {
|
||||
var lanes = TA.length / 4;
|
||||
for (var i = TA.length; i--;)
|
||||
for (var i = SIZE_ARRAY; i--;)
|
||||
TA[i] = i;
|
||||
|
||||
for (var ta of [
|
||||
|
@ -108,7 +97,7 @@ function testLoad(kind, TA) {
|
|||
var C = MakeComparator(kind, ta);
|
||||
var bpe = ta.BYTES_PER_ELEMENT;
|
||||
|
||||
var lastValidArgLoadX = (SIZE_BYTES - (lanes == 4 ? 4 : 8)) / bpe | 0;
|
||||
var lastValidArgLoadX = (SIZE_BYTES - 4) / bpe | 0;
|
||||
var lastValidArgLoadXY = (SIZE_BYTES - 8) / bpe | 0;
|
||||
var lastValidArgLoadXYZ = (SIZE_BYTES - 12) / bpe | 0;
|
||||
var lastValidArgLoad = (SIZE_BYTES - 16) / bpe | 0;
|
||||
|
@ -132,30 +121,25 @@ function testLoad(kind, TA) {
|
|||
C.loadXY(2);
|
||||
C.loadXY(3);
|
||||
C.loadXY(lastValidArgLoadXY);
|
||||
assertThrowsInstanceOf(() => SIMD[kind].loadXY(ta, lastValidArgLoadXY + 1), RangeError);
|
||||
|
||||
C.loadXYZ(0);
|
||||
C.loadXYZ(1);
|
||||
C.loadXYZ(2);
|
||||
C.loadXYZ(3);
|
||||
C.loadXYZ(lastValidArgLoadXYZ);
|
||||
|
||||
if (lanes >= 4) {
|
||||
assertThrowsInstanceOf(() => SIMD[kind].loadXY(ta, lastValidArgLoadXY + 1), RangeError);
|
||||
assertThrowsInstanceOf(() => SIMD[kind].loadXYZ(ta, lastValidArgLoadXYZ + 1), RangeError);
|
||||
}
|
||||
assertThrowsInstanceOf(() => SIMD[kind].loadXYZ(ta, lastValidArgLoadXYZ + 1), RangeError);
|
||||
}
|
||||
|
||||
if (lanes == 4) {
|
||||
// Test ToInt32 behavior
|
||||
var v = SIMD[kind].load(TA, 12.5);
|
||||
assertEqX4(v, [12, 13, 14, 15]);
|
||||
// Test ToInt32 behavior
|
||||
var v = SIMD[kind].load(TA, 12.5);
|
||||
assertEqX4(v, [12, 13, 14, 15]);
|
||||
|
||||
var obj = {
|
||||
valueOf: function() { return 12 }
|
||||
}
|
||||
var v = SIMD[kind].load(TA, obj);
|
||||
assertEqX4(v, [12, 13, 14, 15]);
|
||||
var obj = {
|
||||
valueOf: function() { return 12 }
|
||||
}
|
||||
var v = SIMD[kind].load(TA, obj);
|
||||
assertEqX4(v, [12, 13, 14, 15]);
|
||||
|
||||
var obj = {
|
||||
valueOf: function() { throw new TypeError("i ain't a number"); }
|
||||
|
@ -163,9 +147,8 @@ function testLoad(kind, TA) {
|
|||
assertThrowsInstanceOf(() => SIMD[kind].load(TA, obj), TypeError);
|
||||
}
|
||||
|
||||
testLoad('float32x4', new Float32Array(SIZE_32_ARRAY));
|
||||
testLoad('float64x2', new Float64Array(SIZE_64_ARRAY));
|
||||
testLoad('int32x4', new Int32Array(SIZE_32_ARRAY));
|
||||
testLoad('float32x4', new Float32Array(SIZE_ARRAY));
|
||||
testLoad('int32x4', new Int32Array(SIZE_ARRAY));
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
|
||||
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
var float32x4 = SIMD.float32x4;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
|
||||
function testMaxFloat32(v, w) {
|
||||
return testBinaryFunc(v, w, float32x4.max, (x, y) => Math.fround(Math.max(x, y)), 4);
|
||||
}
|
||||
function testMinFloat32(v, w) {
|
||||
return testBinaryFunc(v, w, float32x4.min, (x, y) => Math.fround(Math.min(x, y)), 4);
|
||||
}
|
||||
|
||||
function testMaxFloat64(v, w) {
|
||||
return testBinaryFunc(v, w, float64x2.max, (x, y) => Math.max(x, y), 2);
|
||||
}
|
||||
function testMinFloat64(v, w) {
|
||||
return testBinaryFunc(v, w, float64x2.min, (x, y) => Math.min(x, y), 2);
|
||||
}
|
||||
|
||||
function maxNum(x, y) {
|
||||
if (x != x)
|
||||
return y;
|
||||
if (y != y)
|
||||
return x;
|
||||
return Math.max(x, y);
|
||||
}
|
||||
|
||||
function minNum(x, y) {
|
||||
if (x != x)
|
||||
return y;
|
||||
if (y != y)
|
||||
return x;
|
||||
return Math.min(x, y);
|
||||
}
|
||||
|
||||
function testMaxNumFloat32(v, w) {
|
||||
return testBinaryFunc(v, w, float32x4.maxNum, maxNum, 4);
|
||||
}
|
||||
function testMinNumFloat32(v, w) {
|
||||
return testBinaryFunc(v, w, float32x4.minNum, minNum, 4);
|
||||
}
|
||||
|
||||
function testMaxNumFloat64(v, w) {
|
||||
return testBinaryFunc(v, w, float64x2.maxNum, maxNum, 2);
|
||||
}
|
||||
function testMinNumFloat64(v, w) {
|
||||
return testBinaryFunc(v, w, float64x2.minNum, minNum, 2);
|
||||
}
|
||||
|
||||
function test() {
|
||||
var v, w;
|
||||
for ([v, w] of [[float32x4(1, 20, 30, 4), float32x4(10, 2, 3, 40)],
|
||||
[float32x4(9.999, 2.1234, 30.4443, 4), float32x4(10, 2.1233, 30.4444, 4.0001)],
|
||||
[float32x4(NaN, -Infinity, +Infinity, -0), float32x4(13.37, 42.42, NaN, 0)]])
|
||||
{
|
||||
testMinFloat32(v, w);
|
||||
testMaxFloat32(v, w);
|
||||
testMinNumFloat32(v, w);
|
||||
testMaxNumFloat32(v, w);
|
||||
}
|
||||
|
||||
for ([v, w] of [[float64x2(1, 20), float64x2(10, 2)],
|
||||
[float64x2(30, 4), float64x2(3, 40)],
|
||||
[float64x2(9.999, 2.1234), float64x2(10, 2.1233)],
|
||||
[float64x2(30.4443, 4), float64x2(30.4444, 4.0001)],
|
||||
[float64x2(NaN, -Infinity), float64x2(13.37, 42.42)],
|
||||
[float64x2(+Infinity, -0), float64x2(NaN, 0)]])
|
||||
{
|
||||
testMinFloat64(v, w);
|
||||
testMaxFloat64(v, w);
|
||||
testMinNumFloat64(v, w);
|
||||
testMaxNumFloat64(v, w);
|
||||
}
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
||||
test();
|
||||
|
|
@ -6,7 +6,6 @@
|
|||
*/
|
||||
|
||||
var float32x4 = SIMD.float32x4;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
var int32x4 = SIMD.int32x4;
|
||||
|
||||
function select(mask, ifTrue, ifFalse) {
|
||||
|
@ -28,38 +27,38 @@ function testSelect(type, inputs) {
|
|||
for (var i = 0; i < 16; i++) {
|
||||
var mask = int32x4.bool(!!(i & 1), !!((i >> 1) & 1), !!((i >> 2) & 1), !!((i >> 3) & 1));
|
||||
for ([x, y] of inputs)
|
||||
assertEqVec(type.select(mask, x, y), select(mask, x, y));
|
||||
assertEqX4(type.select(mask, x, y), select(mask, x, y));
|
||||
}
|
||||
}
|
||||
|
||||
function int32x4FromTypeBits(type, vec) {
|
||||
switch (type) {
|
||||
case float32x4:
|
||||
return int32x4.fromFloat32x4Bits(vec);
|
||||
case float64x2:
|
||||
return int32x4.fromFloat64x2Bits(vec);
|
||||
case int32x4:
|
||||
return vec;
|
||||
default:
|
||||
throw new TypeError("Unknown SIMD type.");
|
||||
}
|
||||
}
|
||||
function bitselect(ScalarTypedArray, mask, ifTrue, ifFalse) {
|
||||
var m = simdToArray(mask);
|
||||
|
||||
function bitselect(type, mask, ifTrue, ifFalse) {
|
||||
var tv = int32x4FromTypeBits(type, ifTrue);
|
||||
var fv = int32x4FromTypeBits(type, ifFalse);
|
||||
var tr = int32x4.and(mask, tv);
|
||||
var fr = int32x4.and(int32x4.not(mask), fv);
|
||||
var orApplied = int32x4.or(tr, fr);
|
||||
var converted = type == int32x4 ? orApplied : type.fromInt32x4Bits(orApplied);
|
||||
return simdToArray(converted);
|
||||
var tv = new ScalarTypedArray(simdToArray(ifTrue));
|
||||
var fv = new ScalarTypedArray(simdToArray(ifFalse));
|
||||
|
||||
tv = new Int32Array(tv.buffer);
|
||||
fv = new Int32Array(fv.buffer);
|
||||
var res = new Int32Array(4);
|
||||
|
||||
for (var i = 0; i < 4; i++) {
|
||||
var t = 0;
|
||||
for (var bit = 0; bit < 32; bit++) {
|
||||
var readVal = (m[i] >> bit) & 1 ? tv[i] : fv[i];
|
||||
var readBit = (readVal >> bit) & 1;
|
||||
t |= readBit << bit;
|
||||
}
|
||||
res[i] = t;
|
||||
}
|
||||
|
||||
res = new ScalarTypedArray(res.buffer);
|
||||
return Array.prototype.map.call(res, x => x);
|
||||
}
|
||||
|
||||
function findCorrespondingScalarTypedArray(type) {
|
||||
switch (type) {
|
||||
case int32x4: return Int32Array;
|
||||
case float32x4: return Float32Array;
|
||||
case float64x2: return Float64Array;
|
||||
default: throw new Error("undefined scalar typed array");
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +73,7 @@ function testBitSelectSimple(type, inputs) {
|
|||
for (var i = 0; i < 16; i++) {
|
||||
var mask = int32x4.bool(!!(i & 1), !!((i >> 1) & 1), !!((i >> 2) & 1), !!((i >> 3) & 1));
|
||||
for ([x, y] of inputs)
|
||||
assertEqVec(type.bitselect(mask, x, y), bitselect(type, mask, x, y));
|
||||
assertEqX4(type.bitselect(mask, x, y), bitselect(ScalarTypedArray, mask, x, y));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +91,7 @@ function testBitSelectComplex(type, inputs) {
|
|||
var ScalarTypedArray = findCorrespondingScalarTypedArray(type);
|
||||
for (var mask of masks) {
|
||||
for ([x, y] of inputs)
|
||||
assertEqVec(type.bitselect(mask, x, y), bitselect(type, mask, x, y));
|
||||
assertEqX4(type.bitselect(mask, x, y), bitselect(ScalarTypedArray, mask, x, y));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,19 +115,6 @@ function test() {
|
|||
testBitSelectSimple(float32x4, inputs);
|
||||
testBitSelectComplex(float32x4, inputs);
|
||||
|
||||
inputs = [
|
||||
[float64x2(0.125,4.25), float64x2(9.75,16.125)],
|
||||
[float64x2(1.5,2.75), float64x2(3.25,4.5)],
|
||||
[float64x2(-1.5,-0), float64x2(NaN,-Infinity)],
|
||||
[float64x2(1,-2), float64x2(13.37,3.13)],
|
||||
[float64x2(1.5,2.75), float64x2(NaN,Infinity)],
|
||||
[float64x2(-NaN,-Infinity), float64x2(9.75,16.125)]
|
||||
];
|
||||
|
||||
testSelect(float64x2, inputs);
|
||||
testBitSelectSimple(float64x2, inputs);
|
||||
testBitSelectComplex(float64x2, inputs);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,3 @@
|
|||
function assertEqX2(v, arr) {
|
||||
try {
|
||||
assertEq(v.x, arr[0]);
|
||||
assertEq(v.y, arr[1]);
|
||||
} catch (e) {
|
||||
print("stack trace:", e.stack);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
function assertEqX4(v, arr) {
|
||||
try {
|
||||
assertEq(v.x, arr[0]);
|
||||
|
@ -20,51 +10,14 @@ function assertEqX4(v, arr) {
|
|||
}
|
||||
}
|
||||
|
||||
function simdLength(v) {
|
||||
var pt = Object.getPrototypeOf(v);
|
||||
if (pt === SIMD.int32x4.prototype || pt === SIMD.float32x4.prototype) {
|
||||
return 4;
|
||||
} else if (pt === SIMD.float64x2.prototype) {
|
||||
return 2;
|
||||
} else {
|
||||
throw new TypeError("Unknown SIMD kind.");
|
||||
}
|
||||
}
|
||||
|
||||
function assertEqVec(v, arr) {
|
||||
var lanes = simdLength(v);
|
||||
if (lanes == 4)
|
||||
assertEqX4(v, arr);
|
||||
else if (lanes == 2)
|
||||
assertEqX2(v, arr);
|
||||
else
|
||||
throw new TypeError("Unknown SIMD kind.");
|
||||
}
|
||||
|
||||
function simdToArray(v) {
|
||||
var lanes = simdLength(v);
|
||||
if (lanes == 4)
|
||||
return [v.x, v.y, v.z, v.w];
|
||||
else if (lanes == 2)
|
||||
return [v.x, v.y];
|
||||
else
|
||||
throw new TypeError("Unknown SIMD kind.");
|
||||
return [v.x, v.y, v.z, v.w];
|
||||
}
|
||||
|
||||
const INT32_MAX = Math.pow(2, 31) - 1;
|
||||
const INT32_MIN = -Math.pow(2, 31);
|
||||
assertEq(INT32_MAX + 1 | 0, INT32_MIN);
|
||||
|
||||
function testUnaryFunc(v, simdFunc, func) {
|
||||
var varr = simdToArray(v);
|
||||
|
||||
var observed = simdToArray(simdFunc(v));
|
||||
var expected = varr.map(function(v, i) { return func(varr[i]); });
|
||||
|
||||
for (var i = 0; i < observed.length; i++)
|
||||
assertEq(observed[i], expected[i]);
|
||||
}
|
||||
|
||||
function testBinaryFunc(v, w, simdFunc, func) {
|
||||
var varr = simdToArray(v);
|
||||
var warr = simdToArray(w);
|
||||
|
@ -76,19 +29,6 @@ function testBinaryFunc(v, w, simdFunc, func) {
|
|||
assertEq(observed[i], expected[i]);
|
||||
}
|
||||
|
||||
function testBinaryCompare(v, w, simdFunc, func) {
|
||||
var varr = simdToArray(v);
|
||||
var warr = simdToArray(w);
|
||||
|
||||
var inLanes = simdLength(v);
|
||||
var observed = simdToArray(simdFunc(v, w));
|
||||
assertEq(observed.length, 4);
|
||||
for (var i = 0; i < 4; i++) {
|
||||
var j = ((i * inLanes) / 4) | 0;
|
||||
assertEq(observed[i], func(varr[j], warr[j]));
|
||||
}
|
||||
}
|
||||
|
||||
function testBinaryScalarFunc(v, scalar, simdFunc, func) {
|
||||
var varr = simdToArray(v);
|
||||
|
||||
|
|
|
@ -31,19 +31,17 @@ function testStore(ta, kind, i, v) {
|
|||
SIMD[kind].storeX(ta, i, v);
|
||||
assertChanged(ta, i, [v.x]);
|
||||
|
||||
reset(ta);
|
||||
SIMD[kind].storeXY(ta, i, v);
|
||||
assertChanged(ta, i, [v.x, v.y]);
|
||||
|
||||
reset(ta);
|
||||
SIMD[kind].storeXYZ(ta, i, v);
|
||||
assertChanged(ta, i, [v.x, v.y, v.z]);
|
||||
|
||||
reset(ta);
|
||||
SIMD[kind].store(ta, i, v);
|
||||
assertChanged(ta, i, simdToArray(v));
|
||||
|
||||
if (simdLength(v) > 2) {
|
||||
reset(ta);
|
||||
SIMD[kind].storeXY(ta, i, v);
|
||||
assertChanged(ta, i, [v.x, v.y]);
|
||||
|
||||
reset(ta);
|
||||
SIMD[kind].storeXYZ(ta, i, v);
|
||||
assertChanged(ta, i, [v.x, v.y, v.z]);
|
||||
}
|
||||
assertChanged(ta, i, [v.x, v.y, v.z, v.w]);
|
||||
}
|
||||
|
||||
function testStoreInt32x4() {
|
||||
|
@ -80,32 +78,8 @@ function testStoreFloat32x4() {
|
|||
assertThrowsInstanceOf(() => SIMD.int32x4.store(F32, 0, v), TypeError);
|
||||
}
|
||||
|
||||
function testStoreFloat64x2() {
|
||||
var F64 = new Float64Array(16);
|
||||
|
||||
var v = SIMD.float64x2(1, 2);
|
||||
testStore(F64, 'float64x2', 0, v);
|
||||
testStore(F64, 'float64x2', 1, v);
|
||||
testStore(F64, 'float64x2', 14, v);
|
||||
|
||||
var v = SIMD.float64x2(NaN, -0);
|
||||
testStore(F64, 'float64x2', 0, v);
|
||||
testStore(F64, 'float64x2', 1, v);
|
||||
testStore(F64, 'float64x2', 14, v);
|
||||
|
||||
var v = SIMD.float64x2(-Infinity, +Infinity);
|
||||
testStore(F64, 'float64x2', 0, v);
|
||||
testStore(F64, 'float64x2', 1, v);
|
||||
testStore(F64, 'float64x2', 14, v);
|
||||
|
||||
assertThrowsInstanceOf(() => SIMD.float64x2.store(F64), TypeError);
|
||||
assertThrowsInstanceOf(() => SIMD.float64x2.store(F64, 0), TypeError);
|
||||
assertThrowsInstanceOf(() => SIMD.float32x4.store(F64, 0, v), TypeError);
|
||||
}
|
||||
|
||||
testStoreInt32x4();
|
||||
testStoreFloat32x4();
|
||||
testStoreFloat64x2();
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
|
|
|
@ -6,61 +6,28 @@
|
|||
*/
|
||||
|
||||
var float32x4 = SIMD.float32x4;
|
||||
var float64x2 = SIMD.float64x2;
|
||||
var int32x4 = SIMD.int32x4;
|
||||
|
||||
function swizzle2(arr, x, y) {
|
||||
return [arr[x], arr[y]];
|
||||
}
|
||||
|
||||
function swizzle4(arr, x, y, z, w) {
|
||||
function swizzle(arr, x, y, z, w) {
|
||||
return [arr[x], arr[y], arr[z], arr[w]];
|
||||
}
|
||||
|
||||
function getNumberOfLanesFromType(type) {
|
||||
switch (type) {
|
||||
case float32x4:
|
||||
case int32x4:
|
||||
return 4;
|
||||
case float64x2:
|
||||
return 2;
|
||||
}
|
||||
throw new TypeError("Unknown SIMD type.");
|
||||
}
|
||||
|
||||
function testSwizzleForType(type) {
|
||||
var lanes = getNumberOfLanesFromType(type);
|
||||
var v = lanes == 4 ? type(1, 2, 3, 4) : type(1, 2);
|
||||
var v = type(1,2,3,4);
|
||||
|
||||
assertThrowsInstanceOf(() => type.swizzle() , TypeError);
|
||||
assertThrowsInstanceOf(() => type.swizzle(v, 0) , TypeError);
|
||||
assertThrowsInstanceOf(() => type.swizzle(v, 0, 1) , TypeError);
|
||||
assertThrowsInstanceOf(() => type.swizzle(v, 0, 1, 2) , TypeError);
|
||||
assertThrowsInstanceOf(() => type.swizzle(v, 0, 1, 2, 4) , TypeError);
|
||||
assertThrowsInstanceOf(() => type.swizzle(v, 0, 1, 2, -1) , TypeError);
|
||||
assertThrowsInstanceOf(() => type.swizzle(0, 1, 2, 3, v) , TypeError);
|
||||
|
||||
if (lanes == 2) {
|
||||
assertThrowsInstanceOf(() => type.swizzle(v, 0, -1) , TypeError);
|
||||
assertThrowsInstanceOf(() => type.swizzle(v, 0, 2) , TypeError);
|
||||
} else {
|
||||
assertEq(lanes, 4);
|
||||
assertThrowsInstanceOf(() => type.swizzle(v, 0, 1), TypeError);
|
||||
}
|
||||
|
||||
// Test all possible swizzles.
|
||||
if (lanes == 4) {
|
||||
var x, y, z, w;
|
||||
for (var i = 0; i < Math.pow(4, 4); i++) {
|
||||
[x, y, z, w] = [i & 3, (i >> 2) & 3, (i >> 4) & 3, (i >> 6) & 3];
|
||||
assertEqVec(type.swizzle(v, x, y, z, w), swizzle4(simdToArray(v), x, y, z, w));
|
||||
}
|
||||
} else {
|
||||
assertEq(lanes, 2);
|
||||
var x, y;
|
||||
for (var i = 0; i < Math.pow(2, 2); i++) {
|
||||
[x, y] = [x & 1, (y >> 1) & 1];
|
||||
assertEqVec(type.swizzle(v, x, y), swizzle2(simdToArray(v), x, y));
|
||||
}
|
||||
var x, y, z, w;
|
||||
for (var i = 0; i < Math.pow(4, 4); i++) {
|
||||
[x, y, z, w] = [i & 3, (i >> 2) & 3, (i >> 4) & 3, (i >> 6) & 3];
|
||||
assertEqX4(type.swizzle(v, x, y, z, w), swizzle(simdToArray(v), x, y, z, w));
|
||||
}
|
||||
|
||||
// Test that the lane inputs are converted into an int32.
|
||||
|
@ -69,12 +36,7 @@ function testSwizzleForType(type) {
|
|||
x: 0,
|
||||
valueOf: function() { return this.x++ }
|
||||
};
|
||||
if (lanes == 4) {
|
||||
assertEqVec(type.swizzle(v, obj, obj, obj, obj), swizzle4(simdToArray(v), 0, 1, 2, 3));
|
||||
} else {
|
||||
assertEq(lanes, 2);
|
||||
assertEqVec(type.swizzle(v, obj, obj), swizzle2(simdToArray(v), 0, 1));
|
||||
}
|
||||
assertEqX4(type.swizzle(v, obj, obj, obj, obj), swizzle(simdToArray(v), 0, 1, 2, 3));
|
||||
|
||||
// Object for which ToInt32 will fail.
|
||||
obj = {
|
||||
|
@ -103,21 +65,7 @@ function testSwizzleFloat32x4() {
|
|||
testSwizzleForType(float32x4);
|
||||
}
|
||||
|
||||
function testSwizzleFloat64x2() {
|
||||
var v = float64x2(1, 2);
|
||||
|
||||
assertThrowsInstanceOf(function() {
|
||||
float32x4.swizzle(v, 0, 0, 0, 0);
|
||||
}, TypeError);
|
||||
|
||||
testSwizzleForType(float64x2);
|
||||
}
|
||||
|
||||
function shuffle2(lhsa, rhsa, x, y) {
|
||||
return [(x < 2 ? lhsa : rhsa)[x % 2],
|
||||
(y < 2 ? lhsa : rhsa)[y % 2]];
|
||||
}
|
||||
function shuffle4(lhsa, rhsa, x, y, z, w) {
|
||||
function shuffle(lhsa, rhsa, x, y, z, w) {
|
||||
return [(x < 4 ? lhsa : rhsa)[x % 4],
|
||||
(y < 4 ? lhsa : rhsa)[y % 4],
|
||||
(z < 4 ? lhsa : rhsa)[z % 4],
|
||||
|
@ -125,50 +73,24 @@ function shuffle4(lhsa, rhsa, x, y, z, w) {
|
|||
}
|
||||
|
||||
function testShuffleForType(type) {
|
||||
var lanes = getNumberOfLanesFromType(type);
|
||||
var lhs, rhs;
|
||||
if (lanes == 4) {
|
||||
lhs = type(1, 2, 3, 4);
|
||||
rhs = type(5, 6, 7, 8);
|
||||
} else {
|
||||
assertEq(lanes, 2);
|
||||
lhs = type(1, 2);
|
||||
rhs = type(3, 4);
|
||||
}
|
||||
var lhs = type(1,2,3,4);
|
||||
var rhs = type(5,6,7,8);
|
||||
|
||||
assertThrowsInstanceOf(() => type.shuffle(lhs) , TypeError);
|
||||
assertThrowsInstanceOf(() => type.shuffle(lhs, rhs) , TypeError);
|
||||
assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0) , TypeError);
|
||||
assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 1) , TypeError);
|
||||
assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 1, 2) , TypeError);
|
||||
assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 1, 2, -1) , TypeError);
|
||||
assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 1, 2, 8) , TypeError);
|
||||
assertThrowsInstanceOf(() => type.shuffle(lhs, 0, 1, 2, 7, rhs) , TypeError);
|
||||
|
||||
if (lanes == 2) {
|
||||
assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 4) , TypeError);
|
||||
assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, -1) , TypeError);
|
||||
} else {
|
||||
assertEq(lanes, 4);
|
||||
assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 1) , TypeError);
|
||||
}
|
||||
|
||||
// Test all possible shuffles.
|
||||
var x, y, z, w;
|
||||
if (lanes == 4) {
|
||||
var x, y, z, w;
|
||||
for (var i = 0; i < Math.pow(8, 4); i++) {
|
||||
[x, y, z, w] = [i & 7, (i >> 3) & 7, (i >> 6) & 7, (i >> 9) & 7];
|
||||
assertEqVec(type.shuffle(lhs, rhs, x, y, z, w),
|
||||
shuffle4(simdToArray(lhs), simdToArray(rhs), x, y, z, w));
|
||||
}
|
||||
} else {
|
||||
assertEq(lanes, 2);
|
||||
var x, y;
|
||||
for (var i = 0; i < Math.pow(4, 2); i++) {
|
||||
[x, y] = [i & 3, (i >> 3) & 3];
|
||||
assertEqVec(type.shuffle(lhs, rhs, x, y),
|
||||
shuffle2(simdToArray(lhs), simdToArray(rhs), x, y));
|
||||
}
|
||||
for (var i = 0; i < Math.pow(8, 4); i++) {
|
||||
[x, y, z, w] = [i & 7, (i >> 3) & 7, (i >> 6) & 7, (i >> 9) & 7];
|
||||
assertEqX4(type.shuffle(lhs, rhs, x, y, z, w),
|
||||
shuffle(simdToArray(lhs), simdToArray(rhs), x, y, z, w));
|
||||
}
|
||||
|
||||
// Test that the lane inputs are converted into an int32.
|
||||
|
@ -177,14 +99,8 @@ function testShuffleForType(type) {
|
|||
x: 0,
|
||||
valueOf: function() { return this.x++ }
|
||||
};
|
||||
if (lanes == 4) {
|
||||
assertEqVec(type.shuffle(lhs, rhs, obj, obj, obj, obj),
|
||||
shuffle4(simdToArray(lhs), simdToArray(rhs), 0, 1, 2, 3));
|
||||
} else {
|
||||
assertEq(lanes, 2);
|
||||
assertEqVec(type.shuffle(lhs, rhs, obj, obj),
|
||||
shuffle2(simdToArray(lhs), simdToArray(rhs), 0, 1));
|
||||
}
|
||||
assertEqX4(type.shuffle(lhs, rhs, obj, obj, obj, obj),
|
||||
shuffle(simdToArray(lhs),simdToArray(rhs), 0, 1, 2, 3));
|
||||
|
||||
// Object for which ToInt32 will fail.
|
||||
obj = {
|
||||
|
@ -213,22 +129,10 @@ function testShuffleFloat32x4() {
|
|||
testShuffleForType(float32x4);
|
||||
}
|
||||
|
||||
function testShuffleFloat64x2() {
|
||||
var v = float64x2(1, 2);
|
||||
|
||||
assertThrowsInstanceOf(function() {
|
||||
float32x4.shuffle(v, v, 0, 0, 0, 0);
|
||||
}, TypeError);
|
||||
|
||||
testShuffleForType(float64x2);
|
||||
}
|
||||
|
||||
testSwizzleInt32x4();
|
||||
testSwizzleFloat32x4();
|
||||
testSwizzleFloat64x2();
|
||||
testShuffleInt32x4();
|
||||
testShuffleFloat32x4();
|
||||
testShuffleFloat64x2();
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
|
|
|
@ -79,7 +79,6 @@
|
|||
macro(float32, float32, "float32") \
|
||||
macro(float32x4, float32x4, "float32x4") \
|
||||
macro(float64, float64, "float64") \
|
||||
macro(float64x2, float64x2, "float64x2") \
|
||||
macro(forceInterpreter, forceInterpreter, "forceInterpreter") \
|
||||
macro(format, format, "format") \
|
||||
macro(frame, frame, "frame") \
|
||||
|
|
|
@ -104,9 +104,8 @@ class GlobalObject : public NativeObject
|
|||
static const unsigned RUNTIME_CODEGEN_ENABLED = WARNED_PROTO_SETTING_SLOW + 1;
|
||||
static const unsigned DEBUGGERS = RUNTIME_CODEGEN_ENABLED + 1;
|
||||
static const unsigned INTRINSICS = DEBUGGERS + 1;
|
||||
static const unsigned FLOAT32X4_TYPE_DESCR = INTRINSICS + 1;
|
||||
static const unsigned FLOAT64X2_TYPE_DESCR = FLOAT32X4_TYPE_DESCR + 1;
|
||||
static const unsigned INT32X4_TYPE_DESCR = FLOAT64X2_TYPE_DESCR + 1;
|
||||
static const unsigned FLOAT32X4_TYPE_DESCR = INTRINSICS + 1;
|
||||
static const unsigned INT32X4_TYPE_DESCR = FLOAT32X4_TYPE_DESCR + 1;
|
||||
static const unsigned FOR_OF_PIC_CHAIN = INT32X4_TYPE_DESCR + 1;
|
||||
|
||||
/* Total reserved-slot count for global objects. */
|
||||
|
@ -409,16 +408,6 @@ class GlobalObject : public NativeObject
|
|||
return getSlotRef(FLOAT32X4_TYPE_DESCR).toObject();
|
||||
}
|
||||
|
||||
void setFloat64x2TypeDescr(JSObject &obj) {
|
||||
MOZ_ASSERT(getSlotRef(FLOAT64X2_TYPE_DESCR).isUndefined());
|
||||
setSlot(FLOAT64X2_TYPE_DESCR, ObjectValue(obj));
|
||||
}
|
||||
|
||||
JSObject &float64x2TypeDescr() {
|
||||
MOZ_ASSERT(getSlotRef(FLOAT64X2_TYPE_DESCR).isObject());
|
||||
return getSlotRef(FLOAT64X2_TYPE_DESCR).toObject();
|
||||
}
|
||||
|
||||
void setInt32x4TypeDescr(JSObject &obj) {
|
||||
MOZ_ASSERT(getSlotRef(INT32X4_TYPE_DESCR).isUndefined());
|
||||
setSlot(INT32X4_TYPE_DESCR, ObjectValue(obj));
|
||||
|
|
|
@ -969,7 +969,6 @@ static const JSFunctionSpec intrinsic_functions[] = {
|
|||
JS_FN("ClampToUint8", js::ClampToUint8, 1, 0),
|
||||
JS_FN("GetTypedObjectModule", js::GetTypedObjectModule, 0, 0),
|
||||
JS_FN("GetFloat32x4TypeDescr", js::GetFloat32x4TypeDescr, 0, 0),
|
||||
JS_FN("GetFloat64x2TypeDescr", js::GetFloat64x2TypeDescr, 0, 0),
|
||||
JS_FN("GetInt32x4TypeDescr", js::GetInt32x4TypeDescr, 0, 0),
|
||||
|
||||
#define LOAD_AND_STORE_SCALAR_FN_DECLS(_constant, _type, _name) \
|
||||
|
|
Загрузка…
Ссылка в новой задаче