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

83079 Коммитов

Автор SHA1 Сообщение Дата
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 b822f9f6fc [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
Jeremy Evans 0f90a24a81 Introduce Allocationless Anonymous Splat Forwarding
Ruby makes it easy to delegate all arguments from one method to another:

```ruby
def f(*args, **kw)
  g(*args, **kw)
end
```

Unfortunately, this indirection decreases performance.  One reason it
decreases performance is that this allocates an array and a hash per
call to `f`, even if `args` and `kw` are not modified.

Due to Ruby's ability to modify almost anything at runtime, it's
difficult to avoid the array allocation in the general case. For
example, it's not safe to avoid the allocation in a case like this:

```ruby
def f(*args, **kw)
  foo(bar)
  g(*args, **kw)
end
```

Because `foo` may be `eval` and `bar` may be a string referencing `args`
or `kw`.

To fix this correctly, you need to perform something similar to escape
analysis on the variables.  However, there is a case where you can
avoid the allocation without doing escape analysis, and that is when
the splat variables are anonymous:

```ruby
def f(*, **)
  g(*, **)
end
```

When splat variables are anonymous, it is not possible to reference
them directly, it is only possible to use them as splats to other
methods.  Since that is the case, if `f` is called with a regular
splat and a keyword splat, it can pass the arguments directly to
`g` without copying them, avoiding allocation.  For example:

```ruby
def g(a, b:)
  a + b
end

def f(*, **)
  g(*, **)
end

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

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

I call this technique: Allocationless Anonymous Splat Forwarding.

This is implemented using a couple additional iseq param flags,
anon_rest and anon_kwrest.  If anon_rest is set, and an array splat
is passed when calling the method when the array splat can be used
without modification, `setup_parameters_complex` does not duplicate
it.  Similarly, if anon_kwest is set, and a keyword splat is passed
when calling the method, `setup_parameters_complex` does not
duplicate it.
2024-01-24 18:25:55 -08:00
Jeremy Evans b8516d6d01 Add pushtoarray VM instruction
This instruction is similar to concattoarray, but it takes the
number of arguments to push to the array, removes that number
of arguments from the stack, and adds them to the array now at
the top of the stack.

This allows `f(*a, 1)` to allocate only a single array on the
caller side (which can be reused on the callee side in the case of
`def f(*a)`). Prior to this commit, `f(*a, 1)` would generate
3 arrays:

* a dupped by splatarray true
* 1 wrapped in array by newarray
* a dupped again by concatarray

Instructions Before for `a = []; f(*a, 1)`:

```
0000 newarray                               0                         (   1)[Li]
0002 setlocal_WC_0                          a@0
0004 putself
0005 getlocal_WC_0                          a@0
0007 splatarray                             true
0009 putobject_INT2FIX_1_
0010 newarray                               1
0012 concatarray
0013 opt_send_without_block                 <calldata!mid:f, argc:1, ARGS_SPLAT|FCALL>
0015 leave
```

Instructions After for `a = []; f(*a, 1)`:

```
0000 newarray                               0                         (   1)[Li]
0002 setlocal_WC_0                          a@0
0004 putself
0005 getlocal_WC_0                          a@0
0007 splatarray                             true
0009 putobject_INT2FIX_1_
0010 pushtoarray                            1
0012 opt_send_without_block                 <calldata!mid:f, argc:1, ARGS_SPLAT|ARGS_SPLAT_MUT|FCALL>
0014 leave
```

With these changes, method calls to Ruby methods should
implicitly allocate at most one array.

Ignore typeprof bundled gem failure due to unrecognized instruction.
2024-01-24 18:25:55 -08:00
Jeremy Evans 6e06d0d180 Add concattoarray VM instruction
This instruction is similar to concatarray, but assumes the first
object is already an array, and appends to it directly.  This is
different than concatarray, which will create a new array instead
of appending to an existing array.

Additionally, for both concatarray and concattoarray, if the second
argument cannot be converted to an array, then just push it onto
the array, instead of creating a new array to wrap it, and then
using concat array.  This saves an array allocation in that case.

This allows `f(*a, *a, *1)` to allocate only a single array on the
caller side (which can be reused on the callee side in the case of
`def f(*a)`). Prior to this commit, `f(*a, *a, *1)` would generate
4 arrays:

* a dupped by splatarray true
* a dupped again by first concatarray
* 1 wrapped in array by third splatarray
* result of [*a, *a] dupped by second concatarray

Instructions Before for `a = []; f(*a, *a, *1)`:

```
0000 newarray                               0                         (   1)[Li]
0002 setlocal_WC_0                          a@0
0004 putself
0005 getlocal_WC_0                          a@0
0007 splatarray                             true
0009 getlocal_WC_0                          a@0
0011 splatarray                             false
0013 concatarray
0014 putobject_INT2FIX_1_
0015 splatarray                             false
0017 concatarray
0018 opt_send_without_block                 <calldata!mid:g, argc:1, ARGS_SPLAT|ARGS_SPLAT_MUT|FCALL>
0020 leave
```

Instructions After for `a = []; f(*a, *a, *1)`:

```
0000 newarray                               0                         (   1)[Li]
0002 setlocal_WC_0                          a@0
0004 putself
0005 getlocal_WC_0                          a@0
0007 splatarray                             true
0009 getlocal_WC_0                          a@0
0011 concattoarray
0012 putobject_INT2FIX_1_
0013 concattoarray
0014 opt_send_without_block                 <calldata!mid:f, argc:1, ARGS_SPLAT|ARGS_SPLAT_MUT|FCALL>
0016 leave
```
2024-01-24 18:25:55 -08:00
Jeremy Evans 22e488464a Add VM_CALL_ARGS_SPLAT_MUT callinfo flag
This flag is set when the caller has already created a new array to
handle a splat, such as for `f(*a, b)` and `f(*a, *b)`.  Previously,
if `f` was defined as `def f(*a)`, these calls would create an extra
array on the callee side, instead of using the new array created
by the caller.

This modifies `setup_args_core` to set the flag whenver it would add
a `splatarray true` instruction.  However, when `splatarray true` is
changed to `splatarray false` in the peephole optimizer, to avoid
unnecessary allocations on the caller side, the flag must be removed.
Add `optimize_args_splat_no_copy` and have the peephole optimizer call
that.  This significantly simplifies the related peephole optimizer
code.

On the callee side, in `setup_parameters_complex`, set
`args->rest_dupped` to true if the flag is set.

This takes a similar approach for optimizing regular splats that was
previiously used for keyword splats in
d2c41b1bff (via VM_CALL_KW_SPLAT_MUT).
2024-01-24 18:25:55 -08:00
KJ Tsanaktsidis ef276858d9 Trigger postponed jobs on running_ec if that is available
Currently, any postponed job triggered from a non-ruby thread gets sent
to the main thread, but if the main thread is sleeping it won't be
checking ints. Instead, we should try and interrupt running_ec if that's
possible, and only fall back to the main thread if it's not.

[Bug #20197]
2024-01-25 13:10:35 +11:00
Hiroshi SHIBATA 2e18228dff Use echo with all platforms 2024-01-25 10:51:18 +09:00
Hiroshi SHIBATA 52085b66d6 Use echo command in mswin platform 2024-01-25 10:51:18 +09:00
Takashi Kokubun 34c688b163
Omit TestCompilePrism on s390x for now (#9694) 2024-01-24 16:03:05 -08:00
Alan Wu 2cc7a56ec7
YJIT: Avoid leaks by skipping objects with a singleton class
For receiver with a singleton class, there are multiple vectors YJIT can
end up retaining the object. There is a path in jit_guard_known_klass()
that bakes the receiver into the code, and the object could also be kept
alive indirectly through a path starting at the CME object baked into
the code.

To avoid these leaks, avoid compiling calls on objects with a singleton
class.

See: https://github.com/Shopify/ruby/issues/552

[Bug #20209]
2024-01-24 18:06:58 -05:00
Peter Zhu f769d68a69 [PRISM] Fix getblockparamproxy for forwarding arguments 2024-01-24 17:32:43 -05:00
Max Prokopiev a65b52b57f [ruby/prism] Add missing snapshot for the new file
https://github.com/ruby/prism/commit/459a9f544e
2024-01-24 20:32:02 +00:00
Max Prokopiev e9f936df71 [ruby/prism] Extract snippet into its own file and skip in TruffleRuby
https://github.com/ruby/prism/commit/12649ee74c
2024-01-24 20:32:02 +00:00
Max Prokopiev 91a5093c15 [ruby/prism] Force encoding during deserialization of constants
otherwise we get failing tests if we have non-ascii
characters in fixtures/**/*.txt

https://github.com/ruby/prism/commit/9323243569
2024-01-24 20:32:01 +00:00
Max Prokopiev 6a63aaade9 [ruby/prism] Use char_is_identifier_start() to check for valid method name
alnum_char() only checks for alphanumeric characters while
ignoring other valid cases (like emoji codepoints for example)

https://github.com/ruby/prism/commit/d15958fd28
2024-01-24 20:32:01 +00:00
Peter Zhu 7d61454f2e [PRISM] Fix method calls in keyword arguments
Fixes ruby/prism#2248.
2024-01-24 15:18:06 -05:00
Aaron Patterson 94f3f9502c Fix repeated block param
Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24 12:04:44 -08:00
Aaron Patterson 1817af5074 Fix local table size / index for repeated kwrest
Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24 12:04:44 -08:00
Aaron Patterson 13c76e40d3 Fix local table size and variable offset for repeated keywords
Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24 12:04:44 -08:00
Aaron Patterson 8b7e78f156 Fix local table size and index for required post underscore
Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24 12:04:44 -08:00
Aaron Patterson bb6af9287b Fix local table space for `*_`
We need to make sure there is enough room in the local table for
repeated `*_` parameters

Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24 12:04:44 -08:00