Граф коммитов

509 Коммитов

Автор SHA1 Сообщение Дата
akr 6fdad008a2 * bignum.c (rb_big_sq_fast): New function for testing.
(rb_big_mul_toom3): Ditto.

* internal.h (rb_big_sq_fast): Declared.
  (rb_big_mul_toom3): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 13:05:57 +00:00
akr 85855a2242 * bignum.c (bary_mul_balance): Initialize a local variable to suppress
a warning.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 13:00:11 +00:00
akr ffe55cdc1e * bignum.c (bary_mul_balance): Reduce work memory.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 11:56:55 +00:00
akr a25f95f8b7 * bignum.c (bary_mul): Add a RB_GC_GUARD.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07 23:04:25 +00:00
akr 1210743cad * bignum.c (bary_mul_karatsuba): Unreachable code removed. Remove
several branches.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07 15:21:26 +00:00
akr 29634bca31 * internal.h (rb_big_mul_normal): Declared.
(rb_big_mul_balance): Ditto.
  (rb_big_mul_karatsuba): Ditto.

* bignum.c (rb_big_mul_normal): New function for tests.
  (rb_big_mul_balance): Ditto.
  (rb_big_mul_karatsuba): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07 14:01:40 +00:00
akr d7c2f3f8a4 Useless comment removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07 11:04:07 +00:00
akr 42d6020059 * bignum.c: Reorder functions to decrease forward reference.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07 11:02:47 +00:00
akr 8dbf566094 * bignum.c: (bigsub_core): Use bary_sub.
(bary_sub): Returns a borrow flag.  Use bary_subb.
  (bary_subb): New function for actually calculating subtraction with
  borrow.
  (bary_sub_one): New function.
  (bigadd_core): Use bary_add.
  (bary_add): Returns a carry flag.  Use bary_addc.
  (bary_addc): New function for actually calculating addition with
  carry.
  (bary_add_one): New function.
  (bary_muladd_1xN): Extracted from bary_mul_normal.
  (bigmul1_normal): Removed.
  (bary_mul_karatsuba): New function.
  (bary_mul1): Invoke rb_thread_check_ints after bary_mul_normal.
  (bary_mul): Remove most and least significant zeros before actual
  multiplication.  Use bary_sq_fast, bary_mul_balance,
  bary_mul_karatsuba and bigmul1_toom3 as bigmul0.
  (bigmul1_balance): Removed.
  (bigmul1_karatsuba): Removed.
  (bigsqr_fast): Removed.
  (bary_sparse_p): Extracted from big_sparse_p.
  (big_sparse_p): Removed.
  (bigmul0): Use bary_mul.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07 06:03:52 +00:00
akr b2cf5f36b9 * bignum.c (bary_sq_fast): Extracted from bigsqr_fast and
ensure not to access zds[2*xn].
  (bigsqr_fast): Allocate the result bignum with 2*xn words.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07 01:22:55 +00:00
akr c97c78501f * bignum.c (BARY_MUL1): Renamed from BARY_MUL.
(bary_mul1): Renamed from bary_mul.
  (bary_mul): Renamed from bary_mul2.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-04 21:04:21 +00:00
akr c311134319 * bignum.c (bary_mul_balance): Extracted from bigmul1_balance and
use bary_mul2 and bary_add to decrease allocations.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-04 20:31:01 +00:00
nobu 4e681d978a bignum.c: constify
* bignum.c: constify maxpow tables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-04 14:41:26 +00:00
akr 313cdec1bc * bignum.c (maxpow_in_bdigit_dbl): Use tables if available.
(maxpow_in_bdigit): Ditto.
  (U16): New macro.
  (U32): Ditto.
  (U64): Ditto.
  (U128): Ditto.
  (maxpow16_exp): New table.
  (maxpow16_num): New table.
  (maxpow32_exp): New table.
  (maxpow32_num): New table.
  (maxpow64_exp): New table.
  (maxpow64_num): New table.
  (maxpow128_exp): New table.
  (maxpow128_num): New table.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-04 11:23:46 +00:00
