Commit Graph

16299 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 389740e1d2 Merge pull request #6377 from jbampton/add-pre-commit-hook-oxipng 2024-10-16 03:34:12 -04:00
Yukihiro "Matz" Matsumoto 62c8951787 Merge pull request #6378 from jbampton/add-pre-commit-hook-format-json 2024-10-16 03:25:58 -04:00
John Bampton e0a9a06c77 Add pre-commit hook pretty-format-json
https://github.com/pre-commit/pre-commit-hooks?tab=readme-ov-file#pretty-format-json

From the official pre-commit team a minor feature to add.

We have one JSON file at `.github/linters/mlc_config.json`.
2024-10-16 03:56:19 +10:00
John Bampton 83040c50e7 Add pre-commit hook oxipng for lossless PNG compression
Oxipng is a multithreaded lossless PNG/APNG compression optimizer.

Lossless compression is a class of data compression that allows the original data to be perfectly reconstructed from the compressed data with no loss of information.

https://en.wikipedia.org/wiki/Lossless_compression

https://github.com/shssoichiro/oxipng?tab=readme-ov-file#git-integration-via-pre-commit

Oxipng is a multithreaded PNG optimizer written in Rust

https://pre-commit.com/index.html#rust

"pre-commit will bootstrap rust if it is not present."
2024-10-16 03:10:16 +10:00
Yukihiro "Matz" Matsumoto bbce194609 Merge pull request #6374 from jbampton/add-hooks-upgrade-pre-commit 2024-10-15 08:43:54 -04:00
Yukihiro "Matz" Matsumoto 7b5608e78a mruby-rational: refactor float to rational conversion
- the function `float_decode_internal` was removed
- simplified `rational_new_f()`
- do not need to call `ldexp`
- allocate less bigint objects
2024-10-15 21:10:11 +09:00
Yukihiro "Matz" Matsumoto 51b11a6919 mruby-rational: add comments
We used `mrb_bint_mul(mrb, n, ONE)` to normalize `n`. The code confused
ChatGPT that could not read the intention.
2024-10-15 21:10:10 +09:00
Yukihiro "Matz" Matsumoto 8cfc1a4581 variable.c: fix int and mrb_bool confusion 2024-10-15 21:10:10 +09:00
Yukihiro "Matz" Matsumoto 540bd54ed3 variable.c (iv_rehash): name magic number 4 as IV_INITIAL_SIZE 2024-10-15 21:10:10 +09:00
Yukihiro "Matz" Matsumoto 06f45f8635 mruby-compiler (codegen): detect too-deep nesting error; fix #6270 2024-10-15 21:10:10 +09:00
Yukihiro "Matz" Matsumoto fa68e634a7 variable.c (mrb_exc_const_get): E_XXX_ERROR should not call const_missing
As #6359 pointed out, calling const_missing hook from E_XXX_ERROR (that
calls mrb_exc_get_id()) can be an attack vector.  Since E_XXX_ERROR is
supposed to be a defined error class, we think that the situation where
it is undefined and the const_missing hook is called should be detected
as an error; fix #6359
2024-10-15 21:09:48 +09:00
Yukihiro "Matz" Matsumoto b5801cd730 mruby-bigint (mrb_bint_new_int64): fixed a bug on the 32bit platforms 2024-10-11 14:19:33 +09:00
Yukihiro "Matz" Matsumoto 2d565d30cb Merge pull request #6376 from 513ry/master 2024-10-11 01:18:02 -04:00
siery c8203b2d52 Fix typo 2024-10-11 05:08:46 +02:00
Yukihiro "Matz" Matsumoto e29f3d64b2 mruby-compiler: stop malloc/free warnings from Visual Studio build 2024-10-11 09:10:44 +09:00
Yukihiro "Matz" Matsumoto 32a527ad6d readfloat.c: fix float to int assignment 2024-10-11 08:45:27 +09:00
Yukihiro "Matz" Matsumoto 763c9cba03 mruby-rational (int_lshift): add cast to stop overflow warning 2024-10-11 08:44:12 +09:00
Yukihiro "Matz" Matsumoto f4fdf25bb0 mruby-bigint (mrb_bint_new_int64): wrong return value 2024-10-11 08:41:51 +09:00
Yukihiro "Matz" Matsumoto 39a5d2a9d8 Merge pull request #6375 from jbampton/fix-grammar 2024-10-10 19:36:49 -04:00
John Bampton 6f97cf10e9 docs: fix grammar 2024-10-11 04:07:58 +10:00
John Bampton 95f58d8a98 Upgrade pre-commit min version; add hook; pre-commit autoupdate
https://github.com/pre-commit/pre-commit-hooks/releases/tag/v5.0.0

pre-commit-hooks now requires pre-commit>=3.2.0

https://github.com/pre-commit/pre-commit-hooks?tab=readme-ov-file#check-illegal-windows-names

https://pre-commit.com/#pre-commit-autoupdate

refs pre-commit/pre-commit#2808

