diff options
author | Sverker Eriksson <[email protected]> | 2014-01-22 16:24:00 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2014-01-22 16:24:00 +0100 |
commit | 1b904fd1fcec000efb33446859e75872dc00ef2b (patch) | |
tree | fd206af80968325baac60b6d9fa15ef5d4d4b296 /erts/emulator/beam/utils.c | |
parent | d8565ab63de970f01ec1bf80fcbf0b3c692c7bd0 (diff) | |
download | otp-1b904fd1fcec000efb33446859e75872dc00ef2b.tar.gz otp-1b904fd1fcec000efb33446859e75872dc00ef2b.tar.bz2 otp-1b904fd1fcec000efb33446859e75872dc00ef2b.zip |
erts: Refactor big-float compare on HALFWORD to use C-stack
for the temporary conversion from float to big.
Preparation for coming bugfix of 'big_buf' array size.
Diffstat (limited to 'erts/emulator/beam/utils.c')
-rw-r--r-- | erts/emulator/beam/utils.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c index 7f8bdcb2ca..86bb5fd3ad 100644 --- a/erts/emulator/beam/utils.c +++ b/erts/emulator/beam/utils.c @@ -2688,11 +2688,7 @@ tailrecur_ne: { FloatDef f1, f2; Eterm big; -#if HEAP_ON_C_STACK - Eterm big_buf[CMP_TMP_HEAP_SIZE]; /* If HEAP_ON_C_STACK */ -#else - Eterm *big_buf = erts_get_scheduler_data()->cmp_tmp_heap; -#endif + Eterm big_buf[32]; #if HALFWORD_HEAP Wterm aw = is_immed(a) ? a : rterm2wterm(a,a_base); Wterm bw = is_immed(b) ? b : rterm2wterm(b,b_base); @@ -2718,8 +2714,9 @@ tailrecur_ne: /* Float is within the no loss limit */ f1.fd = signed_val(aw); j = float_comp(f1.fd, f2.fd); + } #if ERTS_SIZEOF_ETERM == 8 - } else if (f2.fd > (double) (MAX_SMALL + 1)) { + else if (f2.fd > (double) (MAX_SMALL + 1)) { /* Float is a positive bignum, i.e. bigger */ j = -1; } else if (f2.fd < (double) (MIN_SMALL - 1)) { @@ -2730,7 +2727,7 @@ tailrecur_ne: j = signed_val(aw) - (Sint) f2.fd; } #else - } else { + else { /* If float is positive it is bigger than small */ j = (f2.fd > 0.0) ? -1 : 1; } @@ -2765,7 +2762,7 @@ tailrecur_ne: } } else { big = double_to_big(f2.fd, big_buf); - j = big_comp(aw, big); + j = big_comp(aw, rterm2wterm(big,big_buf)); } if (_NUMBER_CODE(a_tag, b_tag) == FLOAT_BIG) { j = -j; @@ -2777,8 +2774,9 @@ tailrecur_ne: /* Float is within the no loss limit */ f2.fd = signed_val(bw); j = float_comp(f1.fd, f2.fd); + } #if ERTS_SIZEOF_ETERM == 8 - } else if (f1.fd > (double) (MAX_SMALL + 1)) { + else if (f1.fd > (double) (MAX_SMALL + 1)) { /* Float is a positive bignum, i.e. bigger */ j = 1; } else if (f1.fd < (double) (MIN_SMALL - 1)) { @@ -2789,7 +2787,7 @@ tailrecur_ne: j = (Sint) f1.fd - signed_val(bw); } #else - } else { + else { /* If float is positive it is bigger than small */ j = (f1.fd > 0.0) ? 1 : -1; } |