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

848 Коммитов

Автор SHA1 Сообщение Дата
tompng 0ff2c7fe6f Faster Integer.sqrt for large bignum
Integer.sqrt uses Newton's method.
This pull request reduces the precision which was unnecessarily high in each calculation step.
2024-03-18 13:52:27 +09:00
Jean Boussier d4f3dcf4df Refactor VM root modules
This `st_table` is used to both mark and pin classes
defined from the C API. But `vm->mark_object_ary` already
does both much more efficiently.

Currently a Ruby process starts with 252 rooted classes,
which uses `7224B` in an `st_table` or `2016B` in an `RArray`.

So a baseline of 5kB saved, but since `mark_object_ary` is
preallocated with `1024` slots but only use `405` of them,
it's a net `7kB` save.

`vm->mark_object_ary` is also being refactored.

Prior to this changes, `mark_object_ary` was a regular `RArray`, but
since this allows for references to be moved, it was marked a second
time from `rb_vm_mark()` to pin these objects.

This has the detrimental effect of marking these references on every
minors even though it's a mostly append only list.

But using a custom TypedData we can save from having to mark
all the references on minor GC runs.

Addtionally, immediate values are now ignored and not appended
to `vm->mark_object_ary` as it's just wasted space.
2024-03-06 15:33:43 -05:00
Yusuke Endoh 25d74b9527 Do not include a backtick in error messages and backtraces
[Feature #16495]
2024-02-15 18:42:31 +09:00
Peter Zhu 6906e502f9 Replace assert with RUBY_ASSERT in bignum.c
assert does not print the bug report, only the file and line number of
the assertion that failed. RUBY_ASSERT prints the full bug report, which
makes it much easier to debug.
2024-02-12 15:07:47 -05:00
Nobuyoshi Nakada c30b8ae947
Adjust styles and indents [ci skip] 2024-01-08 00:50:41 +09:00
git 94788a6d13 * expand tabs. [ci skip]
Please consider using misc/expand_tabs.rb as a pre-commit hook.
2023-06-30 14:59:34 +00:00
Nobuyoshi Nakada 7a0a218dff
Compile debugging code for integer pack always 2023-06-30 23:59:04 +09:00
Matt Valentine-House 026321c5b9 [Feature #19474] Refactor NEWOBJ macros
NEWOBJ_OF is now our canonical newobj macro. It takes an optional ec
2023-04-06 11:07:16 +01:00
Takashi Kokubun 233ddfac54 Stop exporting symbols for MJIT 2023-03-06 21:59:23 -08:00
Jean Boussier 3f54d09a5b bignum.c: rb_int_parse_cstr handle `0` strings
[Bug #19390]

We shouldn't check the string length when skipping zeros, as the
string might only contains zero characters, resulting in an empty string.
2023-01-30 14:42:40 +01:00
Nobuyoshi Nakada 1cdf8ab07b
[Bug #19323] Raise `RangeError` instead of integer overflow 2023-01-08 20:54:48 +09:00
Nobuyoshi Nakada 5ccb625fbb
Use `roomof` macro for rounding up divisions 2022-10-14 19:23:25 +09:00
Takashi Kokubun 5b21e94beb Expand tabs [ci skip]
[Misc #18891]
2022-07-21 09:42:04 -07:00
Nobuyoshi Nakada 9108db961d
Fix the condition when a new buffer is needed without GMP 2022-06-02 10:29:53 +09:00
Nobuyoshi Nakada a080651f46
Disable GMP by -DUSE_GMP=0 2022-05-20 19:05:35 +09:00
S-H-GAMELINKS 5b467400d2 [DOC]Some link prefix replace 2022-04-09 17:43:46 +09:00
Nobuyoshi Nakada 5ca51ddde8
[DOC] Integer#coerce deals with also Float 2021-12-29 11:50:28 +09:00
Nobuyoshi Nakada 27765a7502
Fix the warning in rb_big2dbl, Bignum is no longer defined 2021-12-29 11:49:06 +09:00
Nobuyoshi Nakada 40e7aefeba Remove obsolete Fixnum and Bignum 2021-12-28 18:35:03 +09:00
Peter Zhu aeae6e2842 [Feature #18290] Remove all usages of rb_gc_force_recycle
This commit removes usages of rb_gc_force_recycle since it is a burden
to maintain and makes changes to the GC difficult.
2021-11-08 14:05:54 -05:00
Nobuyoshi Nakada 373b399823 bary_mul_balance_with_mulfunc: move working buffer allocation
Move the allocation of working buffer before the loop.
2021-10-12 00:45:14 +09:00
Nobuyoshi Nakada 6fa1af7ee5 bary_mul_balance_with_mulfunc: consitify invariant variables 2021-10-12 00:45:14 +09:00
S.H b8c3a84bdd
Refactor and Using RBOOL macro 2021-09-15 08:11:05 +09:00
S.H 3fd8531331
Remove uneeded initialize local variable (#4818) 2021-09-13 23:22:01 -07:00
S-H-GAMELINKS 032534dbdf Using RB_BIGNUM_TYPE_P macro 2021-09-11 09:13:24 +09:00
S-H-GAMELINKS bdd6d8746f Replace RBOOL macro 2021-09-05 23:01:27 +09:00
Nobuyoshi Nakada 04be8e84db
Use C99-defined macros to classify a floating-point number 2021-08-27 12:41:30 +09:00
Nobuyoshi Nakada c38c2d8ee2 Moved exported symbols in internal/util.h to ruby/util.h
[Feature #18051]
2021-08-24 10:37:41 +09:00
Nobuyoshi Nakada 836b7047a6 Suppress unused-variable warnings when DEBUG_INTEGER_PACK 2021-08-09 11:21:56 +09:00
S.H 178a2a1a12
Remove unneeded declarations in bignum.c 2021-03-20 20:55:58 +09:00
Yusuke Endoh dd65aa95f9 bignum.c: Make sure the argument of LONG2FIX is long
... because BDIGIT_DBL may be long long. POSFIXABLE and NEGFIXABLE
ensures that the value is representable as long, but it failed to build
on emscripten with -Werror -Wshorten-64-to-32.
2021-01-23 16:05:33 +09:00
Marcus Stollsteimer 3108ad7bf3 [DOC] Fix grammar: "is same as" -> "is the same as" 2021-01-05 15:13:53 +01:00
Nobuyoshi Nakada fb8f011422
Fixed indefinite articles before "Integer" [ci skip] 2020-12-21 01:19:55 +09:00
Yusuke Endoh eb21e8add3 bignum.c (bary_sparse_p): do not comsume Random::DEFAULT
It uses random to determine if the bignum is sparse or not.
It is arguable if three-digit samples are enough or not to determine it,
but anyway, consuming Random source implicitly is not good.

I introduced the random sampling mechanism, and I don't know any
significant reason to do so.  So, let's remove it.
This change makes the sampling points fixed: 40th, 50th, and 60th
percentiles.
2020-10-12 13:45:32 +09:00
Yusuke Endoh 8a39e6d653 bignum.c (rb_int_powm): Integer#pow(0, 1) should return 0
... instead of 1 because it requires "modulo 1".  [Bug #17257]
2020-10-12 13:42:48 +09:00
Kazuhiro NISHIYAMA 946cd6c534
Use https instead of http 2020-07-28 19:51:54 +09:00
卜部昌平 e60cd14d85 ON_DEBUG: delete unused macro
This is no longer used.
2020-07-14 13:19:55 +09:00
卜部昌平 9ec4f1f205 rb_big_aref: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
2020-06-29 11:05:41 +09:00
卜部昌平 184f0ab4c9 rb_int_parse_cstr: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
2020-06-29 11:05:41 +09:00
卜部昌平 5a7c0dd038 str2big_scan_digits: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
2020-06-29 11:05:41 +09:00
卜部昌平 4dfc2f2e3d bary_mul_karatsuba_branch: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
2020-06-29 11:05:41 +09:00
Nobuyoshi Nakada b8fadf3a6b
Respect BIGNUM_DEBUG defined by command line option
And fixed typo in compilers.yml.
2020-05-29 02:43:30 +09:00
卜部昌平 9e41a75255 sed -i 's|ruby/impl|ruby/internal|'
To fix build failures.
2020-05-11 09:24:08 +09:00
卜部昌平 d7f4d732c1 sed -i s|ruby/3|ruby/impl|g
This shall fix compile errors.
2020-05-11 09:24:08 +09:00
卜部昌平 9e6e39c351
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
2020-04-08 13:28:13 +09:00
Nobuyoshi Nakada 5b287481be
Removed non-RUBY_INTEGER_UNIFICATION code 2020-03-21 16:59:55 +09:00
Nobuyoshi Nakada 6f0446785b
Leave power cache table initialized as Qfalse 2020-03-21 16:42:19 +09:00
卜部昌平 aa44b29030 suppress uninitialized variable warnings
Starting GCC 7, warnings about uninitialized variables are issued around
them.  Such warnings could be false positives (all versions of clang do
not warn), but adding initializers there could never be bad things.
2020-03-04 12:30:42 +09:00
Bernhard F. Brodowsky 07c98537ca
Clarified documentation in rb_integer_unpack [ci skip]
I struggled figuring out which of the pack/unpack functions goes into which direction and the two first sentences were of the documentation were:
* Import an integer into a buffer.
* Export an integer into a buffer.

It sounds like both of them go from a ruby integer to a buffer because both use "into". So I fixed it and went to "Import an integer from a buffer". I find this much more clear.
2020-02-08 09:57:15 +09:00
Kenta Murata 076f24c227
bignum.c: extract bdigits_to_mpz and bdigits_from_mpz (#2805) 2020-01-01 22:55:12 +09:00