83249 Commits

Author SHA1 Message Date
Jeremy Evans
2217e08340
Optimize compilation of large literal arrays
To avoid stack overflow, Ruby splits compilation of large arrays
into smaller arrays, and concatenates the small arrays together.
It previously used newarray/concatarray for this, which is
inefficient.  This switches the compilation to use pushtoarray,
which is much faster. This makes almost all literal arrays only
allocate a single array.

For cases where there is a large amount of static values in the
array, Ruby will statically compile subarrays, and previously
added them using concatarray.  This switches to concattoarray,
avoiding an array allocation for the append.

Keyword splats are also supported in arrays, and ignored if the
keyword splat is empty.  Previously, this used newarraykwsplat and
concatarray.  This still uses newarraykwsplat, but switches to
concattoarray to save an allocation.  So large arrays with keyword
splats can allocate 2 arrays instead of 1.

Previously, for the following array sizes (assuming local variable
access for each element), Ruby allocated the following number of
arrays:

  1000 elements: 7 arrays
 10000 elements: 79 arrays
100000 elements: 781 arrays

With these changes, only a single array is allocated (or 2 for a
large array with a keyword splat.

Results using the included benchmark:

```
                       array_1000
            miniruby:     34770.0 i/s
   ./miniruby-before:     10511.7 i/s - 3.31x  slower

                      array_10000
            miniruby:      4938.8 i/s
   ./miniruby-before:       483.8 i/s - 10.21x  slower

                     array_100000
            miniruby:       727.2 i/s
   ./miniruby-before:         4.1 i/s - 176.98x  slower
```

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2024-01-27 10:16:52 -08:00
Masato Ohba
0bac390e07 [rubygems/rubygems] Bump Ruby version to be used in bundle gem template
since 2.6 and 2.7 are EOL and bundler dropped their support by https://github.com/rubygems/rubygems/pull/7116.

https://github.com/rubygems/rubygems/commit/b562d9a822
2024-01-27 15:50:24 +00:00
Kevin Newton
5d9d07a491 [ruby/prism] Bring back #arg_rest local
https://github.com/ruby/prism/commit/9b6907b727
2024-01-27 14:13:35 +00:00
S.H
9b40f42c22
Introduce NODE_ENCODING
`__ENCODING__ `was managed by `NODE_LIT` with Encoding object. 

Introduce `NODE_ENCODING` for
1. `__ENCODING__` is detectable from AST Node.
2. Reduce dependency Ruby object for parse.y
2024-01-27 08:11:10 +00:00
yui-knk
68b9a32a62 bvar is not NODE but ID
Before this commit `ruby -y -e 'tap {|;x, y|}'` failed with SEGV.
This change fixes it.
2024-01-27 16:50:35 +09:00
yui-knk
70cb0a4dec Lrama v0.6.2 2024-01-27 11:51:27 +09:00
Kevin Newton
cb9a47f2ac [PRISM] Fix branchif ADD_INSN1 2024-01-26 16:46:31 -05:00
Benoit Daloze
de135bc247 [ruby/prism] Add level to warnings and errors to categorize them
* Fixes https://github.com/ruby/prism/issues/2082

https://github.com/ruby/prism/commit/7a74576357
2024-01-26 21:34:34 +00:00
Kevin Newton
bcafd28a3e [ruby/prism] Symbol encoding follow-up
Ensure we don't accidentally parse the symbol encoding twice, and
ensure we parse it in every circumstance we need to by requiring
it as a parameter.

https://github.com/ruby/prism/commit/9cea31c785
2024-01-26 21:14:59 +00:00
Peter Zhu
a120529020 [PRISM] Fix loop in rescue blocks
Fixes ruby/prism#2250.

Co-Authored-By: Kevin Newton <kddnewton@gmail.com>
2024-01-26 16:07:24 -05:00
Peter Zhu
59bb78ebd0 [PRISM] Fix for s390x
On s390x, a long is 8 bytes. st_data_t is an unsigned long but
pm_constant_id_t is a 4 byte integer. We need to cast it to st_data_t
when passing it to ST functions.
2024-01-26 15:41:06 -05:00
Kevin Menard
2a509787cb [ruby/prism] Track whether a Symbol should have its encoding changed from the source encoding.
Ruby sets a Symbol literal's encoding to US-ASCII if the symbols consists only of US ASCII code points. Character escapes can also lead a Symbol to have a different encoding than its source's encoding.

https://github.com/ruby/prism/commit/f315660b31
2024-01-26 20:15:19 +00:00
Peter Zhu
3d996e827f [PRISM] Keyword arguments incorrectly passed as mutable
Fixes ruby/prism#2279.
2024-01-26 14:58:29 -05:00
Kevin Newton
99d91838e0 [ruby/prism] Update src/prism.c
https://github.com/ruby/prism/commit/91b5550726
2024-01-26 18:35:54 +00:00
Haldun Bayhantopcu
7d356b8f0e [ruby/prism] Fix multiple assigns with newlines
https://github.com/ruby/prism/commit/b4ba41bdcd
2024-01-26 18:35:54 +00:00
Haldun Bayhantopcu
9a7637da2d [ruby/prism] Add tests
https://github.com/ruby/prism/commit/b9ebf987bd
2024-01-26 18:32:31 +00:00
Haldun Bayhantopcu
b0e10345d3 [ruby/prism] Fix parsing calls with labels
https://github.com/ruby/prism/commit/3db7849a31
2024-01-26 18:32:30 +00:00
Max Prokopiev
8e5bc8f7c2 [ruby/prism] Change binding power for modifiers in case-in nodes
https://github.com/ruby/prism/commit/c31eeba54c
2024-01-26 18:32:02 +00:00
Hiroshi SHIBATA
1949a04f81
vcpkg x-update-baseline for updating baseline commit hash uses 2-spaces indent 2024-01-26 17:46:39 +09:00
Jeremy Evans
771a2f039b Fix incorrect use of VM_CALL_KW_SPLAT_MUT in zsuper with keyword splat
For zsuper calls with a keyword splat but no actual keywords, the
keyword splat is passed directly, so it cannot be mutable, because
if the callee accepts a keyword splat, changes to the keyword splat
by the callee would be reflected in the caller.

While here, simplify the logic when the method supports
literal keywords.  I don't think it is possible for
a method with has_kw param flags to not have keywords, so add an
assertion for that, and set VM_CALL_KW_SPLAT_MUT in a single place.
2024-01-25 20:43:42 -08:00
Hiroshi SHIBATA
395a240b7c
Try to use irb instead of rubygems for completion test
I'm not sure why OpenBSD suggest `rubygems_plugin` file for this.

https://rubyci.s3.amazonaws.com/openbsd-current/ruby-master/log/20240126T013005Z.fail.html.gz

It seems environmental issue, not irb.
2024-01-26 13:40:05 +09:00
Hiroshi SHIBATA
f9bf7d531b
Added vcpkg manifest for windows build environment.
"builtin-baseline": "53bef8994c541b6561884a8395ea35715ece75db" is 2024.01.12
released version of vcpkg.

https://github.com/microsoft/vcpkg/releases/tag/2024.01.12
2024-01-26 12:38:01 +09:00
Takashi Kokubun
7567e4e1e1
YJIT: Fix exits on splatkw instruction (#9711) 2024-01-26 00:22:27 +00:00
git
30b4070ffa Update bundled gems list at b822f9f6fc5a00ec08dbc698b98458 [ci skip] 2024-01-25 23:48:01 +00:00
Soutaro Matsumoto
b822f9f6fc
Bundle rbs-3.4.3 (#9702)
* Bundle rbs-3.4.3
* Remove rbs from `TEST_BUNDLED_GEMS_ALLOW_FAILURES` list
* Add the failing tests to `rbs_skip_tests`
2024-01-26 08:47:29 +09:00
Peter Zhu
5bd6949151 [PRISM] Add raw option to assert_prism_eval 2024-01-25 18:15:45 -05:00
Takashi Kokubun
2034e6ad5a
YJIT: Support concattoarray and pushtoarray (#9708) 2024-01-25 21:45:58 +00:00
Alan Wu
f0224adf2f YJIT: Assert lea source operand type 2024-01-25 16:17:03 -05:00
Matt Valentine-House
e452caac10 [PRISM] Fix next inside rescue 2024-01-25 15:10:52 -05:00
Peter Zhu
e7262966c9 [PRISM] Fix indentation of test_ScopeNode 2024-01-25 12:14:22 -05:00
Takashi Kokubun
d4cc77e7b6
YJIT: Add a counter for invokebuiltin exits (#9696) 2024-01-25 11:23:26 -05:00
Kevin Newton
1301422dfe [PRISM] Fix VM_CALL_ARGS_SPLAT_MUT failures 2024-01-25 11:11:50 -05:00
Kevin Newton
ebf803aa19 [ruby/prism] Fix Ruby head build
https://github.com/ruby/prism/commit/149e2ff7f6
2024-01-25 13:58:07 +00:00
Eddie Lebow
fdb8f08639 [ruby/irb] Reword history file documentation and fix typo
(https://github.com/ruby/irb/pull/842)

https://github.com/ruby/irb/commit/bbabf818c7
2024-01-25 10:20:47 +00:00
ydah
4bd58e1ade [ruby/irb] diabled ==> disabled
https://github.com/ruby/irb/commit/295797ff37
2024-01-25 09:58:17 +00:00
ydah
0334115628 [ruby/irb] Synatx ==> Syntax
https://github.com/ruby/irb/commit/2ffacaa031
2024-01-25 09:58:17 +00:00
ydah
819ae2c2c1 [ruby/irb] assigment ==> assignment
https://github.com/ruby/irb/commit/24c7694467
2024-01-25 09:58:16 +00:00
ydah
5f9f46a24c [ruby/irb] reseting ==> resetting
https://github.com/ruby/irb/commit/6209f06c72
2024-01-25 09:58:16 +00:00
ydah
9b1cc68b77 [ruby/irb] configuation ==> configuration
https://github.com/ruby/irb/commit/a27a511777
2024-01-25 09:58:16 +00:00
ydah
fd9b968569 [ruby/irb] recever ==> receiver
https://github.com/ruby/irb/commit/dbd0e368c4
2024-01-25 09:58:15 +00:00
ydah
6580a95f8d [ruby/irb] inifinity ==> infinity
https://github.com/ruby/irb/commit/78dea58000
2024-01-25 09:58:15 +00:00
ydah
4d4d418457 [ruby/irb] overrided ==> overridden
https://github.com/ruby/irb/commit/b77b23aade
2024-01-25 09:58:14 +00:00
Hiroshi SHIBATA
0f5407b337 Simplified test case for encoding option
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2024-01-25 16:06:06 +09:00
Hiroshi SHIBATA
d13a57cd65 Use Encoding.local_charmap instead of locale
In my windows environment uses cp932 for terminal encoding.
2024-01-25 16:06:06 +09:00
Hiroshi SHIBATA
1d972498eb Use Encoding::CESU_8 for test case
Encoding::Windows_31J is already loaded in mswin platform
2024-01-25 16:06:06 +09:00
Nobuyoshi Nakada
ff55d6b8e1
Use token_seen and simplify comment_at_top
Instead of scanning before the current comment.
2024-01-25 15:06:14 +09:00
Jeremy Evans
2b9719ea30 Ignore --parser=prism failures until prism compiler fixed for recent optimizations 2024-01-24 19:42:41 -08:00
Jeremy Evans
fb596499f7 Temporarily ignore bundled gems failures for rbs and typeprof on macos, similar to ubuntu
This should be reverted after rbs and typeprof are updated to handle
the changes for the optimizations.
2024-01-24 19:42:41 -08:00
Jeremy Evans
42d891be2c Add benchmark for implicit array/hash allocation reduction changes
Benchmark results:

```
named_multi_arg_splat
after:    5344097.6 i/s
before:   3088134.0 i/s - 1.73x  slower

named_post_splat
after:    5401882.3 i/s
before:   2629321.8 i/s - 2.05x  slower

anon_arg_splat
after:   12242780.9 i/s
before:   6845413.2 i/s - 1.79x  slower

anon_arg_kw_splat
after:   11277398.7 i/s
before:   4329509.4 i/s - 2.60x  slower

anon_multi_arg_splat
after:    5132699.5 i/s
before:   3018103.7 i/s - 1.70x  slower

anon_post_splat
after:    5602915.1 i/s
before:   2645185.5 i/s - 2.12x  slower

anon_kw_splat
after:   15403727.3 i/s
before:   6249504.6 i/s - 2.46x  slower

anon_fw_to_named_splat
after:    2985715.3 i/s
before:   2049159.9 i/s - 1.46x  slower

anon_fw_to_named_no_splat
after:    2941030.4 i/s
before:   2100380.0 i/s - 1.40x  slower

fw_to_named_splat
after:    2801008.7 i/s
before:   2012416.4 i/s - 1.39x  slower

fw_to_named_no_splat
after:    2742670.4 i/s
before:   1957707.2 i/s - 1.40x  slower

fw_to_anon_to_named_splat
after:    2309246.6 i/s
before:   1375924.6 i/s - 1.68x  slower

fw_to_anon_to_named_no_splat
after:    2193227.6 i/s
before:   1351184.1 i/s - 1.62x  slower
```
2024-01-24 18:25:55 -08:00
Jeremy Evans
4f77d8d328 Do not use ruby2_keywords for ... argument forwarding
This allows ... argument forwarding to benefit from Allocationless
Anonymous Splat Forwarding, allowing the `f` call below to not
allocate an array or a hash.

```ruby
a = [1]
kw = {b: 2}

def c(a, b:)
end

def f(...)
  c(...)
end

f(*a, **kw)
```

This temporarily skips prism locals tests until prism is changed
to use * and ** for ..., instead of using ruby2_keywords.

Ignore failures in rbs bundled gems tests, since they fail due
to this change.
2024-01-24 18:25:55 -08:00