https://pre-commit.com/#top_level-default_stages
2024-10-11 03:32:16 +10:00
Yukihiro "Matz" Matsumoto 6d4de2496c mruby-bigint: remove unused macros; ref #6371 2024-10-10 23:14:27 +09:00
Yukihiro "Matz" Matsumoto e21055604c mruby-bigint: separate mpz and bint functions; ref #6371
The pull-request #6371 was tight integration of mpz and bint functions.
The mpz functions take `struct RBigint*` instead of `mpz_t*`. It
decrease maintainability, in my opinion. This commit initializes `mpz_t`
from `struct RBigint*` in bint functions, so that we can keep separation
of function roles.
2024-10-10 23:04:04 +09:00
Yukihiro "Matz" Matsumoto c6dbaf702e Merge branch 'bigint-embed'; #6371 2024-10-10 23:02:10 +09:00
Yukihiro "Matz" Matsumoto 12b97ceb78 fixup! Merge branch 'bigint-embed' of https://github.com/dearblue/mruby into bigint-embed 2024-10-10 22:57:32 +09:00
Yukihiro "Matz" Matsumoto bda2fa39d2 Merge branch 'bigint-embed' of https://github.com/dearblue/mruby into bigint-embed 2024-10-10 22:31:55 +09:00
Yukihiro "Matz" Matsumoto 453e9eabf0 mruby-rational (rat_add_b): might have called rational_new_b with int
`rational_new_b` should be called with bigint objects.
2024-10-10 07:55:51 +09:00
Yukihiro "Matz" Matsumoto 5a40f6710b Update AUTHORS [ci skip] 2024-10-09 22:56:45 +09:00
Yukihiro "Matz" Matsumoto b56ad8fdee mruby-bigint: improve mpz_mul_int() and mpz_add_int()
Both functions are only called from mpz_init_set_str(). We can assume

- mpz_t is modifiable
- mpz_t is positive
- n is positive and small (n <= 36)

Those new definitions consume less memory and are slightly faster.
2024-10-08 16:09:46 +09:00
Yukihiro "Matz" Matsumoto 3b06ad4737 mruby-bigint (mpz_mul): cancel Karatsuba algorithm
We tried many times to implement the Karatsuba method to improve the
performance of multiplication of large multi-precision integers. But it
did not speed up in all cases due to the cost of memory allocation.  We
decided to go back to the basic multiplication method.

If anyone wants to take on the challenge of improving the performance of
multiplication, we welcome it.
2024-10-08 16:02:19 +09:00
Yukihiro "Matz" Matsumoto 7e6f8685a3 Merge pull request #6373 from vickash/milkvduo 2024-10-06 20:30:10 -04:00
Yukihiro "Matz" Matsumoto 77fb1b1b65 mruby-bigint (mul_karatsuba): use byte-wise addition to combine 2024-10-07 07:28:24 +09:00
vickash e99f605458 milkv config: Add directive for board variant, and optional wiringX mrbgem 2024-10-06 12:27:12 -04:00
dearblue 6366f1cbb9 Update mrbgems/mruby-bigint/core/bigint.h
Co-authored-by: John Bampton <jbampton@users.noreply.github.com>
2024-10-06 23:03:03 +09:00
vickash 115a739059 milkv config: forgot to remove "-L" in linker paths taken from official Makefile 2024-10-06 09:54:41 -04:00
dearblue 009a79b5c9 Embedding in RBigint objects
Integers up to 3 words long will no longer allocate heap space.
2024-10-06 22:28:22 +09:00
vickash d2878ef47f Comment out test-inline-struct in milv_duo config 2024-10-06 08:33:21 -04:00
vickash 491b7685db Add build config for Milk-V Duo (RISC-V Linux) board 2024-10-06 00:26:07 -04:00
Yukihiro "Matz" Matsumoto 40c7febca8 mruby-bigint (uadd): remove redundant trim() 2024-10-05 15:08:16 +09:00
Yukihiro "Matz" Matsumoto be9da7199b mruby-bigint (mul_karatsuba) improve performance
Unnecessary mpz_t u0u1 and v0v1 are removed.
2024-10-05 10:57:42 +09:00
Yukihiro "Matz" Matsumoto 8faf78f1b8 mruby-method: singleton_method() should search in superclasses
[ruby-bugs:20620](https://bugs.ruby-lang.org/issues/20620)
2024-10-04 21:37:49 +09:00
Yukihiro "Matz" Matsumoto 32aed6ad8c mruby-bigint: increase KARATSUBA_THREASHOLD to 512
Since Karatsuba algorithm is far heavier than the basic multiplication,
we have increased KARATSUBA_THREASHOLD and decreased MAX_RECURSION_DEPTH.
2024-10-04 18:10:14 +09:00
Yukihiro "Matz" Matsumoto 6820da1526 mruby-bigint (mpz_abs): use zero_p() 2024-10-04 18:10:14 +09:00
Yukihiro "Matz" Matsumoto fd8d3a8d70 mruby-bigint: use zero() to make mpz_t zero. 2024-10-04 18:10:14 +09:00
Yukihiro "Matz" Matsumoto 6274f8de43 mruby-bigint (mpz_sub): avoid data copy
Since mpz_sub() calls mpz_add() with opposite sign, refer same data from
the original, instead of copying whole data.
2024-10-04 18:10:14 +09:00
Yukihiro "Matz" Matsumoto 363754b5d1 mruby-bigint (uzero_p): check from the top, not bottom
For most of the case, the first non-zero value would be found earlier
when search starts from the top.
2024-10-04 18:10:14 +09:00
Yukihiro "Matz" Matsumoto fcc1832efc mruby-bigint (mul_karatsuba): avoid copying operand u and v 2024-09-30 18:32:26 +09:00
Yukihiro "Matz" Matsumoto 0023cbdb3d mruby-bigint (mpz_mul): use Karatsuba algorithm to improve performance 2024-09-28 05:26:40 +09:00
Yukihiro "Matz" Matsumoto 1348daa683 vm.c: save offset in a local variable in OP_BLKPUSH 2024-09-27 16:31:13 +09:00
Yukihiro "Matz" Matsumoto b94be7de5a gc.c (mark_context): no need to mark ci->blk; ref #5791
Since the passed block is referenced from the stack after the last
commit.
2024-09-26 02:57:57 +09:00