diff --git a/static_core/compiler/optimizer/code_generator/target/aarch32/encode.cpp b/static_core/compiler/optimizer/code_generator/target/aarch32/encode.cpp index bd9b465a147533d47a8fcb4887db42fae69ef80e..31adbd9afb04404827ca56fafca670a600f234d1 100644 --- a/static_core/compiler/optimizer/code_generator/target/aarch32/encode.cpp +++ b/static_core/compiler/optimizer/code_generator/target/aarch32/encode.cpp @@ -1131,7 +1131,7 @@ void Aarch32Encoder::EncodeIsInf(Reg dst, Reg src) GetMasm()->Mov(Convert(Condition::EQ), VixlReg(dst), VixlImm(1)); } -void Aarch32Encoder::EncodeCmpFracWithDelta(Reg src) +void Aarch32Encoder::EncodeCmpFracWithZero(Reg src) { ASSERT(src.IsFloat()); ASSERT(src.GetSize() == WORD_SIZE || src.GetSize() == DOUBLE_WORD_SIZE); @@ -1143,7 +1143,7 @@ void Aarch32Encoder::EncodeCmpFracWithDelta(Reg src) GetMasm()->Vrintz(VixlVReg(tmp).S(), VixlVReg(src).S()); EncodeSub(tmp, src, tmp); EncodeAbs(tmp, tmp); - GetMasm()->Vmov(tmp1, std::numeric_limits::epsilon()); + GetMasm()->Vmov(tmp1, 0.0); GetMasm()->Vcmp(VixlVReg(tmp).S(), tmp1); } else { ScopedTmpRegF64 tmp(this); @@ -1151,7 +1151,7 @@ void Aarch32Encoder::EncodeCmpFracWithDelta(Reg src) GetMasm()->Vrintz(VixlVReg(tmp).D(), VixlVReg(src).D()); EncodeSub(tmp, src, tmp); EncodeAbs(tmp, tmp); - GetMasm()->Vmov(tmp1, std::numeric_limits::epsilon()); + GetMasm()->Vmov(tmp1, 0.0); GetMasm()->Vcmp(VixlVReg(tmp).D(), tmp1); } GetMasm()->Vmrs(vixl::aarch32::RegisterOrAPSR_nzcv(vixl::aarch32::kPcCode), vixl::aarch32::FPSCR); @@ -1165,7 +1165,7 @@ void Aarch32Encoder::EncodeIsInteger(Reg dst, Reg src) auto labelExit = static_cast(GetLabels())->GetLabel(CreateLabel()); auto labelInfOrNan = static_cast(GetLabels())->GetLabel(CreateLabel()); - EncodeCmpFracWithDelta(src); + EncodeCmpFracWithZero(src); GetMasm()->B(vixl::aarch32::vs, labelInfOrNan); // Inf or NaN GetMasm()->Mov(vixl::aarch32::le, VixlReg(dst), 0x1); GetMasm()->Mov(vixl::aarch32::gt, VixlReg(dst), 0x0); @@ -1187,7 +1187,7 @@ void Aarch32Encoder::EncodeIsSafeInteger(Reg dst, Reg src) auto labelFalse = static_cast(GetLabels())->GetLabel(CreateLabel()); // Check if IsInteger - EncodeCmpFracWithDelta(src); + EncodeCmpFracWithZero(src); GetMasm()->B(vixl::aarch32::vs, labelFalse); // Inf or NaN GetMasm()->B(vixl::aarch32::gt, labelFalse); diff --git a/static_core/compiler/optimizer/code_generator/target/aarch32/target.h b/static_core/compiler/optimizer/code_generator/target/aarch32/target.h index 4fa364a47f721a84e4357ae5d0ed82886d0e9db2..2b2c1e4b62e6781712f9c60721169be37404eb7d 100644 --- a/static_core/compiler/optimizer/code_generator/target/aarch32/target.h +++ b/static_core/compiler/optimizer/code_generator/target/aarch32/target.h @@ -475,7 +475,7 @@ private: bool ComparePosImmHelper(Reg src, int64_t value, Condition *cc); Condition TrySwapCc(Condition cc, bool *swap); void CompareZeroHelper(Reg src, Condition *cc); - void EncodeCmpFracWithDelta(Reg src); + void EncodeCmpFracWithZero(Reg src); static inline constexpr int32_t MEM_BIG_OFFSET = 4095; static inline constexpr int32_t MEM_SMALL_OFFSET = 255; static inline constexpr int32_t VMEM_OFFSET = 1020; diff --git a/static_core/compiler/optimizer/code_generator/target/aarch64/encode.cpp b/static_core/compiler/optimizer/code_generator/target/aarch64/encode.cpp index 0aedd11c8644da29dc6fa66ee99ea83c2c6fd3de..b5ba85f508dd388fff0549abb5e0c0fe12586a1e 100644 --- a/static_core/compiler/optimizer/code_generator/target/aarch64/encode.cpp +++ b/static_core/compiler/optimizer/code_generator/target/aarch64/encode.cpp @@ -643,7 +643,7 @@ void Aarch64Encoder::EncodeIsInf(Reg dst, Reg src) GetMasm()->Cset(VixlReg(dst), vixl::aarch64::Condition::eq); } -void Aarch64Encoder::EncodeCmpFracWithDelta(Reg src) +void Aarch64Encoder::EncodeCmpFracWithZero(Reg src) { ASSERT(src.IsFloat()); ASSERT(src.GetSize() == WORD_SIZE || src.GetSize() == DOUBLE_WORD_SIZE); @@ -654,13 +654,13 @@ void Aarch64Encoder::EncodeCmpFracWithDelta(Reg src) GetMasm()->Frintz(VixlVReg(tmp), VixlVReg(src)); EncodeSub(tmp, src, tmp); EncodeAbs(tmp, tmp); - GetMasm()->Fcmp(VixlVReg(tmp), std::numeric_limits::epsilon()); + GetMasm()->Fcmp(VixlVReg(tmp), 0.0); } else { ScopedTmpRegF64 tmp(this); GetMasm()->Frintz(VixlVReg(tmp), VixlVReg(src)); EncodeSub(tmp, src, tmp); EncodeAbs(tmp, tmp); - GetMasm()->Fcmp(VixlVReg(tmp), std::numeric_limits::epsilon()); + GetMasm()->Fcmp(VixlVReg(tmp), 0.0); } } @@ -672,7 +672,7 @@ void Aarch64Encoder::EncodeIsInteger(Reg dst, Reg src) auto labelExit = static_cast(GetLabels())->GetLabel(CreateLabel()); auto labelInfOrNan = static_cast(GetLabels())->GetLabel(CreateLabel()); - EncodeCmpFracWithDelta(src); + EncodeCmpFracWithZero(src); GetMasm()->B(labelInfOrNan, vixl::aarch64::Condition::vs); // Inf or NaN GetMasm()->Cset(VixlReg(dst), vixl::aarch64::Condition::le); GetMasm()->B(labelExit); @@ -693,7 +693,7 @@ void Aarch64Encoder::EncodeIsSafeInteger(Reg dst, Reg src) auto labelFalse = static_cast(GetLabels())->GetLabel(CreateLabel()); // Check if IsInteger - EncodeCmpFracWithDelta(src); + EncodeCmpFracWithZero(src); GetMasm()->B(labelFalse, vixl::aarch64::Condition::vs); // Inf or NaN GetMasm()->B(labelFalse, vixl::aarch64::Condition::gt); diff --git a/static_core/compiler/optimizer/code_generator/target/aarch64/target.h b/static_core/compiler/optimizer/code_generator/target/aarch64/target.h index 60026f390e804b393a9820c37aa86125d1b98dc6..106f94b2f61a65390a60065468ebb78307d12e3d 100644 --- a/static_core/compiler/optimizer/code_generator/target/aarch64/target.h +++ b/static_core/compiler/optimizer/code_generator/target/aarch64/target.h @@ -467,7 +467,7 @@ private: void HandleChar(int32_t ch, const vixl::aarch64::Register &tmp, vixl::aarch64::Label *labelNotFound, vixl::aarch64::Label *labelUncompressedString); - void EncodeCmpFracWithDelta(Reg src); + void EncodeCmpFracWithZero(Reg src); private: Aarch64LabelHolder *labels_ {nullptr}; diff --git a/static_core/compiler/optimizer/code_generator/target/amd64/encode.cpp b/static_core/compiler/optimizer/code_generator/target/amd64/encode.cpp index f3aa0dfe70989d2c51594959cc51e299e4307a51..7d95c909081452a562773622557bc85806a158dc 100644 --- a/static_core/compiler/optimizer/code_generator/target/amd64/encode.cpp +++ b/static_core/compiler/optimizer/code_generator/target/amd64/encode.cpp @@ -2803,7 +2803,7 @@ void Amd64Encoder::EncodeIsInf(Reg dst, Reg src) GetMasm()->sete(ArchReg(dst, BYTE_SIZE)); } -void Amd64Encoder::EncodeCmpFracWithDelta(Reg src) +void Amd64Encoder::EncodeCmpFracWithZero(Reg src) { ASSERT(src.IsFloat()); ASSERT(src.GetType() == FLOAT32_TYPE || src.GetType() == FLOAT64_TYPE); @@ -2818,7 +2818,7 @@ void Amd64Encoder::EncodeCmpFracWithDelta(Reg src) GetMasm()->roundss(ArchVReg(tmp), ArchVReg(src), asmjit::imm(RND_CTL_TRUNCATED)); EncodeSub(tmp, src, tmp); EncodeAbs(tmp, tmp); - EncodeMov(delta, Imm(std::numeric_limits::epsilon())); + EncodeMov(delta, Imm(static_cast(0.0))); GetMasm()->ucomiss(ArchVReg(tmp), ArchVReg(delta)); } else { ScopedTmpRegF64 tmp(this); @@ -2826,7 +2826,7 @@ void Amd64Encoder::EncodeCmpFracWithDelta(Reg src) GetMasm()->roundsd(ArchVReg(tmp), ArchVReg(src), asmjit::imm(RND_CTL_TRUNCATED)); EncodeSub(tmp, src, tmp); EncodeAbs(tmp, tmp); - EncodeMov(delta, Imm(std::numeric_limits::epsilon())); + EncodeMov(delta, Imm(static_cast(0.0))); GetMasm()->ucomisd(ArchVReg(tmp), ArchVReg(delta)); } } @@ -2839,7 +2839,7 @@ void Amd64Encoder::EncodeIsInteger(Reg dst, Reg src) auto labelExit = static_cast(GetLabels())->GetLabel(CreateLabel()); GetMasm()->xor_(ArchReg(dst, WORD_SIZE), ArchReg(dst, WORD_SIZE)); - EncodeCmpFracWithDelta(src); + EncodeCmpFracWithZero(src); GetMasm()->jp(*labelExit); // Inf or NaN GetMasm()->set(ArchCc(Condition::LE, true), ArchReg(dst, BYTE_SIZE)); GetMasm()->bind(*labelExit); @@ -2855,7 +2855,7 @@ void Amd64Encoder::EncodeIsSafeInteger(Reg dst, Reg src) GetMasm()->xor_(ArchReg(dst, WORD_SIZE), ArchReg(dst, WORD_SIZE)); // Check if IsInteger - EncodeCmpFracWithDelta(src); + EncodeCmpFracWithZero(src); GetMasm()->jp(*labelExit); // Inf or NaN GetMasm()->j(ArchCc(Condition::GT, true), *labelExit); diff --git a/static_core/compiler/optimizer/code_generator/target/amd64/target.h b/static_core/compiler/optimizer/code_generator/target/amd64/target.h index 73b9a703be7ebd5161821619c52a87ebf641e475..c75f45e8501f9ffcf2b70ef826f5b00831402c4d 100644 --- a/static_core/compiler/optimizer/code_generator/target/amd64/target.h +++ b/static_core/compiler/optimizer/code_generator/target/amd64/target.h @@ -462,7 +462,7 @@ private: void CopyImmToXmm(Reg xmm, T imm); void EncodeCompareAndSwap(Reg dst, Reg obj, const Reg *offset, Reg val, Reg newval); - void EncodeCmpFracWithDelta(Reg src); + void EncodeCmpFracWithZero(Reg src); private: Amd64LabelHolder *labels_ {nullptr}; diff --git a/static_core/plugins/ets/runtime/intrinsics/std_core_Double.cpp b/static_core/plugins/ets/runtime/intrinsics/std_core_Double.cpp index 8b84c181b0435d8de775badb261d6b1f792015e5..93c92426f8d92499b76557e906086bc6d4ff692f 100644 --- a/static_core/plugins/ets/runtime/intrinsics/std_core_Double.cpp +++ b/static_core/plugins/ets/runtime/intrinsics/std_core_Double.cpp @@ -281,7 +281,7 @@ extern "C" EtsLong StdCoreDoubleBitCastToLong(EtsDouble f) static inline bool IsInteger(double v) { - return std::isfinite(v) && (std::fabs(v - std::trunc(v)) <= std::numeric_limits::epsilon()); + return std::isfinite(v) && (std::fabs(v - std::trunc(v)) == 0.0); } extern "C" EtsBoolean StdCoreDoubleIsInteger(double v) diff --git a/static_core/plugins/ets/stdlib/escompat/BigInt.ets b/static_core/plugins/ets/stdlib/escompat/BigInt.ets index bfef878abb2a66a7967f1ccb4d8d397726694a3c..51492864ed777e1858d913e251a06ca4d39ec64f 100644 --- a/static_core/plugins/ets/stdlib/escompat/BigInt.ets +++ b/static_core/plugins/ets/stdlib/escompat/BigInt.ets @@ -114,7 +114,18 @@ export final class BigInt { constructor(d: double) { // should we cast it to long at then use internal helper? // i.e. like this: this.bytes = BigInt.fromLongHelper(d as long, 64) - this((d as Double).toString()) + if (!d.isInteger()) { + throw new RangeError(`the number ${d} cannot be converted to a BigInt because it is not an integer`) + } + if (d > Long.MAX_VALUE || d < Long.MIN_VALUE) { + let trimmed = d.toString().trim() + let a = BigInt.parseFromString(trimmed) + this.bytes = a[0] as FixedArray + this.sign = a[1] as int + return + } + this.sign = d < 0 ? -1 : (d == 0 ? 0 : 1) + this.bytes = this.sign == 0 ? [] as FixedArray : BigInt.fromLongHelper(d.toLong(), 64, this.sign) } constructor(d: string) { diff --git a/static_core/plugins/ets/stdlib/std/core/Double.ets b/static_core/plugins/ets/stdlib/std/core/Double.ets index fc93a47852522e8bf1e62db7c08fa3918ebdd5ed..ef675163727e73eef950c027eea5ac7ae4281a70 100644 --- a/static_core/plugins/ets/stdlib/std/core/Double.ets +++ b/static_core/plugins/ets/stdlib/std/core/Double.ets @@ -543,7 +543,7 @@ export final class Double extends Floating implements Comparable { */ public static isInteger(v: double): boolean { // In the language % works as C fmod that differs with IEEE-754 % definition - return Double.compare(v % (1.0 as double), 0.0 as double); + return (abs(v % (1.0 as double)) == 0.0); } /** diff --git a/static_core/plugins/ets/tests/checked/ets_isinteger.ets b/static_core/plugins/ets/tests/checked/ets_isinteger.ets index d49f2b8ab63f34299300a9c0f3a3275421a70a55..e6a3825f2b887678570a4d984fd3ce20e7a9920d 100644 --- a/static_core/plugins/ets/tests/checked/ets_isinteger.ets +++ b/static_core/plugins/ets/tests/checked/ets_isinteger.ets @@ -20,12 +20,12 @@ //! ASM x64: /xor.*/, arm64: /frintz.*/, arm32: /vrintz\.f32.*/ //! ASM_NEXT x64: /roundss.*/, arm64: /fsub.*/, arm32: /vsub\.f32.*/ //! ASM_NEXT x64: /movss.*/, arm64: /fabs.*/, arm32: /vabs\.f32.*/ -//! ASM_NEXT x64: /subss.*/, arm64: /ldr.*/, arm32: /mov\s+r[0-9]+,\s+#34000000/ -//! ASM_NEXT x64: /movss.*/, arm64: /fcmp.*/, arm32: /vmov.*/ -//! ASM_NEXT x64: /mov\s+\$0x7FFFFFFF,.*/, arm64: /b\.vs.*/, arm32: /vcmp\.f32.*/ -//! ASM_NEXT x64: /movd.*/, arm64: /cset\s+w[0-9]+,\s+le/, arm32: /vmrs APSR_nzcv, FPSCR/ -//! ASM_NEXT x64: /andps.*/, arm64: /b\s+.*/, arm32: /bvs.*/ -//! ASM_NEXT x64: /mov\s+\$0x34000000,.*/, arm64: /mov\s+w[0-9]+, #0x0/, arm32: /movle\s+r[0-9]+,\s+#1/ +//! ASM_NEXT x64: /subss.*/, arm64: /fcmp.*/, arm32: /mov\s+r[0-9]+,.*/ +//! ASM_NEXT x64: /movss.*/, arm64: /b\.vs.*/, arm32: /vmov.*/ +//! ASM_NEXT x64: /mov\s+\$0x7FFFFFFF,.*/, arm64: /cset\s+w[0-9]+,\s+le/, arm32: /vcmp\.f32.*/ +//! ASM_NEXT x64: /movd.*/, arm64: /b\s+.*/, arm32: /vmrs APSR_nzcv, FPSCR/ +//! ASM_NEXT x64: /andps.*/, arm64: /mov\s+w[0-9]+, #0x0/, arm32: /bvs.*/ +//! ASM_NEXT x64: /mov\s+\$0x00,.*/, arm32: /movle\s+r[0-9]+,\s+#1/ //! ASM_NEXT x64: /movd.*/, arm32: /movgt\s+r[0-9]+,\s+#0/ //! ASM_NEXT x64: /ucomiss.*/, arm32: /b.*/ //! ASM_NEXT x64: /jp.*/, arm32: /mov\s+r[0-9]+,\s+#0/ @@ -34,16 +34,16 @@ //! ASM x64: /xor.*/, arm64: /frintz.*/, arm32: /vrintz\.f32.*/ //! ASM_NEXT x64: /roundss.*/, arm64: /fsub.*/, arm32: /vsub\.f32.*/ //! ASM_NEXT x64: /movss.*/, arm64: /fabs.*/, arm32: /vabs\.f32.*/ -//! ASM_NEXT x64: /subss.*/, arm64: /ldr.*/, arm32: /mov\s+r[0-9]+,\s+#34000000/ -//! ASM_NEXT x64: /movss.*/, arm64: /fcmp.*/, arm32: /vmov.*/ -//! ASM_NEXT x64: /mov\s+\$0x7FFFFFFF,.*/, arm64: /b\.vs.*/, arm32: /vcmp\.f32.*/ -//! ASM_NEXT x64: /movd.*/, arm64: /b\.gt.*/, arm32: /vmrs APSR_nzcv, FPSCR/ -//! ASM_NEXT x64: /andps.*/, arm64: /fabs.*/, arm32: /bvs.*/ -//! ASM_NEXT x64: /mov\s+\$0x34000000,.*/, arm64: /ldr.*/, arm32: /bgt.*/ -//! ASM_NEXT x64: /movd.*/, arm64: /fcmp.*/, arm32: /vabs\.f32/ -//! ASM_NEXT x64: /ucomiss.*/, arm64: /cset\s+w[0-9]+,\s+le/, arm32: /mov\s+r[0-9]+,\s+#ffff/ -//! ASM_NEXT x64: /jp.*/, arm64: /b\s+.*/, arm32: /movt\s+r[0-9]+,\s+#4b7f/ -//! ASM_NEXT x64: /jnbe.*/, arm64: /mov\s+w[0-9]+, #0x0/, arm32: /vmov.*/ +//! ASM_NEXT x64: /subss.*/, arm64: /fcmp.*/, arm32: /mov\s+r[0-9]+,.*/ +//! ASM_NEXT x64: /movss.*/, arm64: /b\.vs.*/, arm32: /vmov.*/ +//! ASM_NEXT x64: /mov\s+\$0x7FFFFFFF,.*/, arm64: /b\.gt.*/, arm32: /vcmp\.f32.*/ +//! ASM_NEXT x64: /movd.*/, arm64: /fabs.*/, arm32: /vmrs APSR_nzcv, FPSCR/ +//! ASM_NEXT x64: /andps.*/, arm64: /ldr.*/, arm32: /bvs.*/ +//! ASM_NEXT x64: /mov\s+\$0x00,.*/, arm64: /fcmp.*/, arm32: /bgt.*/ +//! ASM_NEXT x64: /movd.*/, arm64: /cset\s+w[0-9]+,\s+le/, arm32: /vabs\.f32/ +//! ASM_NEXT x64: /ucomiss.*/, arm64: /b\s+.*/, arm32: /mov\s+r[0-9]+,\s+#ffff/ +//! ASM_NEXT x64: /jp.*/, arm64: /mov\s+w[0-9]+, #0x0/, arm32: /movt\s+r[0-9]+,\s+#4b7f/ +//! ASM_NEXT x64: /jnbe.*/, arm32: /vmov.*/ //! ASM_NEXT x64: /mov\s+\$0x7FFFFFFF,.*/, arm32: /vcmp\.f32.*/ //! ASM_NEXT x64: /movd.*/, arm32: /vmrs APSR_nzcv, FPSCR/ //! ASM_NEXT x64: /movss.*/, arm32: /movle\s+r[0-9]+,\s+#1/ @@ -56,43 +56,38 @@ //! ASM x64: /xor.*/, arm64: /frintz.*/, arm32: /vrintz\.f64.*/ //! ASM_NEXT x64: /roundsd.*/, arm64: /fsub.*/, arm32: /vsub\.f64.*/ //! ASM_NEXT x64: /movsd.*/, arm64: /fabs.*/, arm32: /vabs\.f64.*/ -//! ASM_NEXT x64: /subsd.*/, arm64: /ldr.*/, arm32: /mov\s+r[0-9]+,\s+#0/ -//! ASM_NEXT x64: /movsd.*/, arm64: /fcmp.*/, arm32: /vdup\.32.*/ -//! ASM_NEXT x64: /mov\s+\$0x7FFFFFFFFFFFFFFF,.*/, arm64: /b\.vs.*/, arm32: /mov\s+r[0-9]+,\s+#0/ -//! ASM_NEXT x64: /movq.*/, arm64: /cset\s+w[0-9]+,\s+le/, arm32: /movt\s+r[0-9]+,\s+#3cb0/ -//! ASM_NEXT x64: /andps.*/, arm64: /b\s+.*/, arm32: /vmov\.32.*/ -//! ASM_NEXT x64: /mov\s+\$0x3CB0000000000000,.*/, arm64: /mov\s+w[0-9]+, #0x0/, arm32: /vcmp\.f64.*/ -//! ASM_NEXT x64: /movq.*/, arm32: /vmrs APSR_nzcv, FPSCR/ -//! ASM_NEXT x64: /ucomisd.*/, arm32: /bvs.*/ -//! ASM_NEXT x64: /jp.*/, arm32: /movle\s+r[0-9]+,\s+#1/ -//! ASM_NEXT x64: /setbe.*/, arm32: /movgt\s+r[0-9]+,\s+#0/ -//! ASM_NEXT arm32: /b.*/ -//! ASM_NEXT arm32: /mov\s+r[0-9]+,\s+#0/ +//! ASM_NEXT x64: /subsd.*/, arm64: /fcmp.*/, arm32: /vmov.*/ +//! ASM_NEXT x64: /movsd.*/, arm64: /b\.vs.*/, arm32: /vcmp.*/ +//! ASM_NEXT x64: /mov\s+\$0x7FFFFFFFFFFFFFFF,.*/, arm64: /cset\s+w[0-9]+,\s+le/, arm32: /vmrs.*/ +//! ASM_NEXT x64: /movq.*/, arm64: /b\s+.*/, arm32: /bvs.*/ +//! ASM_NEXT x64: /andps.*/, arm64: /mov\s+w[0-9]+, #0x0/, arm32: /movle.*/ +//! ASM_NEXT x64: /mov\s+\$0x00,.*/, arm32: /movgt.*/ +//! ASM_NEXT x64: /movq.*/, arm32: /b.*/ +//! ASM_NEXT x64: /ucomisd.*/, arm32: /mov.*/ +//! ASM_NEXT x64: /jp.*/ +//! ASM_NEXT x64: /setbe.*/ //! ASM_INST "Intrinsic.StdDoubleIsSafeInteger" //! ASM x64: /xor.*/, arm64: /frintz.*/, arm32: /vrintz\.f64.*/ //! ASM_NEXT x64: /roundsd.*/, arm64: /fsub.*/, arm32: /vsub\.f64.*/ //! ASM_NEXT x64: /movsd.*/, arm64: /fabs.*/, arm32: /vabs\.f64.*/ -//! ASM_NEXT x64: /subsd.*/, arm64: /ldr.*/, arm32: /mov\s+r[0-9]+,\s+#0/ -//! ASM_NEXT x64: /movsd.*/, arm64: /fcmp.*/, arm32: /vdup\.32.*/ -//! ASM_NEXT x64: /mov\s+\$0x7FFFFFFFFFFFFFFF,.*/, arm64: /b\.vs.*/, arm32: /mov\s+r[0-9]+,\s+#0/ -//! ASM_NEXT x64: /movq.*/, arm64: /b\.gt.*/, arm32: /movt\s+r[0-9]+,\s+#3cb0/ -//! ASM_NEXT x64: /andps.*/, arm64: /fabs.*/, arm32: /vmov\.32.*/ -//! ASM_NEXT x64: /mov\s+\$0x3CB0000000000000,.*/, arm64: /ldr.*/, arm32: /vcmp\.f64.*/ -//! ASM_NEXT x64: /movq.*/, arm64: /fcmp.*/, arm32: /vmrs APSR_nzcv, FPSCR/ -//! ASM_NEXT x64: /ucomisd.*/, arm64: /cset\s+w[0-9]+,\s+le/, arm32: /bvs.*/ -//! ASM_NEXT x64: /jp.*/, arm64: /b\s+.*/, arm32: /bgt.*/ -//! ASM_NEXT x64: /jnbe.*/, arm64: /mov\s+w[0-9]+, #0x0/, arm32: /vabs\.f64.*/ -//! ASM_NEXT x64: /mov\s+\$0x7FFFFFFFFFFFFFFF,.*/, arm32: /mvn\s+r[0-9]+,\s+#0/ -//! ASM_NEXT x64: /movq.*/, arm32: /vdup\.32.*/ -//! ASM_NEXT x64: /movsd.*/, arm32: /mov\s+r[0-9]+,\s+#ffff/ -//! ASM_NEXT x64: /andps.*/, arm32: /movt\s+r[0-9]+,\s+#433f/ -//! ASM_NEXT x64: /mov\s+\$0x433FFFFFFFFFFFFF,.*/, arm32: /vmov\.32.*/ +//! ASM_NEXT x64: /subsd.*/, arm64: /fcmp.*/, arm32: /vmov.*/ +//! ASM_NEXT x64: /movsd.*/, arm64: /b\.vs.*/, arm32: /vcmp.*/ +//! ASM_NEXT x64: /mov\s+\$0x7FFFFFFFFFFFFFFF,.*/, arm64: /b\.gt.*/, arm32: /vmrs.*/ +//! ASM_NEXT x64: /movq.*/, arm64: /fabs.*/, arm32: /bvs.*/ +//! ASM_NEXT x64: /andps.*/, arm64: /ldr.*/, arm32: /bgt.*/ +//! ASM_NEXT x64: /mov\s+\$0x00,.*/, arm64: /fcmp.*/, arm32: /vabs\.f64.*/ +//! ASM_NEXT x64: /movq.*/, arm64: /cset\s+w[0-9]+,\s+le/, arm32: /mvn.*/ +//! ASM_NEXT x64: /ucomisd.*/, arm64: /b\s+.*/, arm32: /vdup\.32.*/ +//! ASM_NEXT x64: /jp.*/, arm64: /mov\s+w[0-9]+, #0x0/, arm32: /mov\s+r[0-9]+,\s+#ffff/ +//! ASM_NEXT x64: /jnbe.*/, arm32: /movt\s+r[0-9]+,\s+#433f/ +//! ASM_NEXT x64: /mov\s+\$0x7FFFFFFFFFFFFFFF,.*/, arm32: /vmov\.32.*/ //! ASM_NEXT x64: /movq.*/, arm32: /vcmp\.f64.*/ -//! ASM_NEXT x64: /ucomisd.*/, arm32: /vmrs APSR_nzcv, FPSCR/ -//! ASM_NEXT x64: /setbe.*/, arm32: /movle\s+r[0-9]+,\s+#1/ -//! ASM_NEXT arm32: /movgt\s+r[0-9]+,\s+#0/ -//! ASM_NEXT arm32: /b.*/ -//! ASM_NEXT arm32: /mov\s+r[0-9]+,\s+#0/ +//! ASM_NEXT x64: /movsd.*/, arm32: /vmrs APSR_nzcv, FPSCR/ +//! ASM_NEXT x64: /andps.*/, arm32: /movle\s+r[0-9]+,\s+#1/ +//! ASM_NEXT x64: /mov\s+\$0x433FFFFFFFFFFFFF,.*/, arm32: /movgt.*/ +//! ASM_NEXT x64: /movq.*/, arm32: /b.*/ +//! ASM_NEXT x64: /ucomisd.*/, arm32: /mov\s+r[0-9]+,\s+#0/ +//! ASM_NEXT x64: /setbe.*/ function main(): int { let trueInt: float = 1.0f; diff --git a/static_core/plugins/ets/tests/ets_func_tests/escompat/BigIntTest.ets b/static_core/plugins/ets/tests/ets_func_tests/escompat/BigIntTest.ets index 2005453ffcedcfd8630f631b2d380e68b3facad7..58808b6ca8641af26e117b0d4675e549b855fa07 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/escompat/BigIntTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/escompat/BigIntTest.ets @@ -47,6 +47,37 @@ function testBigIntToString5() { arktest.assertEQ(result, "a") } +function testBigIntConstructor1() { + let n = BigInt(0x0102030405060708) + arktest.assertEQ(n, BigInt("72623859790382848")) + + const errorcheck = (e: Error | Exception) => { + return (e instanceof RangeError) && + e.message === 'the number 72623859.79038285 cannot be converted to a BigInt because it is not an integer' + } + arktest.expectThrow((): void => { n = BigInt(72623859.790382848) }, errorcheck) +} + +function testBigIntConstructor2() { + let n = BigInt(0x010203040506) + arktest.assertEQ(n, BigInt("1108152157446")) + n = BigInt(72623859) + arktest.assertEQ(n, BigInt("72623859")) +} + +function testBigIntConstructor3() { + let n = BigInt("72623859790382856") + arktest.assertEQ(n.toString(), "72623859790382856") + n = BigInt("72623859790382848") + arktest.assertEQ(n.toString(), "72623859790382848") +} + +function testBigIntConstructor4() { + let n = BigInt(0.0) + arktest.assertEQ(n, BigInt("0.0")) + arktest.assertEQ(n.toString(), "0") +} + function main(): int { const suite = new arktest.ArkTestsuite("test bigint toString by undefined") @@ -55,6 +86,10 @@ function main(): int { suite.addTest("convert 0b10 to toString(undefined)", testBigIntToString3) suite.addTest("convert 0x10 to toString(undefined)", testBigIntToString4) suite.addTest("test union number|undefined as params for toString", testBigIntToString5) + suite.addTest("test large numbers and decimals", testBigIntConstructor1) + suite.addTest("test ordinary numbers", testBigIntConstructor2) + suite.addTest("test strings", testBigIntConstructor3) + suite.addTest("test 0.0", testBigIntConstructor4) return suite.run() } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_double_static.yaml b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_double_static.yaml index c1f24e4decc7c99b75b1937992958fad7ff95a0b..a361cfb42685289121a6637041720229242542b6 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_double_static.yaml +++ b/static_core/plugins/ets/tests/stdlib-templates/std/core/list.std_core_double_static.yaml @@ -155,7 +155,7 @@ method_return_type: boolean, expected_data_item_type: boolean, expected_data_type: 'FixedArray', - expected_test_data: '[true, true, true, true, true, true]', + expected_test_data: '[true, true, true, true, true, false]', verify_test_result_function: 'comparePrimitiveValue' }