diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-02-05 04:31:27 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-02-05 04:31:27 +0000 |
commit | 1db619a8e1b8a5d3b52871993f6d6b608e79058e (patch) | |
tree | 9bdb85c498731821aa32bddb893bf0e93c30548a /insns.def | |
parent | d3642de04134abab0131548c03a878a486416c7d (diff) | |
download | ruby-1db619a8e1b8a5d3b52871993f6d6b608e79058e.tar.gz |
* insns.def (opt_mult): Use int128_t for overflow detection.
* bignum.c (rb_uint128t2big): added for opt_mult.
* bignum.c (rb_uint128t2big): added for rb_uint128t2big..
* configure.in: define int128_t, uint128_t and related MACROs.
Initially introduced by r41379 but reverted by r50749.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'insns.def')
-rw-r--r-- | insns.def | 25 |
1 files changed, 17 insertions, 8 deletions
@@ -1430,20 +1430,29 @@ opt_mult { if (FIXNUM_2_P(recv, obj) && BASIC_OP_UNREDEFINED_P(BOP_MULT, FIXNUM_REDEFINED_OP_FLAG)) { - long a, b; - - a = FIX2LONG(recv); + long a = FIX2LONG(recv); if (a == 0) { val = recv; } else { - b = FIX2LONG(obj); - if (MUL_OVERFLOW_FIXNUM_P(a, b)) { +#ifdef HAVE_INT128_T + VALUE rb_int128t2big(int128_t n); + int128_t r = (int128_t)a * FIX2LONG(obj); + if (RB_FIXABLE(r)) { + val = LONG2FIX((long)r); + } + else { + val = rb_int128t2big(r); + } +#else + long b = FIX2LONG(obj); + if (MUL_OVERFLOW_FIXNUM_P(a, b)) { val = rb_big_mul(rb_int2big(a), rb_int2big(b)); - } - else { + } + else { val = LONG2FIX(a * b); - } + } +#endif } } else if (FLONUM_2_P(recv, obj) && |