mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 936740: inline call to libc's ceil for Math.ceil(); r=jandem
This commit is contained in:
parent
ee3ad9642d
commit
b8918e11e2
@ -4099,6 +4099,9 @@ CodeGenerator::visitMathFunctionD(LMathFunctionD *ins)
|
||||
case MMathFunction::Floor:
|
||||
funptr = JS_FUNC_TO_DATA_PTR(void *, js::math_floor_impl);
|
||||
break;
|
||||
case MMathFunction::Ceil:
|
||||
funptr = JS_FUNC_TO_DATA_PTR(void *, js::math_ceil_impl);
|
||||
break;
|
||||
case MMathFunction::Round:
|
||||
funptr = JS_FUNC_TO_DATA_PTR(void *, js::math_round_impl);
|
||||
break;
|
||||
@ -4133,6 +4136,7 @@ CodeGenerator::visitMathFunctionF(LMathFunctionF *ins)
|
||||
case MMathFunction::ASin: funptr = JS_FUNC_TO_DATA_PTR(void *, asinf); break;
|
||||
case MMathFunction::ACos: funptr = JS_FUNC_TO_DATA_PTR(void *, acosf); break;
|
||||
case MMathFunction::Floor: funptr = JS_FUNC_TO_DATA_PTR(void *, floorf); break;
|
||||
case MMathFunction::Ceil: funptr = JS_FUNC_TO_DATA_PTR(void *, ceilf); break;
|
||||
default:
|
||||
MOZ_ASSUME_UNREACHABLE("Unknown or unsupported float32 math function");
|
||||
}
|
||||
|
@ -611,6 +611,7 @@ class IonBuilder : public MIRGenerator
|
||||
// Math natives.
|
||||
InliningStatus inlineMathAbs(CallInfo &callInfo);
|
||||
InliningStatus inlineMathFloor(CallInfo &callInfo);
|
||||
InliningStatus inlineMathCeil(CallInfo &callInfo);
|
||||
InliningStatus inlineMathRound(CallInfo &callInfo);
|
||||
InliningStatus inlineMathSqrt(CallInfo &callInfo);
|
||||
InliningStatus inlineMathAtan2(CallInfo &callInfo);
|
||||
|
@ -43,6 +43,8 @@ IonBuilder::inlineNativeCall(CallInfo &callInfo, JSNative native)
|
||||
return inlineMathAbs(callInfo);
|
||||
if (native == js::math_floor)
|
||||
return inlineMathFloor(callInfo);
|
||||
if (native == js::math_ceil)
|
||||
return inlineMathCeil(callInfo);
|
||||
if (native == js::math_round)
|
||||
return inlineMathRound(callInfo);
|
||||
if (native == js_math_sqrt)
|
||||
@ -588,6 +590,36 @@ IonBuilder::inlineMathFloor(CallInfo &callInfo)
|
||||
return InliningStatus_NotInlined;
|
||||
}
|
||||
|
||||
IonBuilder::InliningStatus
|
||||
IonBuilder::inlineMathCeil(CallInfo &callInfo)
|
||||
{
|
||||
if (callInfo.constructing())
|
||||
return InliningStatus_NotInlined;
|
||||
|
||||
if (callInfo.argc() != 1)
|
||||
return InliningStatus_NotInlined;
|
||||
|
||||
MIRType argType = callInfo.getArg(0)->type();
|
||||
MIRType returnType = getInlineReturnType();
|
||||
|
||||
// Math.ceil(int(x)) == int(x)
|
||||
if (argType == MIRType_Int32 && returnType == MIRType_Int32) {
|
||||
callInfo.unwrapArgs();
|
||||
current->push(callInfo.getArg(0));
|
||||
return InliningStatus_Inlined;
|
||||
}
|
||||
|
||||
if (IsFloatingPointType(argType) && returnType == MIRType_Double) {
|
||||
callInfo.unwrapArgs();
|
||||
MMathFunction *ins = MMathFunction::New(alloc(), callInfo.getArg(0), MMathFunction::Ceil, nullptr);
|
||||
current->add(ins);
|
||||
current->push(ins);
|
||||
return InliningStatus_Inlined;
|
||||
}
|
||||
|
||||
return InliningStatus_NotInlined;
|
||||
}
|
||||
|
||||
IonBuilder::InliningStatus
|
||||
IonBuilder::inlineMathRound(CallInfo &callInfo)
|
||||
{
|
||||
|
@ -604,6 +604,7 @@ MMathFunction::FunctionName(Function function)
|
||||
case Trunc: return "Trunc";
|
||||
case Cbrt: return "Cbrt";
|
||||
case Floor: return "Floor";
|
||||
case Ceil: return "Ceil";
|
||||
case Round: return "Round";
|
||||
default:
|
||||
MOZ_ASSUME_UNREACHABLE("Unknown math function");
|
||||
|
@ -3875,6 +3875,7 @@ class MMathFunction
|
||||
Trunc,
|
||||
Cbrt,
|
||||
Floor,
|
||||
Ceil,
|
||||
Round
|
||||
};
|
||||
|
||||
@ -3931,7 +3932,8 @@ class MMathFunction
|
||||
bool isFloat32Commutative() const {
|
||||
return function_ == Log || function_ == Sin || function_ == Cos
|
||||
|| function_ == Exp || function_ == Tan || function_ == ATan
|
||||
|| function_ == ASin || function_ == ACos || function_ == Floor;
|
||||
|| function_ == ASin || function_ == ACos || function_ == Floor
|
||||
|| function_ == Ceil;
|
||||
}
|
||||
void trySpecializeFloat32(TempAllocator &alloc);
|
||||
void computeRange(TempAllocator &alloc);
|
||||
|
Loading…
Reference in New Issue
Block a user