summaryrefslogtreecommitdiff
path: root/src/vm/jithelpers.cpp
diff options
context:
space:
mode:
authorHyeongseok Oh <hseok82.oh@smasung.com>2016-08-23 17:07:47 +0900
committerHyeongseok Oh <hseok82.oh@smasung.com>2016-08-23 17:07:47 +0900
commit3ed59739b770dbafb494d06ea5a0a314974542b3 (patch)
treeecd5e3731b50585da6b9d641939bd894eac2b4f4 /src/vm/jithelpers.cpp
parent39302ecfa7a32bb39d30e299a1863d0af59c31c5 (diff)
downloadcoreclr-3ed59739b770dbafb494d06ea5a0a314974542b3.tar.gz
coreclr-3ed59739b770dbafb494d06ea5a0a314974542b3.tar.bz2
coreclr-3ed59739b770dbafb494d06ea5a0a314974542b3.zip
fix for infinite and NaN double
Diffstat (limited to 'src/vm/jithelpers.cpp')
-rw-r--r--src/vm/jithelpers.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/vm/jithelpers.cpp b/src/vm/jithelpers.cpp
index 0f05342a63..d3620780ed 100644
--- a/src/vm/jithelpers.cpp
+++ b/src/vm/jithelpers.cpp
@@ -613,21 +613,36 @@ HCIMPL1_V(UINT64, JIT_Dbl2ULng, double val)
const double two63 = 2147483648.0 * 4294967296.0;
UINT64 ret;
- if (val < two63) {
#ifdef _TARGET_XARCH_
+ if (val < two63) {
ret = FastDbl2Lng(val);
+ }
+ else {
+ // subtract 0x8000000000000000, do the convert then add it back again
+ ret = FastDbl2Lng(val - two63) + I64(0x8000000000000000);
+ }
#else
// In x86/x64, conversion result of negative double to unsigned integer is
// bit-equivalent unsigned value.
// But other architecture's compiler convert negative doubles to zero when
// the target is unsigned.
+ if (!_finite(val)) {
ret = UINT64(val);
-#endif
}
- else {
- // subtract 0x8000000000000000, do the convert then add it back again
- ret = FastDbl2Lng(val - two63) + I64(0x8000000000000000);
-}
+ else {
+ if (val >= 0.0) {
+ if (val < two63) {
+ ret = UINT64(val);
+ }
+ else {
+ ret = FastDbl2Lng(val - two63) + I64(0x8000000000000000);
+ }
+ }
+ else {
+ ret = UINT64(val);
+ }
+ }
+#endif
return ret;
}
HCIMPLEND