@@ -13395,12 +13395,17 @@ static int js_is_array(JSContext *ctx, JSValueConst val)
1339513395
1339613396static double js_math_pow(double a, double b)
1339713397{
13398+ double d;
13399+
1339813400 if (unlikely(!isfinite(b)) && fabs(a) == 1) {
1339913401 /* not compatible with IEEE 754 */
13400- return NAN;
13402+ d = NAN;
1340113403 } else {
13402- return pow(a, b);
13404+ JS_X87_FPCW_SAVE_AND_ADJUST(fpcw);
13405+ d = pow(a, b);
13406+ JS_X87_FPCW_RESTORE(fpcw);
1340313407 }
13408+ return d;
1340413409}
1340513410
1340613411JSValue JS_NewBigInt64(JSContext *ctx, int64_t v)
@@ -13820,11 +13825,15 @@ static no_inline __exception int js_binary_arith_slow(JSContext *ctx, JSValue *s
1382013825 }
1382113826 break;
1382213827 case OP_div:
13828+ JS_X87_FPCW_SAVE_AND_ADJUST(fpcw);
1382313829 sp[-2] = js_number((double)v1 / (double)v2);
13830+ JS_X87_FPCW_RESTORE(fpcw);
1382413831 return 0;
1382513832 case OP_mod:
1382613833 if (v1 < 0 || v2 <= 0) {
13834+ JS_X87_FPCW_SAVE_AND_ADJUST(fpcw);
1382713835 sp[-2] = js_number(fmod(v1, v2));
13836+ JS_X87_FPCW_RESTORE(fpcw);
1382813837 return 0;
1382913838 } else {
1383013839 v = (int64_t)v1 % (int64_t)v2;
@@ -13888,6 +13897,7 @@ static no_inline __exception int js_binary_arith_slow(JSContext *ctx, JSValue *s
1388813897 if (JS_ToFloat64Free(ctx, &d2, op2))
1388913898 goto exception;
1389013899 handle_float64:
13900+ JS_X87_FPCW_SAVE_AND_ADJUST(fpcw);
1389113901 switch(op) {
1389213902 case OP_sub:
1389313903 dr = d1 - d2;
@@ -13907,6 +13917,7 @@ static no_inline __exception int js_binary_arith_slow(JSContext *ctx, JSValue *s
1390713917 default:
1390813918 abort();
1390913919 }
13920+ JS_X87_FPCW_RESTORE(fpcw);
1391013921 sp[-2] = js_float64(dr);
1391113922 }
1391213923 return 0;
@@ -14023,7 +14034,9 @@ static no_inline __exception int js_add_slow(JSContext *ctx, JSValue *sp)
1402314034 }
1402414035 if (JS_ToFloat64Free(ctx, &d2, op2))
1402514036 goto exception;
14037+ JS_X87_FPCW_SAVE_AND_ADJUST(fpcw);
1402614038 sp[-2] = js_float64(d1 + d2);
14039+ JS_X87_FPCW_RESTORE(fpcw);
1402714040 }
1402814041 return 0;
1402914042 exception:
0 commit comments