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

83128 Коммитов

Автор SHA1 Сообщение Дата
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
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