diff options
author | Benoit Daloze <eregontp@gmail.com> | 2023-02-21 14:12:51 +0100 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-02-21 14:24:12 +0000 |
commit | 5077cc2be68a29339748b50b2346285f545392ea (patch) | |
tree | bbe1badff46681c088a5ee2c4329bd60df79ec1a /ext | |
parent | 93ac7405b80cc61930d73da04441fa09af1851e1 (diff) | |
download | ruby-5077cc2be68a29339748b50b2346285f545392ea.tar.gz |
[ruby/bigdecimal] Avoid RB_GC_GUARD(a) = b in bigdecimal
* This is not supported on TruffleRuby, which requires the value to be
set before RB_GC_GUARD() is called.
* See https://github.com/oracle/truffleruby/pull/2879
https://github.com/ruby/bigdecimal/commit/7b2957922f
Diffstat (limited to 'ext')
-rw-r--r-- | ext/bigdecimal/bigdecimal.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 24f299d248..b4e32c709e 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -4142,11 +4142,14 @@ get_vp_value: } x = VpCheckGetValue(vx); - RB_GC_GUARD(one) = VpCheckGetValue(NewOneWrapLimited(1, 1)); - RB_GC_GUARD(two) = VpCheckGetValue(VpCreateRbObject(1, "2", true)); + one = VpCheckGetValue(NewOneWrapLimited(1, 1)); + two = VpCheckGetValue(VpCreateRbObject(1, "2", true)); + RB_GC_GUARD(one); + RB_GC_GUARD(two); n = prec + BIGDECIMAL_DOUBLE_FIGURES; - RB_GC_GUARD(vn) = SSIZET2NUM(n); + vn = SSIZET2NUM(n); + RB_GC_GUARD(vn); expo = VpExponent10(vx); if (expo < 0 || expo >= 3) { char buf[DECIMAL_SIZE_OF_BITS(SIZEOF_VALUE * CHAR_BIT) + 4]; @@ -4158,9 +4161,12 @@ get_vp_value: } w = BigDecimal_sub(x, one); x = BigDecimal_div2(w, BigDecimal_add(x, one), vn); - RB_GC_GUARD(x2) = BigDecimal_mult2(x, x, vn); - RB_GC_GUARD(y) = x; - RB_GC_GUARD(d) = y; + x2 = BigDecimal_mult2(x, x, vn); + y = x; + d = y; + RB_GC_GUARD(x2); + RB_GC_GUARD(y); + RB_GC_GUARD(d); i = 1; while (!VpIsZero((Real*)DATA_PTR(d))) { SIGNED_VALUE const ey = VpExponent10(DATA_PTR(y)); |