akr fd8f2338e9 * bignum.c (rb_cstr_to_inum): Avoid temporary buffer allocation except
very big base non-power-of-2 numbers.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-04 09:38:11 +00:00
akr b2be623240 * internal.h (ruby_digit36_to_number_table): Declared.
* util.c (ruby_digit36_to_number_table): Moved from scan_digits.

* bignum.c (conv_digit): Use ruby_digit36_to_number_table.

* pack.c (hex2num): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-03 13:32:14 +00:00
akr c4107e71c5 * bignum.c (maxpow_in_bdigit): Renamed from calc_hbase and return
maxpow.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-03 03:08:52 +00:00
akr c78826190f * bignum.c (roomof): Cast to long.
(rb_ull2big): Fix bignew arguments.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-02 14:49:06 +00:00
charliesome d74bb62dcc * bignum.c (rb_cstr_to_inum): fix 64 bit to 32 bit shorten warning
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-02 13:16:35 +00:00
akr 4658478ae1 * bignum.c (rb_cstr_to_inum): Merge two temporary buffers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-02 12:20:00 +00:00
akr 2ade221827 * bignum.c (rb_cstr_to_inum): Use BDIGIT_DBL to collect adjacent digits.
(BDIGIT_DBL_MAX): New macro.
  (maxpow_in_bdigit_dbl): New function.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-02 11:52:13 +00:00
akr df1192edf5 * bignum.c (bary_mul2): New function.
(rb_cstr_to_inum): Use a better algorithm to compose the result
  if input length is very long.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-01 13:59:50 +00:00
akr 551fe2bddc * bignum.c (rb_cstr_to_inum): Skip leading zeros.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-01 03:04:07 +00:00
akr 98a8c820c7 * bignum.c (nlz16): New function.
(nlz32): Ditto.
  (nlz64): Ditto.
  (nlz128): Ditto.
  (nlz): Redefined using an above function.
  (bitsize): New macro.
  (rb_cstr_to_inum): Use bitsize instead of nlz.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-30 16:01:53 +00:00
akr 305f06c7e3 * bignum.c (rb_cstr_to_inum): Use rb_integer_unpack if base is a power
of 2.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-30 13:16:08 +00:00
akr b1e052d080 * bignum.c (big_rshift): Use abs2twocomp and twocomp2abs_bang.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29 16:58:58 +00:00
akr 7251c93cb3 * bignum.c (RBIGNUM_SET_NEGATIVE_SIGN): New macro.
(RBIGNUM_SET_POSITIVE_SIGN): Ditto.
  (rb_big_neg): Inline get2comp to avoid double negation.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29 15:57:07 +00:00
akr 1522375b99 * bignum.c (bary_neg): Extracted from bary_2comp.
(bary_plus_one): Extracted from bary_2comp.
  (bary_2comp): Use bary_neg and bary_plus_one.
  (big_extend_carry): Extracted from get2comp.
  (get2comp): Use big_extend_carry.
  (rb_integer_unpack): Use big_extend_carry.
  (rb_big_neg): Use bary_neg.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29 14:38:26 +00:00
akr 69f1a3351f * bignum.c (bary_2comp): Simplified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29 13:33:40 +00:00
akr c6cb7416d2 * bignum.c (bigor_int): Return -1 if y == -1.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29 00:35:57 +00:00
akr f0454052f7 * bignum.c (bigor_int): Use RB_GC_GUARD.
(bigxor_int): Take xn and hibitsx arguments.  Use twocomp2abs_bang.
  (rb_big_xor): Use abs2twocomp and twocomp2abs_bang.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29 00:08:47 +00:00
akr 88430941c8 * bignum.c (bigand_int): Don't apply bitwise and for BDIGIT and long.
(bigor_int): Take xn and hibitsx arguments.  Use twocomp2abs_bang.
  (rb_big_or): Use abs2twocomp and twocomp2abs_bang.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-28 23:21:57 +00:00
