summaryrefslogtreecommitdiff
path: root/bignum.c
AgeCommit message (Collapse)Author
2019-09-10Unused LONG_MAX_as_doubleNobuyoshi Nakada
LONG_MAX_as_double is not needed when long is small enough to be exactly representable as a double, e.g., IL32LLP64 platforms.
2019-09-05interesting (but annoying) tidbit warning suppressed卜部昌平
This changeset is to suppress clang's -Wimplicit-int-float-conversion warning. In 64 bit signed long and IEEE 754 double combination (== almost everyone these days), LONG_MAX is 9,223,372,036,854,775,807. This value is _not_ exactly representable by double. The nearest value that a double can represnt is 9,223,372,036,854,775,808. It is one greater than LONG_MAX. Let's call this value the "x". The expression `LONG_MAX < yi` is a long versus double comparison. According to ISO/IEC 9899:1999 Section 6.3.1.8 (that defines the "usual rithmetic conversions"), The long value must first be casted into double. Because FLT_ROUNDS is typically 1 ("round to the nearest" mode), the conversion yields the "x" value shown above. So the comparison is in fact `x < yi`. This comparison is false for yi == x situation, i.e. yi is still bigger than LONG_MAX. On such situation the `yn = (long)yi;` statement that appear several lines below renders underfined behaviour, as per ISO/IEC 9899:1999 Section 6.3.1.3. To remedy, we just change the comparison from `<` to `<=` so that yi == x situation can properly be handled.
2019-08-03* expand tabs.git
2019-08-03Predefine some IDsNobuyoshi Nakada
2019-03-22[DOC] fix markups [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-04* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-04introduce rb_nogvl C-API to mark ubf as async-signal-safenormal
zlib and bignum both contain unblocking functions which are async-signal-safe and do not require spawning additional threads. We can execute those functions directly in signal handlers without incurring overhead of extra threads, so provide C-API users the ability to deal with that. Other C-API users may have similar need. This flexible API can supercede existing uses of rb_thread_call_without_gvl and rb_thread_call_without_gvl2 by introducing a flags argument to control behavior. Note: this API is NOT finalized. It needs approval from other committers. I prefer shorter name than previous rb_thread_call_without_gvl* functions because my eyes requires big fonts. [Bug #15499] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-12complex.c: rb_complex_new_polarnobu
* complex.c (rb_complex_new_polar): renamed with _new to clarify that it creates a new instance, but is not an instance method. * complex.c (rb_complex_polar): deprecated. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-16bignum.c: fix bug in big2dbl()shyouhei
I was wrong at r65753. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-16bignum.c: avoid (size_t)--shyouhei
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-16bignum.c: BDIGIT might or might not integer-promoteshyouhei
BDIGIT can be unsigned int or unsigned short, depending on BDIGIT_DBL. Given that, unsigned int and unsigned short are different in how integer promotion works. BOGLO assumes its argument is wider than BDIGIT, which is not always true. We have to force that explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-16avoid division by zeroshyouhei
* cvt(): use signbit() instead of 1/d < 0 * w_float(): ditto * ruby_float_step_size(): unit==0 check shall be prior to divisions * arith_seq_float_step_size(): ditto * rb_big_divide(): same as r65642 * fix_divide(): ditto * rb_big_fdiv_double(): ditto * fix_fdiv_double(): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-16bignum.c: suppress unused variable warningnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-15* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-15suppress integer overflow warningsshyouhei
* util.c: annotate as NO_SANITIZE * bignum.c: avoid (size_t)-- * marshal.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-15bignum.c: ee should be signedshyouhei
In C, signed + unsigned of the same size results in unsigned (cf: ISO/IEC 9899:1990 section 6.2.1.5). However `num` is signed here. Which means the addition must be done in signed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-13suppress integer overflow warningsshyouhei
* random.c: annotate rb_hash_start with NO_SANITIZE (seed.key.hash + h overflows and that seems intentional) * bignum.c: avoid (size_t)-- * cont.c: ditto * util.c: ditto * vm_insnhelper.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-12~(unsigned char) is not unsigned charshyouhei
The unary ~ operator excercises integer promotion of the operand _before_ actually applying bitwise complement (cf: ISO/IEC 9899:1990 section 6.3.3.3). Which means `~buf[i]` is in fact `(int)~(int)buf[i]`. The problem is, when buf[i] is 0xFF: buf[i] 0xFF (int)buf[i] 0x0000_00FF ~(int)buf[i] 0xFFFF_FF00 This is -256, out of unsigned char range. The proposed fix is to change the char signed. By doing so, buf[i] 0xFF (signed char)buf[i] 0xFF (int)(signed char)buf[i] 0xFFFF_FFFF ~(int)(signed char)buf[i] 0x0000_0000 This is 0, does not overflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-04complex.c: rb_dbl_complex_polar_pinobu
* complex.c (rb_dbl_complex_polar_pi): suffixed with _pi to clarify that `ang` is not radian, but multiplied by PI. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-02Fix Rational of Floatnobu
[ruby-core:89239] [Bug #15189] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-24UNREACHABLE_RETURNnobu
* include/ruby/ruby.h (UNREACHABLE_RETURN): UNREACHABLE at the end of non-void functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-17refine Integer#** and Float#**nobu
* complex.c (rb_dbl_complex_polar): utility function, which returns more precise value in right angle cases. * bignum.c (rb_big_pow): use rb_dbl_complex_polar(). * numeric.c (rb_float_pow, fix_pow): create a Complex by polar form. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-14bignum.c: get rid of redefined methodnobu
* bignum.c (int_pow_tmp3): get rid of redefined Integer#> on internal calculations, as well as the GMP version. * bignum.c (rb_int_powm): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-13bignum.c: call functions directlynobu
* bignum.c (int_pow_tmp{1,2,3}): call dedicated functions directly for internal calculations, instead of method calls. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-13bignum.c: refine pownobu
* bignum.c (rb_big_pow): make Complex and Rational instances from calculated results by API functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63642 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-04bignum.c: Bignum#fdiv avoids double division when divisor is bignummame
`Rational(int, bignum).to_f` sometimes returned a wrong result because `Bignum#div` casted its divisor to double. [Bug #14637] [ruby-core:86330] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-15Add `exception:` keyword in Kernel#Integer()mrkn
Support `exception:` keyword argument in Kernel#Integer(). If `exception:` is `false`, `Kernel#Integer()` returns `nil` if the given value cannot be interpreted as an integer value. The default value of `exception:` is `true`. This is part of [Feature #12732]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-24rb_int_powm: call rb_int_pow directlymrkn
* bignum.c (rb_int_powm): call rb_int_pow directly instead of calling `**` operator. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62567 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-23[DOC] obsolete classesnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-20Signature of rb_uint2big and rb_int2bignobu
* include/ruby/ruby.h (rb_uint2big, rb_int2big): declare with uintptr_t and intptr_t instead of VALUE and SIGNED_VALUE respectively. [ruby-core:83424] [Bug #14036] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-04mjit_compile.c: merge initial JIT compilerk0kubun
which has been developed by Takashi Kokubun <takashikkbn@gmail> as YARV-MJIT. Many of its bugs are fixed by wanabe <s.wanabe@gmail.com>. This JIT compiler is designed to be a safe migration path to introduce JIT compiler to MRI. So this commit does not include any bytecode changes or dynamic instruction modifications, which are done in original MJIT. This commit even strips off some aggressive optimizations from YARV-MJIT, and thus it's slower than YARV-MJIT too. But it's still fairly faster than Ruby 2.5 in some benchmarks (attached below). Note that this JIT compiler passes `make test`, `make test-all`, `make test-spec` without JIT, and even with JIT. Not only it's perfectly safe with JIT disabled because it does not replace VM instructions unlike MJIT, but also with JIT enabled it stably runs Ruby applications including Rails applications. I'm expecting this version as just "initial" JIT compiler. I have many optimization ideas which are skipped for initial merging, and you may easily replace this JIT compiler with a faster one by just replacing mjit_compile.c. `mjit_compile` interface is designed for the purpose. common.mk: update dependencies for mjit_compile.c. internal.h: declare `rb_vm_insn_addr2insn` for MJIT. vm.c: exclude some definitions if `-DMJIT_HEADER` is provided to compiler. This avoids to include some functions which take a long time to compile, e.g. vm_exec_core. Some of the purpose is achieved in transform_mjit_header.rb (see `IGNORED_FUNCTIONS`) but others are manually resolved for now. Load mjit_helper.h for MJIT header. mjit_helper.h: New. This is a file used only by JIT-ed code. I'll refactor `mjit_call_cfunc` later. vm_eval.c: add some #ifdef switches to skip compiling some functions like Init_vm_eval. win32/mkexports.rb: export thread/ec functions, which are used by MJIT. include/ruby/defines.h: add MJIT_FUNC_EXPORTED macro alis to clarify that a function is exported only for MJIT. array.c: export a function used by MJIT. bignum.c: ditto. class.c: ditto. compile.c: ditto. error.c: ditto. gc.c: ditto. hash.c: ditto. iseq.c: ditto. numeric.c: ditto. object.c: ditto. proc.c: ditto. re.c: ditto. st.c: ditto. string.c: ditto. thread.c: ditto. variable.c: ditto. vm_backtrace.c: ditto. vm_insnhelper.c: ditto. vm_method.c: ditto. I would like to improve maintainability of function exports, but I believe this way is acceptable as initial merging if we clarify the new exports are for MJIT (so that we can use them as TODO list to fix) and add unit tests to detect unresolved symbols. I'll add unit tests of JIT compilations in succeeding commits. Author: Takashi Kokubun <takashikkbn@gmail.com> Contributor: wanabe <s.wanabe@gmail.com> Part of [Feature #14235] --- * Known issues * Code generated by gcc is faster than clang. The benchmark may be worse in macOS. Following benchmark result is provided by gcc w/ Linux. * Performance is decreased when Google Chrome is running * JIT can work on MinGW, but it doesn't improve performance at least in short running benchmark. * Currently it doesn't perform well with Rails. We'll try to fix this before release. --- * Benchmark reslts Benchmarked with: Intel 4.0GHz i7-4790K with 16GB memory under x86-64 Ubuntu 8 Cores - 2.0.0-p0: Ruby 2.0.0-p0 - r62186: Ruby trunk (early 2.6.0), before MJIT changes - JIT off: On this commit, but without `--jit` option - JIT on: On this commit, and with `--jit` option ** Optcarrot fps Benchmark: https://github.com/mame/optcarrot | |2.0.0-p0 |r62186 |JIT off |JIT on | |:--------|:--------|:--------|:--------|:--------| |fps |37.32 |51.46 |51.31 |58.88 | |vs 2.0.0 |1.00x |1.38x |1.37x |1.58x | ** MJIT benchmarks Benchmark: https://github.com/benchmark-driver/mjit-benchmarks (Original: https://github.com/vnmakarov/ruby/tree/rtl_mjit_branch/MJIT-benchmarks) | |2.0.0-p0 |r62186 |JIT off |JIT on | |:----------|:--------|:--------|:--------|:--------| |aread |1.00 |1.09 |1.07 |2.19 | |aref |1.00 |1.13 |1.11 |2.22 | |aset |1.00 |1.50 |1.45 |2.64 | |awrite |1.00 |1.17 |1.13 |2.20 | |call |1.00 |1.29 |1.26 |2.02 | |const2 |1.00 |1.10 |1.10 |2.19 | |const |1.00 |1.11 |1.10 |2.19 | |fannk |1.00 |1.04 |1.02 |1.00 | |fib |1.00 |1.32 |1.31 |1.84 | |ivread |1.00 |1.13 |1.12 |2.43 | |ivwrite |1.00 |1.23 |1.21 |2.40 | |mandelbrot |1.00 |1.13 |1.16 |1.28 | |meteor |1.00 |2.97 |2.92 |3.17 | |nbody |1.00 |1.17 |1.15 |1.49 | |nest-ntimes|1.00 |1.22 |1.20 |1.39 | |nest-while |1.00 |1.10 |1.10 |1.37 | |norm |1.00 |1.18 |1.16 |1.24 | |nsvb |1.00 |1.16 |1.16 |1.17 | |red-black |1.00 |1.02 |0.99 |1.12 | |sieve |1.00 |1.30 |1.28 |1.62 | |trees |1.00 |1.14 |1.13 |1.19 | |while |1.00 |1.12 |1.11 |2.41 | ** Discourse's script/bench.rb Benchmark: https://github.com/discourse/discourse/blob/v1.8.7/script/bench.rb NOTE: Rails performance was somehow a little degraded with JIT for now. We should fix this. (At least I know opt_aref is performing badly in JIT and I have an idea to fix it. Please wait for the fix.) *** JIT off Your Results: (note for timings- percentile is first, duration is second in millisecs) categories_admin: 50: 17 75: 18 90: 22 99: 29 home_admin: 50: 21 75: 21 90: 27 99: 40 topic_admin: 50: 17 75: 18 90: 22 99: 32 categories: 50: 35 75: 41 90: 43 99: 77 home: 50: 39 75: 46 90: 49 99: 95 topic: 50: 46 75: 52 90: 56 99: 101 *** JIT on Your Results: (note for timings- percentile is first, duration is second in millisecs) categories_admin: 50: 19 75: 21 90: 25 99: 33 home_admin: 50: 24 75: 26 90: 30 99: 35 topic_admin: 50: 19 75: 20 90: 25 99: 30 categories: 50: 40 75: 44 90: 48 99: 76 home: 50: 42 75: 48 90: 51 99: 89 topic: 50: 49 75: 55 90: 58 99: 99 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19INFINITY is float. That of double is HUGE_VAL.shyouhei
It seems HUGE_VAL is already used. Why not eliminate INTINITY. NAN is also float. That of double is called nan(). This is also fixed. Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15__builtin_assume_aligned for *(foo *) castsshyouhei
These casts are guarded. Must be safe to assume alignments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15__alignof__ to take alignment of a typeshyouhei
C11 and C++11 has this feature so why not use it when available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-30numeric.c: Fix Integer#pow with a large Fixnum modulomrkn
* numeric.c: Fix Integer#pow with a large Fixnum modulo [Bug #14259] [ruby-core:84562] * test/ruby/test_numeric.rb: add assertions for reproducing this bug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-08bignum.c: [DOC] simplify commentstomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-06`Integer#pow(b)` accepts numerickazu
instead of integer only and returns numeric instead of integer only same as `Integer#**` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-05bignum.c: unified int_pow_tmp2nobu
* bignum.c (int_pow_tmp2): unified DLONG and none DLONG code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-04bignum.c: explicit castsnobu
* bignum.c (int_pow_tmp2): explicitly cast to get rid of implicit conversion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-04bignum.c, numeric.c: add Integer#pow(b, m)mrkn
This commit is based on the pull-request #1320 created by Makoto Kishimoto. [Feature #12508] [Feature #11003] [close GH-1320] * bignum.c (rb_int_powm): Added for Integer#pow(b, m). * internal.h (rb_int_powm): Declared to refer in numeric.c. * bignum.c (bary_powm_gmp): Added for Integer#pow(b, m) using GMP. * bignum.c (int_pow_tmp1): Added for implementing Integer#pow(b, m). * bignum.c (int_pow_tmp2, int_pow_tmp3): ditto. * internal.h (rb_num_positive_int_p): Moved from numeric.c for sharing the definition with bignum.c. * internal.h (rb_num_negative_int_p, rb_num_compare_with_zero): ditto. * numeric.c(negative_int_p): Moved to internal.h for sharing the definition with bignum.c. * numeric.c (positive_int_p, compare_with_zero): ditto. * numeric.c (rb_int_odd_p): Exported (renamed from int_odd_p). * internal.h (rb_int_odd_p): ditto. * internal.h (HALF_LONG_MSB): Added. * numeric.c (SQRT_LONG_MAX): Redefined by using HALF_LONG_MSB. * test/ruby/test_numeric.rb (test_pow): Added for Integer#pow(b, m). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-02bignum.c: avoid use of uninitialized value in Integer.sqrtrhe
This is a follow-up fix to r57713. estimate_initial_sqrt() didn't initialize BDIGITs except the topmost two, letting Integer.sqrt return wrong result in the fast path, such as for (1<<504). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-18Get rid of shadowing local variablesnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-22numeric.c: use NUM2DBLnobu
* numeric.c (fix_fdiv_double), bignum.c (rb_big_fdiv_double): use NUM2DBL on unknown object. RFLOAT_VALUE is only appliicable to T_FLOAT object. [ruby-core:82924] [Bug #13928] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-15bignum.c: fix inexact estimationnobu
* bignum.c (estimate_initial_sqrt): estimated square root is inexact if it is not equal to its ceil, needs Newton's method. [ruby-core:80696] [Bug #13440] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-16bignum.c: [DOC] typos and grammarstomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-16bignum.c: rb_int_parse_cstrnobu
* bignum.c (rb_int_parse_cstr): extend rb_cstr_parse_inum with flags. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-09revert RB_FIXABLE related changesets [Bug #13288][Bug #13293][Bug #13294]shyouhei
This commit is auto-generated using following command: svn diff -r57807:57788 include internal.h bignum.c numeric.c compile.c insns.def object.c sprintf.c | patch -p0 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-07Use ADD instead of MULnaruse
* On recent CPUs, 2-operand MUL's latency is 3 cycle but ADD is 1 cycle. * clang Optimizes `MUL rax,2` into `ADD rax,rax` but gcc7 doesn't. * LONG2FIX is compiled into `lea r14,[r15+r15*1+0x1]`; this is 1cycle and run in parallel if the branch prediction is correct. * Note that old (RB_POSFIXABLE(f) && RB_NEGFIXABLE(f)) is usually uses following instructions. * movabs rax,0x4000000000000000 * add rax,rdi * js It needs large immediate and Macro-Fusion is not applied. ADD and JO is much smaller though it is also Macro-Fusion unfriendly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-06optimize FIXABLE macroshyouhei
Looking at the source code, FIXABLE tends to be just before LOING2FIX to check applicability of that operation. Why not try computing first then check for overflow, which should be optimial. I also tried the same thing for unsigned types but resulted in slower execution. It seems RB_POSFIXABLE() is fast enough on modern CPUs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-28Makefile.sub: ULL_TO_DOUBLEnobu
* win32/Makefile.sub (config.h): define ULL_TO_DOUBLE for conversion from unsigned __int64 to double, which is not implemented in till Visual Studio.NET 2003, aka VC7.1. * bignum.c (estimate_initial_sqrt): use ULL_TO_DOUBLE if defined. * numeric.c (BDIGIT_DBL_TO_DOUBLE): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e