mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 876916 - Hook up Math.sqrt to MSqrt in asm.js. r=luke
This commit is contained in:
parent
3ba81379fd
commit
285c5366c0
@ -3341,6 +3341,28 @@ CheckMathAbs(FunctionCompiler &f, ParseNode *call, MDefinition **def, Type *type
|
||||
return f.failf(call, "%s is not a subtype of signed or doublish", argType.toChars());
|
||||
}
|
||||
|
||||
static bool
|
||||
CheckMathSqrt(FunctionCompiler &f, ParseNode *call, MDefinition **def, Type *type)
|
||||
{
|
||||
if (CallArgListLength(call) != 1)
|
||||
return f.fail(call, "Math.sqrt must be passed 1 argument");
|
||||
|
||||
ParseNode *arg = CallArgList(call);
|
||||
|
||||
MDefinition *argDef;
|
||||
Type argType;
|
||||
if (!CheckExpr(f, arg, Use::ToNumber, &argDef, &argType))
|
||||
return false;
|
||||
|
||||
if (argType.isDoublish()) {
|
||||
*def = f.unary<MSqrt>(argDef, MIRType_Double);
|
||||
*type = Type::Double;
|
||||
return true;
|
||||
}
|
||||
|
||||
return f.failf(call, "%s is not a subtype of doublish", argType.toChars());
|
||||
}
|
||||
|
||||
static bool
|
||||
CheckCallArgs(FunctionCompiler &f, ParseNode *callNode, Use use, FunctionCompiler::Args *args)
|
||||
{
|
||||
@ -3541,7 +3563,7 @@ CheckMathBuiltinCall(FunctionCompiler &f, ParseNode *callNode, AsmJSMathBuiltin
|
||||
case AsmJSMathBuiltin_floor: arity = 1; callee = UnaryMathFunCast(floor); break;
|
||||
case AsmJSMathBuiltin_exp: arity = 1; callee = UnaryMathFunCast(exp); break;
|
||||
case AsmJSMathBuiltin_log: arity = 1; callee = UnaryMathFunCast(log); break;
|
||||
case AsmJSMathBuiltin_sqrt: arity = 1; callee = UnaryMathFunCast(sqrt); break;
|
||||
case AsmJSMathBuiltin_sqrt: return CheckMathSqrt(f, callNode, def, type);
|
||||
case AsmJSMathBuiltin_pow: arity = 2; callee = BinaryMathFunCast(ecmaPow); break;
|
||||
case AsmJSMathBuiltin_atan2: arity = 2; callee = BinaryMathFunCast(ecmaAtan2); break;
|
||||
}
|
||||
|
@ -3030,6 +3030,10 @@ class MSqrt
|
||||
static MSqrt *New(MDefinition *num) {
|
||||
return new MSqrt(num);
|
||||
}
|
||||
static MSqrt *NewAsmJS(MDefinition *num, MIRType type) {
|
||||
JS_ASSERT(type == MIRType_Double);
|
||||
return new MSqrt(num);
|
||||
}
|
||||
MDefinition *num() const {
|
||||
return getOperand(0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user