akr b83b33eef0 * bignum.c (rb_big_and): Allocate new bignum with same size to shorter
argument if it's high bits are zero.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-28 03:35:39 +00:00
akr 43e4de376b * bignum.c (bigand_int): Add arguments, xn and hibitsx.
Use twocomp2abs_bang.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-27 23:07:59 +00:00
akr ef18728433 * bignum.c (abs2twocomp_bang): Removed.
(abs2twocomp): Take n_ret argument to return actual length.
  (rb_big_and): Follow above change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-27 14:59:50 +00:00
akr cd6912a595 * bignum.c (get2comp): Use bary_2comp.
(abs2twocomp_bang): New function.
  (abs2twocomp): New function.
  (twocomp2abs_bang): New function.
  (rb_big_and): Use abs2twocomp and twocomp2abs_bang.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-27 13:54:02 +00:00
akr c72186f4c2 * bignum.c (rb_big_pow): Retry if y is a Bignum and it is
representable as a Fixnum.
  Use rb_absint_numwords.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26 15:27:20 +00:00
nobu 86b65861cd * bignum.c (LSHIFTABLE): extract from LSHIFTX().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26 06:27:29 +00:00
akr 1457ee2ce4 * bignum.c (bigxor_int): Fix a buffer over read.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26 03:49:45 +00:00
akr 9be51267b5 * bignum.c (bigand_int): Consider negative values.
(bigor_int): The allocated bignum should have enough size
  to store long.
  This fixes (bignum fits in a BDIGIT) | (fixnum bigger than BDIGIT)
  on platforms which SIZEOF_BDIGITS < SIZEOF_LONG,
  such as LP64 with 32bit BDIGIT (no int128).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26 03:16:12 +00:00
akr 3ade5353e1 * bignum.c (bigand_int): Fix a buffer over read.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25 22:28:43 +00:00
akr 5026d0ae75 * bignum.c (bigadd_int): Fix a buffer over read.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25 21:53:58 +00:00
akr 4d906fbc14 * bignum.c (bigsub_int): Fix a buffer over read.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25 16:18:32 +00:00
akr 56435700df * bignum.c (rb_absint_singlebit_p): Use POW2_P.
(bary_pack): Ditto.
  (rb_big2str0): Ditto.
  (POW2_P): Moved to top.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25 13:47:39 +00:00
akr 7565d728b6 * bignum.c (big2dbl): Use (BDIGIT)1 instead of 1UL.
(bary_mul_normal): Remove a useless cast.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25 12:51:17 +00:00
akr b58230bcbd * bignum.c (big2ulong): "check" argument removed.
(rb_big2ulong): Follow above change.
  (rb_big2long): Ditto.
  (rb_big_rshift): Ditto.
  (rb_big_aref): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25 12:19:58 +00:00
akr d4f1cc3204 * bignum.c (rb_big2ulong_pack): Use rb_integer_pack.
(rb_big_aref): Call big2ulong with TRUE for "check" argument.
  It should be non-effective.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25 11:10:40 +00:00
akr e4e5bc118e * bignum.c (LSHIFTX): Revert r41611.
The redundant expression suppresses a warning, C4293, by Visual
  Studio.
  http://ruby-mswin.cloudapp.net/vc10-x64/ruby-trunk/log/20130625T072854Z.log.html.gz#miniruby



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25 10:36:14 +00:00
akr a8c226922d * bignum.c (big2ulong): Add a cast.
(big2ull): Add a specialized code for SIZEOF_LONG_LONG <=
  SIZEOF_BDIGITS.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25 10:04:37 +00:00
akr 8dcdfe36b7 * bignum.c (integer_unpack_single_bdigit): Use "1 + ~u" instead of
"-u" to suppress warning (C4146) by Visual Studio.
  Reported by ko1 via IRC.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25 03:46:52 +00:00