diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lj_obj.h | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/lj_obj.h b/src/lj_obj.h index c7e47422..72b7ace8 100644 --- a/src/lj_obj.h +++ b/src/lj_obj.h | |||
| @@ -942,14 +942,22 @@ static LJ_AINLINE int32_t lj_num2bit(lua_Number n) | |||
| 942 | 942 | ||
| 943 | #define lj_num2int(n) ((int32_t)(n)) | 943 | #define lj_num2int(n) ((int32_t)(n)) |
| 944 | 944 | ||
| 945 | /* | ||
| 946 | ** This must match the JIT backend behavior. In particular for archs | ||
| 947 | ** that don't have a common hardware instruction for this conversion. | ||
| 948 | ** Note that signed FP to unsigned int conversions have an undefined | ||
| 949 | ** result and should never be relied upon in portable FFI code. | ||
| 950 | ** See also: C99 or C11 standard, 6.3.1.4, footnote of (1). | ||
| 951 | */ | ||
| 945 | static LJ_AINLINE uint64_t lj_num2u64(lua_Number n) | 952 | static LJ_AINLINE uint64_t lj_num2u64(lua_Number n) |
| 946 | { | 953 | { |
| 947 | #ifdef _MSC_VER | 954 | #if LJ_TARGET_X86ORX64 || LJ_TARGET_MIPS |
| 948 | if (n >= 9223372036854775808.0) /* They think it's a feature. */ | 955 | int64_t i = (int64_t)n; |
| 949 | return (uint64_t)(int64_t)(n - 18446744073709551616.0); | 956 | if (i < 0) i = (int64_t)(n - 18446744073709551616.0); |
| 950 | else | 957 | return (uint64_t)i; |
| 958 | #else | ||
| 959 | return (uint64_t)n; | ||
| 951 | #endif | 960 | #endif |
| 952 | return (uint64_t)n; | ||
| 953 | } | 961 | } |
| 954 | 962 | ||
| 955 | static LJ_AINLINE int32_t numberVint(cTValue *o) | 963 | static LJ_AINLINE int32_t numberVint(cTValue *o) |
