83249 Commits

Author SHA1 Message Date
Willian Tenfen W
d42330d702 [rubygems/rubygems] Improve gem login scope selection
https://github.com/rubygems/rubygems/commit/26c7abe5f6
2024-01-29 17:22:01 +00:00
Alan Wu
b0711b1cf1
YJIT: Fix tailcall and JIT entry eating up FINISH frames (#9729)
Suppose YJIT runs a rb_vm_opt_send_without_block()
fallback and the control frame stack looks like:

```
will_tailcall_bar [FINISH]
caller_that_used_fallback
```

will_tailcall_bar() runs in the interpreter and sets up a tailcall.
Right before JIT_EXEC() in the `send` instruction, the stack will look like:

```
bar [FINISH]
caller_that_used_fallback
```

Previously, JIT_EXEC() ran bar() in JIT code, which caused the `FINISH`
flag to return to the interpreter instead of to the JIT code running
caller_that_used_fallback(), causing code to run twice and probably
crash. Recent flaky failures on CI about "each stub expects a particular
iseq" are probably due to leaving methods twice in
`test_optimizations.rb`.

Only run JIT code from the interpreter if a new frame is pushed.
2024-01-29 12:21:17 -05:00
Peter Zhu
9a5a11f3d0 [PRISM] Use the splatkw instruction
Fixes ruby/prism#2272.
2024-01-29 11:42:40 -05:00
Kevin Newton
e050097beb [ruby/prism] Raise diagnostics for parser
https://github.com/ruby/prism/commit/102b4a16f5
2024-01-29 16:09:47 +00:00
Maxime Chevalier-Boisvert
adf29c9a98
YJIT: add asm comment when we clear local types (#9713)
Small PR to add a comment when we clear local variable types,
so we can be aware that it's happening when looking at the disasm.
2024-01-29 15:36:34 +00:00
Peter Zhu
fde3d065e6 Add removable and refcnt output to labels
Co-Authored-By: Kevin Newton <kddnewton@gmail.com>
2024-01-29 10:05:32 -05:00
Matt Valentine-House
c422805bbb [PRISM] Fix encoding for interpolated strings.
This wasn't taking into account strings with flags set on the containing
node that could affect the encoding. It does now
2024-01-29 10:04:16 -05:00
Hiroya Fujinami
3e6e3ca262
Correctly handle consecutive lookarounds (#9738)
Fix [Bug #20207]
Fix [Bug #20212]

Handling consecutive lookarounds in init_cache_opcodes is buggy, so it
causes invalid memory access reported in [Bug #20207] and [Bug #20212].
This fixes it by using recursive functions to detected lookarounds
nesting correctly.
2024-01-29 23:51:26 +09:00
Yuta Saito
0d4de0f4b1 wasm: align fiber stack pointer to 16 bytes
In WebAssembly C ABI, the linear stack pointer must be always aligned
to 16 bytes like other archs.
The misaligned stack pointer causes some weird memory corruption since
compiler assumes the aligned stack pointer.
2024-01-29 23:45:36 +09:00
Nobuyoshi Nakada
8bff7e996c
[DOC] Move "Execution Shell on Windows" under "Execution Shell" 2024-01-29 17:16:49 +09:00
Masato Ohba
933ede5d76 [rubygems/rubygems] Remove travis_removal_info
`travis_removal_info` is added by https://github.com/rubygems/rubygems/pull/6150. According to the comment, it's supposed to be removed at bundler v2.5.0 but it hasn't.

https://github.com/rubygems/rubygems/commit/e18797d43f
2024-01-29 05:39:13 +00:00
David Rodríguez
e99951edfa [rubygems/rubygems] Simplify how extensions are built
https://github.com/rubygems/rubygems/commit/0b8faf1e39
2024-01-29 12:20:44 +09:00
David Rodríguez
5ea4df6a8f [rubygems/rubygems] Remove annoying debug info
Sometimes you want this, sometimes you don't. And when you don't, this
hides other debugging puts you may have added.

https://github.com/rubygems/rubygems/commit/df37582c81
2024-01-29 12:20:44 +09:00
David Rodríguez
1991c6d7a0 [rubygems/rubygems] Remove now unnecessary elseif
https://github.com/rubygems/rubygems/commit/d05b9e659b

Co-authored-by: Samuel Giddins <segiddins@segiddins.me>
2024-01-29 12:19:32 +09:00
David Rodríguez
355480dec6 [rubygems/rubygems] Properly restore empty env vars
https://github.com/rubygems/rubygems/commit/e0d68a8688
2024-01-29 12:19:31 +09:00
Hiroshi SHIBATA
2956d3a511
Removed duplicated license file 2024-01-29 12:18:26 +09:00
David Rodríguez
5a884c2e00 [rubygems/rubygems] Add a spec to prove uri is no longer loaded
https://github.com/rubygems/rubygems/commit/3a262f55c8
2024-01-29 12:15:37 +09:00
David Rodríguez
5f9c120073 [rubygems/rubygems] Remove no longer needed uri install during specs
https://github.com/rubygems/rubygems/commit/7f35dc19c5
2024-01-29 12:15:26 +09:00
David Rodríguez
f3123f8af2 [rubygems/rubygems] Use rubygems vendored uri from Bundler when available
https://github.com/rubygems/rubygems/commit/5d6a8f2fb4
2024-01-29 12:15:10 +09:00
David Rodríguez
d64d0b5423
Vendor uri gem in RubyGems 2024-01-29 12:14:21 +09:00
David Rodríguez
6bbbfb4629 [rubygems/rubygems] Require vendored_uri file in Bundler
https://github.com/rubygems/rubygems/commit/62bc261042
2024-01-29 12:02:04 +09:00
Nobuyoshi Nakada
5ac9c8f01b [ruby/win32ole] [DOC] Remove spaces inside parentheses
https://github.com/ruby/win32ole/commit/57e4a38465
2024-01-28 15:27:19 +00:00
Nobuyoshi Nakada
8074525b2b [ruby/win32ole] Move toplevel constant for olegen under WIN32OLE
https://github.com/ruby/win32ole/commit/78ff137c0f
2024-01-28 15:25:36 +00:00
Nobuyoshi Nakada
3ad54239b5 [ruby/win32ole] [DOC] Move sample to toplevel
https://github.com/ruby/win32ole/commit/70ea60c4d2
2024-01-28 15:25:36 +00:00
Nobuyoshi Nakada
703ad99bf8 [ruby/win32ole] Use end_with? and fix indent
https://github.com/ruby/win32ole/commit/7648ee7e56
2024-01-28 15:25:35 +00:00
Nobuyoshi Nakada
bd6f983403 [ruby/win32ole] Use the scoped names in the tests
https://github.com/ruby/win32ole/commit/2b91b6b838
2024-01-28 15:25:35 +00:00
Nobuyoshi Nakada
8af4ef30e5 [ruby/win32ole] Move WIN32OLE prefixed error classes under WIN32OLE
https://github.com/ruby/win32ole/commit/1c95816168
2024-01-28 15:25:35 +00:00
Nobuyoshi Nakada
1e2d088dd3 [ruby/win32ole] Use the scoped names in inspect and error messages
https://github.com/ruby/win32ole/commit/2f51493bd1
2024-01-28 15:25:34 +00:00
Nobuyoshi Nakada
baef72da36 [ruby/win32ole] [DOC] Update class names using the scoped names
https://github.com/ruby/win32ole/commit/2c5d193da7
2024-01-28 15:25:34 +00:00
Nobuyoshi Nakada
1bc48684cd [ruby/win32ole] Rename WIN32OLE::Typelib as WIN32OLE::TypeLib
https://github.com/ruby/win32ole/commit/5feede2cc5
2024-01-28 15:25:33 +00:00
Nobuyoshi Nakada
853bcf65c7 [ruby/win32ole] Rename WIN32OLE::VARIANT as WIN32OLE::VariantType
Prevent name clash with `WIN32OLE::Variant`, of generated document
files on case-insensitive filesystems, such as Windows.

https://github.com/ruby/win32ole/commit/049e5f0a6e
2024-01-28 15:25:33 +00:00
Masato Nakamura
c166615837 [ruby/reline] Add metadata for rubygems.org
(https://github.com/ruby/reline/pull/638)

https://github.com/ruby/reline/commit/d3a324d22c
2024-01-28 12:38:55 +00:00
Nobuyoshi Nakada
23b8337cd1
[Bug #20219] gettable returns NULL on error 2024-01-28 19:15:31 +09:00
Nobuyoshi Nakada
5f733a1ae7
[Bug #20217] rescue block is void only if all children are void 2024-01-28 18:44:09 +09:00
Nobuyoshi Nakada
fed877c791
[Bug #20217] return with ensure is a void value expression 2024-01-28 18:44:09 +09:00
Nobuyoshi Nakada
d3e6bcd37f [ruby/digest] [DOC] Expand Digest::SHA2 definitions for RDoc
Since RDoc searches `var = rb_define_class_under(...)` statements
literally, they cannot be built by macros.

https://github.com/ruby/digest/commit/d39b684f91
2024-01-28 06:49:28 +00:00
Nobuyoshi Nakada
81702b4b87 [ruby/digest] Prefer rb_const_get over rb_path2class for direct constants
https://github.com/ruby/digest/commit/e5d30394b3
2024-01-28 06:49:28 +00:00
Nobuyoshi Nakada
f475dc1cd2 [ruby/digest] [DOC] Add .document
https://github.com/ruby/digest/commit/6db96aa99a
2024-01-28 06:49:26 +00:00
Nobuyoshi Nakada
e0f4c4e410
Provisionally ignore panics that happen in these days often [ci skip]
```
    ruby: YJIT has panicked. More info to follow...
  thread '<unnamed>' panicked at src/core.rs:2751:9:
  assertion `left == right` failed: each stub expects a particular iseq
    left: 0x7fc8d8e09850
   right: 0x7fc8d2c2f3a0
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
     1: core::panicking::panic_fmt
               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
     2: core::panicking::assert_failed_inner
     3: core::panicking::assert_failed
               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:279:5
     4: yjit::core::branch_stub_hit_body
               at /home/runner/work/ruby/ruby/src/yjit/src/core.rs:2751:9
     5: yjit::core::branch_stub_hit::{{closure}}::{{closure}}
               at /home/runner/work/ruby/ruby/src/yjit/src/core.rs:2696:36
     6: yjit::stats::with_compile_time
               at /home/runner/work/ruby/ruby/src/yjit/src/stats.rs:979:15
     7: yjit::core::branch_stub_hit::{{closure}}
               at /home/runner/work/ruby/ruby/src/yjit/src/core.rs:2696:13
     8: std::panicking::try::do_call
               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
     9: __rust_try
    10: std::panicking::try
               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
    11: std::panic::catch_unwind
               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
    12: yjit::cruby::with_vm_lock
               at /home/runner/work/ruby/ruby/src/yjit/src/cruby.rs:647:21
    13: yjit::core::branch_stub_hit
               at /home/runner/work/ruby/ruby/src/yjit/src/core.rs:2695:9
    14: <unknown>
```
2024-01-28 12:46:07 +09:00
Nobuyoshi Nakada
3dde9c1b43
Extract continue-on-error condition to the matrix [ci skip] 2024-01-28 12:30:21 +09:00
Nobuyoshi Nakada
e018036d89
Rename nd_head in RNode_RESBODY as nd_next 2024-01-28 11:12:22 +09:00
Nobuyoshi Nakada
0f98d284f3
Remove unused nd_resq from RNode_ENSURE 2024-01-28 11:11:13 +09:00
Kevin Newton
e256d44f98 [ruby/prism] Handle implicit rest in array pattern for parser gem
https://github.com/ruby/prism/commit/d3722d6660
2024-01-28 01:10:47 +00:00
Jeremy Evans
8a027d111f Remove expandarray/splatarray sequence peephole optimization
newarray, duparray, concatarray, and splatarray always leave an
array at the top of the stack.  expandarray does not, it takes
an array from the top of the stack as input, and leaves individual
elements on the stack.  I assume no Ruby code generates the
expandarray/splatarray sequence, or it could break. The only
use of expandarray outside the peephole optimizer is in the
masgn code, and it does not appear to generate splatarray
directly after expandarray.

The splatarray/splatarray peephole optimization is probably
also wrong in the following case:

```
putobject  [1,2]
splatarray false
splatarray true
```

This instruction sequence should result in a duplicate of
[1,2] at the top of the stack, but the peephole optimizer would
remove the `splatarray true`, resulting in change that made
[1,2] on top of the stack.  I'm not sure Ruby code can generate
`splatarray false` followed by `splatarray true` (I could get it
to generate chains of `splatarray true`), so maybe this has no
effect.

newarray, duparray, and concatarray all result in newly allocated
arrays at the top of the stack, so they shouldn't have an issue
with removing either `splatarray true` or `splatarray false`.
2024-01-27 14:47:07 -08:00
Jeremy Evans
d917bb8e60 Eliminate 1-2 array allocations for each splat used in a masgn method
Given code such as:

```ruby
  h[*a, :a], h[*b] = v
```

Ruby would previously allocate 5 arrays for the mass assignment:

* splatarray true for a
* newarray for v[0]
* concatarray for [*a, a] and v[0]
* newarray for v[1]
* concatarray for b and v[1]

This optimizes it to only allocate 2 arrays:

* splatarray true for a
* splatarray true for b

Instead of the newarray/concatarray combination, pushtoarray is used.

Note above that there was no splatarray true for b originally. The
normal compilation uses splatarray false for b.  Instead of trying
to find and modify the splatarray false to splatarray true, this
adds splatarray true for b, which requires a couple of swap
instructions, before the pushtoarray.  This could be further
optimized to remove the need for those three instructions, but I'm
not sure if the complexity is worth it.

Additionally, this sets VM_CALL_ARGS_SPLAT_MUT on the call to
[]= in the h[*b] case, so that if []= has a splat parameter, the
new array can be used directly, without additional duplication.
2024-01-27 14:04:55 -08:00
Jeremy Evans
a591e11a7a Eliminate 1-2 array allocations for each splat used in a op_asgn method
Given code such as:

```ruby
  h[*a, 1] += 1
  h[*b] += 2
```

Ruby would previously allocate 5 arrays:

* splatarray true for a
* newarray for 1
* concatarray for [*a, 1] and [1]
* newarray for 2
* concatarray for b and [2]

This optimizes it to only allocate 2 arrays:

* splatarray true for a
* splatarray true for b

Instead of the newarray/concatarray combination, pushtoarray is used.

Note above that there was no splatarray true for b originally. The
normal compilation uses splatarray false for b.  Instead of trying
to find and modify the splatarray false to splatarray true, this
adds splatarray true for b, which requires a couple of swap
instructions, before the pushtoarray.  This could be further
optimized to remove the need for those three instructions, but I'm
not sure if the complexity is worth it.

Additionally, this sets VM_CALL_ARGS_SPLAT_MUT on the call to
[]= in the h[*b] case, so that if []= has a splat parameter, the
new array can be used directly, without additional duplication.
2024-01-27 13:02:42 -08:00
Kevin Newton
f12ebe1188 [ruby/prism] Add parser translation
https://github.com/ruby/prism/commit/8cdec8070c
2024-01-27 19:59:42 +00:00
Jeremy Evans
223910b329 Reduce array allocations for literal arrays with splats and other args
Previously, a literal array with a splat and any other args resulted in
more than one array allocation:

```ruby
[1, *a]
[*a, 1]
[*a, *a]
[*a, 1, 2]

[*a, a]
[*a, 1, *a]
[*a, 1, a]
[*a, a, a]

[*a, a, *a]
[*a, 1, *a, 1]
[*a, 1, *a, *a]

[*a, a, *a, a]
```

This is because previously Ruby would use newarray and concatarray
to create the array, which both each allocate an array internally.

This changes the compilation to use concattoarray and pushtoarray,
which do not allocate arrays.  It also updates the peephole optimizer
to optimize the duparray/concattoarray sequence to
putobject/concattoarray, mirroring the existing duparray/concatarray
optimization.

These changes reduce the array allocations for the above examples to
a single array allocation, except for:

```
[*a, 1, a]
[*a, a, a]
```

The reason for this is because optimizing this case to only allocate
1 array requires changes to compile_array, which would currently
conflict with an unmerged pull request (#9721).  After that pull
request is merged, it should be possible to refactor things to only
allocate a 1 array for all literal arrays (or 2 for arrays with
keyword splats).
2024-01-27 11:42:01 -08:00
Kevin Newton
e337c9478a [ruby/prism] Error follow-up
Split up the diagnostic levels so that error and warning levels
aren't mixed. Also fix up deconstruct_keys implementation.

https://github.com/ruby/prism/commit/bd3eeb308d

Co-authored-by: Benoit Daloze <eregontp@gmail.com>
2024-01-27 18:46:16 +00:00
Benoit Daloze
c2e2d2398b [ruby/prism] Call #inspect on diagnostic levels
* So it's clear it is a Symbol.
  Before:
  ... @level=warning_verbose_true>
  After:
  ... @level=:warning_verbose_true>

https://github.com/ruby/prism/commit/84503643b9
2024-01-27 18:41:07 +00:00