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

32 Коммитов

Автор SHA1 Сообщение Дата
Takashi Kokubun 478e0fc710
YJIT: Replace Array#each only when YJIT is enabled (#11955)
* YJIT: Replace Array#each only when YJIT is enabled

* Add comments about BUILTIN_ATTR_C_TRACE

* Make Ruby Array#each available with --yjit as well

* Fix all paths that expect a C location

* Use method_basic_definition_p to detect patches

* Copy a comment about C_TRACE flag to compilers

* Rephrase a comment about add_yjit_hook

* Give METHOD_ENTRY_BASIC flag to Array#each

* Add --yjit-c-builtin option

* Allow inconsistent source_location in test-spec

* Refactor a check of BUILTIN_ATTR_C_TRACE

* Set METHOD_ENTRY_BASIC without touching vm->running
2024-11-04 11:14:28 -05:00
BurdetteLamar 3affd43c2d [DOC] Tweaks for Array#shuffle 2024-10-16 14:12:06 -04:00
BurdetteLamar f549448e5e [DOC] Correct related for Array#shuffle! 2024-10-16 14:11:52 -04:00
Burdette Lamar 644153bfa8
[DOC] Tweaks for Array#shuffle! (#11891) 2024-10-15 14:33:59 -04:00
Burdette Lamar 628da153bb
[DOC] Tweaks for Array#sample (#11876) 2024-10-11 11:25:58 -04:00
Burdette Lamar 75ab01f3b7
[DOC] Tweaks for Array#last (#11748) 2024-10-02 10:55:19 -04:00
Burdette Lamar 5be11c1d1b
[DOC] Tweaks for Array#first (#11687) 2024-09-29 21:21:55 -04:00
Burdette Lamar 0960c8aacd
[DOC] Tweaks for Array#fetch_values (#11603) 2024-09-12 15:19:20 -04:00
BurdetteLamar 818e20359f [DOC] Tweaks for Array#each 2024-09-11 13:15:41 -04:00
Jean Boussier bc85c8d852 Implement Array#fetch_values
[Feature #20702]

Works the same way than `Hash#fetch_values` for for array.
2024-09-06 12:40:32 +02:00
Aaron Patterson 2c1655314a Revert moving things to Ruby
This is slowing down benchmarks on x86, so lets revert it for now.
2024-07-29 14:18:11 -07:00
Takashi Kokubun 174c01b80e
Remove redundant :use_block with yield (#11203) 2024-07-19 18:36:14 -07:00
Aaron Patterson b974c84606 Move Array#map to Ruby
Improves activerecord by about 1% on the interpreter:

```
before: ruby 3.4.0dev (2024-07-03T18:40:10Z master f88841b8f3) [arm64-darwin23]
after: ruby 3.4.0dev (2024-07-03T18:41:14Z ruby-map 6c0df4eb32) [arm64-darwin23]

------------  -----------  ----------  ----------  ----------  -------------  ------------
bench         before (ms)  stddev (%)  after (ms)  stddev (%)  after 1st itr  before/after
activerecord  235.2        0.8         233.6       0.7         1.01           1.01
------------  -----------  ----------  ----------  ----------  -------------  ------------
Legend:
- after 1st itr: ratio of before/after time for the first benchmarking iteration.
- before/after: ratio of before/after time. Higher is better for after. Above 1 represents a speedup.
```

Improves YJIT by about 4%:

```
before: ruby 3.4.0dev (2024-07-03T18:40:10Z master f88841b8f3) +YJIT [arm64-darwin23]
after: ruby 3.4.0dev (2024-07-03T18:41:14Z ruby-map 6c0df4eb32) +YJIT [arm64-darwin23]

------------  -----------  ----------  ----------  ----------  -------------  ------------
bench         before (ms)  stddev (%)  after (ms)  stddev (%)  after 1st itr  before/after
activerecord  142.1        1.2         137.0       0.6         1.00           1.04
------------  -----------  ----------  ----------  ----------  -------------  ------------
Legend:
- after 1st itr: ratio of before/after time for the first benchmarking iteration.
- before/after: ratio of before/after time. Higher is better for after. Above 1 represents a speedup.
```
2024-07-03 12:32:53 -07:00
Aaron Patterson 4c9134d2b2 Move Array#select to Ruby
This speeds up the mail benchmark by about 7% on the interpreter:

```
before: ruby 3.4.0dev (2024-07-03T17:01:41Z master f4b313f733) [arm64-darwin23]
after: ruby 3.4.0dev (2024-07-03T17:45:50Z ruby-select de282cacd5) [arm64-darwin23]

-----  -----------  ----------  ----------  ----------  -------------  ------------
bench  before (ms)  stddev (%)  after (ms)  stddev (%)  after 1st itr  before/after
mail   72.9         0.8         68.2        1.0         1.02           1.07
-----  -----------  ----------  ----------  ----------  -------------  ------------
Legend:
- after 1st itr: ratio of before/after time for the first benchmarking iteration.
- before/after: ratio of before/after time. Higher is better for after. Above 1 represents a speedup.
```

YJIT is about 13% faster:

```
before: ruby 3.4.0dev (2024-07-03T17:01:41Z master f4b313f733) +YJIT [arm64-darwin23]
after: ruby 3.4.0dev (2024-07-03T17:45:50Z ruby-select de282cacd5) +YJIT [arm64-darwin23]

-----  -----------  ----------  ----------  ----------  -------------  ------------
bench  before (ms)  stddev (%)  after (ms)  stddev (%)  after 1st itr  before/after
mail   51.0         0.8         45.2        0.6         1.00           1.13
-----  -----------  ----------  ----------  ----------  -------------  ------------
Legend:
- after 1st itr: ratio of before/after time for the first benchmarking iteration.
- before/after: ratio of before/after time. Higher is better for after. Above 1 represents a speedup.
```
2024-07-03 11:32:40 -07:00
Koichi Sasada 9180e33ca3 show warning for unused block
With verbopse mode (-w), the interpreter shows a warning if
a block is passed to a method which does not use the given block.

Warning on:

* the invoked method is written in C
* the invoked method is not `initialize`
* not invoked with `super`
* the first time on the call-site with the invoked method
  (`obj.foo{}` will be warned once if `foo` is same method)

[Feature #15554]

`Primitive.attr! :use_block` is introduced to declare that primitive
functions (written in C) will use passed block.

For minitest, test needs some tweak, so use
ea9caafc07
for `test-bundled-gems`.
2024-04-15 12:08:07 +09:00
Nobuyoshi Nakada 3dccb716da
Use `defined?(yield)` and `SIZED_ENUMERATOR`
Prefer built-in features over method calls that may be overridden.
2024-02-17 23:28:00 +09:00
Burdette Lamar 65f5435540
[DOC] Doc compliance (#9955) 2024-02-14 10:47:42 -05:00
Takashi Kokubun c84237f953
Rewrite Array#each in Ruby using Primitive (#9533) 2024-01-23 20:09:57 +00:00
Burdette Lamar 8c5b9ebf71
[DOC] Improve doc guide compliance (#8221) 2023-08-15 14:43:58 -04:00
Nobuyoshi Nakada 0e5aecea11
[DOC] Move docs of `Array#first` and `Array#last` to array.rb 2023-05-10 15:47:39 +09:00
Koichi Sasada 0112a5b342 `Array#first` and `Array#last` in Ruby 2023-03-23 14:03:12 +09:00
Koichi Sasada a24eeee556 Use `Primitive.mandatory_only?` for `Array#sample` 2021-11-15 15:58:56 +09:00
Nobuyoshi Nakada f8bf766877
[DOC] Additional to Array#sample [ci skip]
* The requirement to the +n+ argument.
* The order of the result array.  [Misc #14147]
2021-09-22 14:17:09 +09:00
Yusuke Endoh a237617a5b array.rb: Remove unnecessary phrase from rdoc
A fix to 54fb8fb62a
2020-11-12 16:59:59 +09:00
Yusuke Endoh a02ba60466 array.rb: show examples whether `Array#shuffle!` has side effect or not
Partially revert 54fb8fb62a
2020-11-12 16:59:59 +09:00
Burdette Lamar 54fb8fb62a
Comply with guide for method doc: array.c (#3506)
Methods:

    any?
    all?
    one?
    none?
    sum
    shuffle!
    shuffle
    sample
2020-09-02 14:02:34 -05:00
Nobuyoshi Nakada 63aadc237f [Feature #16254] Use `Primitive.func` style 2020-06-19 18:46:55 +09:00
Nobuyoshi Nakada d863f4bccd [Feature #16254] Use `__builtin.func` style 2020-06-19 18:46:55 +09:00
Nobuyoshi Nakada a2e215fea4
Removed useless shebang and executable bit [ci skip] 2020-02-01 23:25:46 +09:00
Nobuyoshi Nakada b1eae5e15e
Cleaned an excess semicolon up [ci skip]
which has not been removed when translated from C.
2020-01-27 09:49:13 +09:00
Nobuyoshi Nakada d4e1d4e94e
Moved Array#sample to rbinc 2020-01-26 19:45:58 +09:00
Nobuyoshi Nakada 29eb1b1602
Moved Array#shuffle and Array#shuffle! to rbinc 2020-01-26 19:40:34 +09:00