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

530 Коммитов

Автор SHA1 Сообщение Дата
akr 651f762c17 * bignum.c (DIGSPERLONG): Unused macro removed.
(DIGSPERLL): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 15:38:52 +00:00
akr 75a86e4733 * bignum.c (rb_big_aref): Less scan when the number is negative.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 15:36:18 +00:00
akr b9eeeac5c8 * bignum.c (big_shift): Avoid signed integer overflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 15:19:48 +00:00
akr f9029004ee * bignum.c (bary_mul_precheck): Use bary_small_lshift or
bary_mul_normal if xl is 1.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 15:16:23 +00:00
akr de79b66f46 * bignum.c (big_shift3): New function.
big_lshift and big_rshift are merged.
  (big_shift2): New function.
  (big_lshift): Use big_shift3.
  (big_rshift): Ditto.
  (check_shiftdown): Removed.
  (rb_big_lshift): Use big_shift2 and big_shift3.
  (rb_big_rshift): Ditto.
  (big_lshift): Removed.
  (big_rshift): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 14:03:13 +00:00
akr 0001cf6bdc * bignum.c (bary_small_lshift): Use size_t instead of long.
(bary_small_rshift): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 06:53:12 +00:00
akr e31c9896d6 * bignum.c (bary_small_lshift): Functions moved to remove
declaration.
  (bary_small_rshift): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 06:36:40 +00:00
akr 725bc0c870 * bignum.c (biglsh_bang): Removed.
(bigrsh_bang): Ditto.
  (bigmul1_toom3): Use bary_small_lshift and bary_small_rshift.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 00:28:10 +00:00
akr 973d855391 * bignum.c: Don't use toom3 after once karatsuba is choosen.
(mulfunc_t): New type.
  (bary_mul_toom3_start): Renamed from bary_mul.
  (bary_mul_karatsuba_start): Renamed from bary_mul.
  (bary_mul_balance_with_mulfunc): Renamed from bary_mul_balance and
  new argument, mulfunc, is added.
  (rb_big_mul_balance): Invoke bary_mul_balance_with_mulfunc with
  bary_mul_toom3_start.
  (bary_mul_karatsuba): Invoke bary_mul_karatsuba_start instead of
  bary_mul.
  (bary_mul_precheck): Extracted from bary_mul.
  (bary_mul_karatsuba_branch): Extracted from bary_mul.
  (bary_mul_karatsuba_start): New function to call bary_mul_precheck
  and bary_mul_karatsuba_branch.
  (bary_mul_toom3_branch): Extracted from bary_mul.
  (bary_mul_toom3_start): New function to call bary_mul_precheck and
  bary_mul_toom3_branch.
  (bary_mul): Just call bary_mul_toom3_start.
  Arguments for work memory are removed.
  (rb_cstr_to_inum): Follow the bary_mul change.
  (bigmul0): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-11 03:06:02 +00:00
akr c0796c36b5 * bignum.c: Add a static assertion for RBIGNUM_EMBED_LEN_MAX.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10 13:46:38 +00:00
akr 55e60d05dc * bignum.c (bary_2comp): Don't use bary_plus_one.
(bary_add_one): Replaced by the implementation of bary_plus_one.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10 13:06:33 +00:00
nobu c37e6ab28d bignum.c: sizeof_bdigit_dbl
* bignum.c (sizeof_bdigit_dbl): check sizeof(BDIGIT_DBL).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10 11:48:24 +00:00
akr 716c93bed1 * bignum.c (SIZEOF_BDIGIT_DBL): Add a ifdef guard for test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10 11:10:05 +00:00
nobu cc47b02969 bignum.c: select by preprocessor conditions
* bignum.c (maxpow_in_bdigit_dbl, maxpow_in_bdigit): select by
  preprocessor conditions to reduce dead code and suppress warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10 05:58:45 +00:00
akr 5ec8b6e78e * bignum.c (bary_mul): x*1 is x.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-09 15:43:48 +00:00
akr 55cbeefb2d * bignum.c (bary_mul_single): Invoke MEMZERO here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-09 13:44:49 +00:00
akr 0c620c2ec3 * bignum.c (bary_mul1): No need to invoke MEMZERO at last.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-09 13:19:59 +00:00
akr fa343a796f * bignum.c (biglsh_bang): Don't shift a BDIGIT with BITSPERDIG bits.
(bigrsh_bang): Ditto.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 16:50:04 +00:00
akr fa1e85c933 * bignum.c (bigrsh_bang): Fix bignum digits overrun.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 16:19:18 +00:00
akr be2a1ad45b * bignum.c (biglsh_bang): Fix bignum digits under-run.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 15:48:09 +00:00
akr 1ffdd828b3 * bignum.c (bary_mul): Arguments for work memory added.
(bary_mul_balance): Ditto.
  (bary_mul_karatsuba): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 13:44:34 +00:00
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