summaryrefslogtreecommitdiffhomepage
path: root/mrblib
AgeCommit message (Collapse)Author
2021-11-28Align "wrong number of arguments" messagesdearblue
Make "N for M" into the form "given N, expected M". As I worked, I noticed that the `argnum_error()` function had a part to include the method name in the message. I think this part is no longer needed by https://github.com/mruby/mruby/pull/5394. - Before this patch ```console % bin/mruby -e '[1, 2, 3].each 0' trace (most recent call last): [1] -e:1 -e:1:in each: 'each': wrong number of arguments (1 for 0) (ArgumentError) ``` - After this patch ```console % bin/mruby -e '[1, 2, 3].each 0' trace (most recent call last): [1] -e:1 -e:1:in each: wrong number of arguments (given 1, expected 0) (ArgumentError) ```
2021-11-24Fixed some methods where keyword arguments are not passeddearblue
2021-09-01string.c: implement `__sub_replace()` in C.Yukihiro "Matz" Matsumoto
To reduce number of string allocation.
2021-09-01string.rb: avoid internal `__to_str` calls.Yukihiro "Matz" Matsumoto
`__to_str` was a mere type check method despite its name.
2021-08-03Replace `fixnum` references with `int`.Yukihiro "Matz" Matsumoto
The `Fixnum` class is no longer provided by `mruby`.
2021-07-05Make `LocalJumpError` a direct subclass of `StandardError`.Yukihiro "Matz" Matsumoto
To be compatible with CRuby.
2021-05-14range.c: implement (part of) `Range#to_a` in C.Yukihiro "Matz" Matsumoto
Mostly for performance reason.
2021-05-13Simplify module inclusion for `Array`, `Hash` and `Range`.Yukihiro "Matz" Matsumoto
2021-05-12range.rb: add `Range#entries` as an alias to `Range#to_a`.Yukihiro "Matz" Matsumoto
2021-05-12array.rb: add `Array#entries` as an alias to `Array#to_a`.Yukihiro "Matz" Matsumoto
The performance of `Enumerable#entries` are significantly slower than `Array#to_a`.
2021-05-11Remove the obsolete term `Fixnum`.Yukihiro "Matz" Matsumoto
Except for compatibility code.
2021-04-28string.{c,rb}: fix type of return values from some methods as Ruby3.0Yukihiro "Matz" Matsumoto
When the receiver is the instance of subclass of `String`. - `String#each_char` - `String#each_line` - `String#partition`
2021-04-24Skip tests that use `Float` inside; ref #5421Yukihiro "Matz" Matsumoto
2021-04-16feat(CI): add the GitHub Super LinterJohn Bampton
The GitHub Super Linter is a more robust and better supported tool than the current GitHub Actions we are using. Running these checks: ERROR_ON_MISSING_EXEC_BIT: true VALIDATE_BASH: true VALIDATE_BASH_EXEC: true VALIDATE_EDITORCONFIG: true VALIDATE_MARKDOWN: true VALIDATE_SHELL_SHFMT: true VALIDATE_YAML: true https://github.com/marketplace/actions/super-linter https://github.com/github/super-linter Added the GitHub Super Linter badge to the README. Also updated the pre-commit framework and added more documentation on pre-commit. Added one more pre-commit check: check-executables-have-shebangs Added one extra check for merge conflicts to our GitHub Actions. EditorConfig and Markdown linting. Minor grammar and spelling fixes. Update linter.yml
2021-03-04Remove unused `mrblib/init_mrblib.c`KOBAYASHI Shuji
2020-12-15refactor: remove trailing whitespace from C, Header, Ruby and YAML filesJohn Bampton
Lint
2020-11-25Move inline `iseq` in `array.c` to `array.rb`.Yukihiro "Matz" Matsumoto
There's no efficiency difference since `cdump` is implemented.
2020-11-24Fix compiler errors from `MRB_NO_FLOAT`; #5185Yukihiro "Matz" Matsumoto
Also added `no-float.rb` target in `build_config`.
2020-11-21Move some `.rake` files to `tasks` directory for consistencyKOBAYASHI Shuji
2020-11-20Refactor `mrblib/mrblib.rake`KOBAYASHI Shuji
2020-11-14Scan source files only from `cdump` enabled gems.Yukihiro "Matz" Matsumoto
2020-11-10Reduce memory usage of Hash objectKOBAYASHI Shuji
## Implementation Summary * Change entry list from segmented list to flat array. * Change value of hash bucket from pointer to entry to index of entry list, and represent it by variable length bits according to capacity of hash buckets. * Store management information about entry list and hash table to `struct RHash` as much as possible. ## Benchmark Summary Only the results of typical situations on 64-bit Word-boxing are present here. For more detailed information, including consideration, see below (although most of the body is written in Japanese). * https://shuujii.github.io/mruby-hash-benchmark ### Memory Usage Lower value is better. | Hash Size | Baseline | New | Factor | |----------:|--------------:|--------------:|-----------:| | 16 | 344B | 256B | 0.74419x | | 40 | 1,464B | 840B | 0.57377x | | 200 | 8,056B | 3,784B | 0.46971x | | 500 | 17,169B | 9,944B | 0.57949x | ### Performance Higher value is better. #### `mrb_hash_set` | Hash Size | Baseline | New | Factor | |----------:|--------------:|--------------:|-----------:| | 16 | 1.41847M i/s | 1.36004M i/s | 0.95881x | | 40 | 0.39224M i/s | 0.31888M i/s | 0.81296x | | 200 | 0.03780M i/s | 0.04290M i/s | 1.13494x | | 500 | 0.01225M i/s | 0.01314M i/s | 1.07275x | #### `mrb_hash_get` | Hash Size | Baseline | New | Factor | |----------:|--------------:|--------------:|-----------:| | 16 | 26.05920M i/s | 30.19543M i/s | 1.15872x | | 40 | 44.26420M i/s | 32.75781M i/s | 0.74005x | | 200 | 44.55171M i/s | 31.56926M i/s | 0.70860x | | 500 | 39.19250M i/s | 29.73806M i/s | 0.75877x | #### `mrb_hash_each` | Hash Size | Baseline | New | Factor | |----------:|--------------:|--------------:|-----------:| | 16 | 25.11964M i/s | 30.34167M i/s | 1.20789x | | 40 | 11.74253M i/s | 13.25539M i/s | 1.12884x | | 200 | 2.01133M i/s | 2.97214M i/s | 1.47770x | | 500 | 0.87411M i/s | 1.21178M i/s | 1.38631x | #### `Hash#[]=` | Hash Size | Baseline | New | Factor | |----------:|--------------:|--------------:|-----------:| | 16 | 0.50095M i/s | 0.56490M i/s | 1.12764x | | 40 | 0.19132M i/s | 0.18392M i/s | 0.96129x | | 200 | 0.03624M i/s | 0.03256M i/s | 0.89860x | | 500 | 0.01527M i/s | 0.01236M i/s | 0.80935x | #### `Hash#[]` | Hash Size | Baseline | New | Factor | |----------:|--------------:|--------------:|-----------:| | 16 | 11.53211M i/s | 12.78806M i/s | 1.10891x | | 40 | 15.26920M i/s | 13.37529M i/s | 0.87596x | | 200 | 15.28550M i/s | 13.36410M i/s | 0.87430x | | 500 | 14.57695M i/s | 12.75388M i/s | 0.87494x | #### `Hash#each` | Hash Size | Baseline | New | Factor | |----------:|--------------:|--------------:|-----------:| | 16 | 0.30462M i/s | 0.27080M i/s | 0.88898x | | 40 | 0.12912M i/s | 0.11704M i/s | 0.90642x | | 200 | 0.02638M i/s | 0.02402M i/s | 0.91071x | | 500 | 0.01066M i/s | 0.00959M i/s | 0.89953x | #### `Hash#delete` | Hash Size | Baseline | New | Factor | |----------:|--------------:|--------------:|-----------:| | 16 | 7.84167M i/s | 6.96419M i/s | 0.88810x | | 40 | 6.91292M i/s | 7.41427M i/s | 1.07252x | | 200 | 3.75952M i/s | 7.32080M i/s | 1.94727x | | 500 | 2.10754M i/s | 7.05963M i/s | 3.34970x | #### `Hash#shift` | Hash Size | Baseline | New | Factor | |----------:|--------------:|--------------:|-----------:| | 16 | 14.66444M i/s | 13.18876M i/s | 0.89937x | | 40 | 11.95124M i/s | 11.10420M i/s | 0.92913x | | 200 | 5.53681M i/s | 7.88155M i/s | 1.42348x | | 500 | 2.96728M i/s | 5.40405M i/s | 1.82121x | #### `Hash#dup` | Hash Size | Baseline | New | Factor | |----------:|--------------:|--------------:|-----------:| | 16 | 0.15063M i/s | 5.37889M i/s | 35.71024x | | 40 | 0.06515M i/s | 3.38196M i/s | 51.91279x | | 200 | 0.01359M i/s | 1.46538M i/s | 107.84056x | | 500 | 0.00559M i/s | 0.75411M i/s | 134.88057x | ### Binary Size Lower value is better. | File | Baseline | New | Factor | |:-----------|--------------:|--------------:|----------:| | mruby | 730,408B | 734,176B | 1.00519x | | libmruby.a | 1,068,134B | 1,072,846B | 1.00441x | ## Other Fixes The following issues have also been fixed in the parts where there was some change this time. * [Heap use-after-free in `Hash#value?`](https://gist.github.com/shuujii/30e4fcd5844a4112a0ecd4a5b3483101#file-heap-use-after-free-in-hash-value-md) * [Heap use-after-free in `ht_hash_equal`](https://gist.github.com/shuujii/30e4fcd5844a4112a0ecd4a5b3483101#file-heap-use-after-free-in-ht_hash_equal-md) * [Heap use-after-free in `ht_hash_func`](https://gist.github.com/shuujii/30e4fcd5844a4112a0ecd4a5b3483101#file-heap-use-after-free-in-ht_hash_func-md) * [Heap use-after-free in `mrb_hash_merge`](https://gist.github.com/shuujii/30e4fcd5844a4112a0ecd4a5b3483101#file-heap-use-after-free-in-mrb_hash_merge-md) * [Self-replacement does not work for `Hash#replace`](https://gist.github.com/shuujii/30e4fcd5844a4112a0ecd4a5b3483101#file-self-replacement-does-not-work-for-hash-replace-md) * [Repeated deletes and inserts increase memory usage of `Hash`](https://gist.github.com/shuujii/30e4fcd5844a4112a0ecd4a5b3483101#file-repeated-deletes-and-inserts-increase-memory-usage-of-hash-md) * [`Hash#rehash` does not reindex completely](https://gist.github.com/shuujii/30e4fcd5844a4112a0ecd4a5b3483101#file-hash-rehash-does-not-reindex-completely-md) * `mrb_hash_delete_key` does not cause an error for frozen object * `mrb_hash_new_capa` does not allocate required space first * [`mrb_os_memsize_of_hash_table` result is incorrect](https://github.com/mruby/mruby/pull/5032#discussion_r457994075)
2020-11-05Add `Array.new([1,2,3])` initialization.Yukihiro "Matz" Matsumoto
2020-10-15Merge branch 'work_for_merge' of https://github.com/zubycz/mruby into ↵Yukihiro "Matz" Matsumoto
zubycz-work_for_merge
2020-10-13Introduce endless range (a part of #5085)taiyoslime
Co-Authored-By: n4o847 <[email protected]> Co-Authored-By: smallkirby <[email protected]>
2020-10-12Reorganize `Integer` system.Yukihiro "Matz" Matsumoto
- Integrate `Fixnum` and `Integer` - Remove `Integral` - `int / int -> int` - Replace `mrb_fixnum()` to `mrb_int()` - Replace `mrb_fixnum_value()` to `mrb_int_value()`. - Use `mrb_integer_p()` instead of `mrb_fixnum_p()`
2020-10-12Make division by zero cause `ZeroDivisionError`.Yukihiro "Matz" Matsumoto
As described in ISO 15.2.30.
2020-10-12Integrate `Fixnum` class into `Integer` classdearblue
* The `Fixnum` constant is now an alias for the `Integer` class. * Remove `struct mrb_state::fixnum_class` member. If necessary, use `struct mrb_state::integer_class` instead.
2020-10-12Generate C struct from `irep` instead of binary dump.Yukihiro "Matz" Matsumoto
2020-07-22Define `Array#to_a` to avoid unnecessary loops.Yukihiro "Matz" Matsumoto
2020-07-22Small comment fix in `mrblib/array.c`.Yukihiro "Matz" Matsumoto
2020-06-20Move definition of `BasicObject#!=` to `mrblib`.Yukihiro "Matz" Matsumoto
C implementation used `mrb_funcall()` that bypassed many optimization.
2020-05-09Fix some `Hash` methods are inconsistent with `values`KOBAYASHI Shuji
Inconsistent when hash has duplicate key. ### Example ```ruby # example.rb keys = (1..3).map{[_1]} h = keys.to_h{[_1, _1[0]]} keys[0][0] = 2 p h.values p h.each_value.to_a p h ``` #### Before this patch: ```console $ bin/mruby example.rb [1, 2, 3] [1, 1, 3] {[2]=>1, [2]=>1, [3]=>3} ``` #### After this patch (same as Ruby) ```console $ bin/mruby example.rb [1, 2, 3] [1, 2, 3] {[2]=>1, [2]=>2, [3]=>3} ```
2019-12-27Use Rake DSL instead of commands of `FileUtils`KOBAYASHI Shuji
- Respect `--verbose(-v)` and `--dry-run(-n)` options. - Silence warnings to keyword arguments on Ruby 2.7.
2019-09-12Merge pull request #4527 from lopopolo/string-each-line-paragraph-modeYukihiro "Matz" Matsumoto
Add paragraph mode to String#each_line in mrblib
2019-08-17Implement `Array#each` using inline mruby bytecode.Yukihiro "Matz" Matsumoto
2019-08-16Implement `Class#new` using inline mruby bytecode.Yukihiro "Matz" Matsumoto
2019-08-14Integrate `kazuho/mruby-class-new-fiber-safe` in the master.Yukihiro "Matz" Matsumoto
Avoid calling `initialize` via `mrb_funcall`, which cause `cross C boundary` error from Fibers started in the method.
2019-08-10`Enumerable#reject`, etc. should return `Enumerable` without blockKOBAYASHI Shuji
2019-07-17Fixed a bug in #4034Yukihiro "Matz" Matsumoto
2019-07-17Merge branch 'master' into i110/inspect-recursionYukihiro "Matz" Matsumoto
2019-07-13`Enumerable#detect` {and `#find`} should call `ifnone`; fix #4484Yukihiro "Matz" Matsumoto
It's an error in ISO specification; 15.3.2.2.4 and 15.3.2.2.7
2019-07-07Fix `Numeric#step` to infinity; ref. #4555KOBAYASHI Shuji
2019-06-29Replace `String#[]=` method by C implementsdearblue
The purpose is to eliminate string objects that are temporarily created during processing.
2019-06-25Unify loops to minimize bytecode sizeRyan Lopopolo
2019-06-23Use explicit block parameterRyan Lopopolo
2019-06-23Optimize String#each_lineRyan Lopopolo
2019-06-22Speed up base case by 2xRyan Lopopolo
Make non-paragraph mode twice as fast. Performance is within a factor of 2 of the original implementation.
2019-06-22Add paragraph mode to String#each_line in mrblibRyan Lopopolo
mruby/mruby#4511 demonstrated an infinite loop in `String#each_line` when given an empty string separator. In MRI, an empty separator places String#each_line in paragraph mode, where the String is separated on successive runs of newlines. In paragraph mode, the String `"abc\n\n\ndef\nxyz"` is split into `["abc\n\n\n", "def\nxyz"]`. This commit makes the String#each_line implementation as close to ruby/spec compliant as possible given the limitations of mruby core. With this patch, the following specs fail for `String#each_line`: - uses `$/` as the separator when none is given (can be fixed by aliasing and redefining the method to use $/ as the default value of separator in mruby-io) - when no block is given returned Enumerator size should return nil (`Enumerator#size` is not supported on mruby) - tries to convert the separator to a string using to_str (`String#to_str` is not implemented on mruby) This patch has similar memory consumption compared to the prior implementation and is takes 4x the time the prior implementation takes to execute: ```console /usr/bin/time -l ./bin/mruby -e '("aaa\n\nbbbbb\n\n\n\n\ncccc" * 100000).each_line("\n") { }'; ```
2019-06-04Fix typo in `mrblib/range.rb` [ci skip]KOBAYASHI Shuji