Age | Commit message (Collapse) | Author |
|
https://bugs.ruby-lang.org/issues/21203
TestGc#test_gc_parameter_init_slots is a flaky test that fails intermittently. Until the issue with flakiness is resolved, I will skip it.
Notes:
Merged-By: ono-max <[email protected]>
|
|
[Bug #17506]
`Thread.current.group` isn't shareable so it shouldn't be inherited
by the main thread of a new Ractor.
This cause an extra allocation when spawning a ractor, which could
be elided with a bit of extra work, but not sure if it's worth
the effort.
Notes:
Merged: https://github.com/ruby/ruby/pull/13013
|
|
limit
|
|
Anonymous positional splats cannot be directly accessed, they can
only be passed as splats to other methods. So if an anonymous
positional splat would be empty, you can use a shared frozen
empty array to save an allocation.
```ruby
def a(*) end
a()
```
This is similar to how anonymous empty keyword splats are optimized,
except those use `nil` instead of a shared empty frozen hash.
This updates the allocation tests to check that the array allocations
are avoided where possible.
It also makes a small change to test_iseq.rb to ensure an unfrozen
hash is passed as the value of an anonymous splat parameter.
Notes:
Merged: https://github.com/ruby/ruby/pull/12596
|
|
The following method call:
```ruby
a(*nil)
```
A method call such as `a(*nil)` previously allocated an array, because
it calls `nil.to_a`, but I have determined this array allocation is
unnecessary. The instructions in this case are:
```
0000 putself ( 1)[Li]
0001 putnil
0002 splatarray false
0004 opt_send_without_block <calldata!mid:a, argc:1, ARGS_SPLAT|FCALL>
0006 leave
```
The method call uses `ARGS_SPLAT` without `ARGS_SPLAT_MUT`, so the
returned array doesn't need to be mutable. I believe all cases where
`splatarray false` are used allow the returned object to be frozen,
since the `false` means to not duplicate the array. The optimization
in this case is to have `splatarray false` push a shared empty frozen
array, instead of calling `nil.to_a` to return a newly allocated array.
There is a slightly backwards incompatibility with this optimization,
in that `nil.to_a` is not called. However, I believe the new behavior
of `*nil` not calling `nil.to_a` is more consistent with how `**nil`
does not call `nil.to_hash`. Also, so much Ruby code would break if
`nil.to_a` returned something different from the empty hash, that it's
difficult to imagine anyone actually doing that in real code, though
we have a few tests/specs for that.
I think it would be bad for consistency if `*nil` called `nil.to_a`
in some cases and not others, so this changes other cases to not
call `nil.to_a`:
For `[*nil]`, this uses `splatarray true`, which now allocates a
new array for a `nil` argument without calling `nil.to_a`.
For `[1, *nil]`, this uses `concattoarray`, which now returns
the first array if the second array is `nil`.
This updates the allocation tests to check that the array allocations
are avoided where possible.
Implements [Feature #21047]
Notes:
Merged: https://github.com/ruby/ruby/pull/12597
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12977
|
|
[Bug #21195]
Notes:
Merged-By: ioquatix <[email protected]>
|
|
A space is added only when the source path is found.
|
|
|
|
Blocks insert a leading `nop` instruction in order to execute a "block
call" tracepoint. Block compilation unconditionally inserts a leading
`nop` plus a label after the instruction:
https://github.com/ruby/ruby/blob/641f15b1c6bd8921407a1f045573d3b0605f00d3/prism_compile.c#L6867-L6869
This `nop` instruction is used entirely for firing the block entry
tracepoint. The label exists so that the block can contain a loop but
the block entry tracepoint is executed only once.
For example, the following code is an infinite loop, but should only
execute the b_call tracepoint once:
```ruby
-> { redo }.call
```
Previous to this commit, we would eliminate the `nop` instruction, but
only if there were no other jump instructions inside the block. This
means that the following code would still contain a leading `nop` even
though the label following the `nop` is unused:
```ruby
-> { nil if bar }
```
```
== disasm: #<ISeq:block in <main>@test.rb:1 (1,2)-(1,17)> (catch: FALSE)
0000 nop ( 1)[Bc]
0001 putself [Li]
0002 opt_send_without_block <calldata!mid:bar, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0004 branchunless 8
0006 putnil
0007 leave [Br]
0008 putnil
0009 leave [Br]
```
This commit checks to see if the label inserted after the `nop` is
actually a jump target. If it's not a jump target, then we should be
safe to eliminate the leading `nop`:
```
> build-master/miniruby --dump=insns test.rb
== disasm: #<ISeq:<main>@test.rb:1 (1,0)-(1,17)>
0000 putspecialobject 1 ( 1)[Li]
0002 send <calldata!mid:lambda, argc:0, FCALL>, block in <main>
0005 leave
== disasm: #<ISeq:block in <main>@test.rb:1 (1,2)-(1,17)>
0000 putself ( 1)[LiBc]
0001 opt_send_without_block <calldata!mid:bar, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0003 branchunless 7
0005 putnil
0006 leave [Br]
0007 putnil
0008 leave [Br]
```
We have a test for b_call tracepoints that use `redo` here:
https://github.com/ruby/ruby/blob/aebf96f371c8d874398e0041b798892e545fa206/test/ruby/test_settracefunc.rb#L1728-L1736
Notes:
Merged: https://github.com/ruby/ruby/pull/12957
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12925
|
|
|
|
|
|
Since `rb_bug` does not always take Ruby frame info during SEGV, the
source file path may not be output.
```
1) Failure:
TestRubyOptions#test_crash_report_script [/tmp/ruby/src/trunk_gcc11/test/ruby/test_rubyoptions.rb:907]:
Expected /
bug\.rb:(?:1:)?\s\[BUG\]\sSegmentation\sfault.*\n
/x
to match
"[BUG] Segmentation fault at 0x000003e900328766\n"+
```
http://ci.rvm.jp/results/trunk_gcc11@ruby-sp2-noble-docker/5663880
|
|
[Bug #21029]
Notes:
Merged: https://github.com/ruby/ruby/pull/12949
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12947
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12798
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12889
|
|
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12946
|
|
Infinite ranges, i.e. unbounded ranges, should overlap with any other range
which wasn't the case in the following example: (0..3).overlap?(nil..nil)
Notes:
Merged: https://github.com/ruby/ruby/pull/12937
|
|
[Misc #21143]
Conceptually this makes sense and is more consistent with using
the `Name = Class.new(Superclass)` alternative method.
However the new class is still named before `inherited` is called.
Notes:
Merged: https://github.com/ruby/ruby/pull/12927
|
|
Previously, live range of `ast_value` ended on the call right before
rb_ast_dispose(), which led to premature collection and use-after-free.
We observed this crashing on -O3, -DVM_CHECK_MODE, with GCC 11.4.0 on
Ubuntu.
Co-authored-by: Aaron Patterson <[email protected]>
Notes:
Merged: https://github.com/ruby/ruby/pull/12898
|
|
The code between the two ObjectSpace.count_objects could trigger a GC,
which could free string objects causing this test to fail.
We can see this failure on CI http://ci.rvm.jp/results/trunk-random2@ruby-sp2-noble-docker/5651016
TestHashOnly#test_AREF_fstring_key [test/ruby/test_hash.rb:1991]:
<197483> expected but was
<129689>.
Notes:
Merged: https://github.com/ruby/ruby/pull/12916
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12914
|
|
https://github.com/ruby/ruby/pull/12801 changed regexp matches to reuse
the backref, which causes memory to leak if the original registers of the
match is not freed.
For example, the following script leaks memory:
10.times do
1_000_000.times do
"aaaaaaaaaaa".gsub(/a/, "")
end
puts `ps -o rss= -p #{$$}`
end
Before:
774256
1535152
2297360
3059280
3821296
4583552
5160304
5091456
5114256
4980192
After:
12480
11440
11696
11632
11632
11760
11824
11824
11824
11888
Notes:
Merged: https://github.com/ruby/ruby/pull/12905
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12901
|
|
The test could flake because a major GC could be triggered due to allocation
for caches or other things, which would cause the test to fail.
|
|
The test fails sometimes with:
TestGc#test_latest_gc_info_weak_references_count [test/ruby/test_gc.rb:421]:
Expected 2 to be <= 1.
Notes:
Merged: https://github.com/ruby/ruby/pull/12894
|
|
The following Location information has been added This is the information required for parse.y to be a universal parser:
```
❯ ruby --parser=prism --dump=parsetree -e "class A < B; end"
@ ProgramNode (location: (1,0)-(1,16))
+-- locals: []
+-- statements:
@ StatementsNode (location: (1,0)-(1,16))
+-- body: (length: 1)
+-- @ ClassNode (location: (1,0)-(1,16))
+-- locals: []
+-- class_keyword_loc: (1,0)-(1,5) = "class"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- constant_path:
| @ ConstantReadNode (location: (1,6)-(1,7))
| +-- name: :A
+-- inheritance_operator_loc: (1,8)-(1,9) = "<"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- superclass:
| @ ConstantReadNode (location: (1,10)-(1,11))
| +-- name: :B
+-- body: nil
+-- end_keyword_loc: (1,13)-(1,16) = "end"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- name: :A
```
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12879
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12878
|
|
TestSetTraceFunc#test_tracepoint_disable is a flaky and failing intermittently. Here is an example of failure logs.
```
1) Failure:
TestSetTraceFunc#test_tracepoint_disable [/home/runner/work/ruby/ruby/src/test/ruby/test_settracefunc.rb:857]:
<[:foo, :disable, :foo, :disable]> expected but was
<[:call, :call, :foo, :disable, :foo, :disable]>.
```
https://github.com/ruby/ruby/actions/runs/13619175633/job/38066208546?pr=12585#step:12:875
I printed values of TracePoint objects as follows, and checked the values when failing intermittently.
https://github.com/ruby/ruby/blob/7f9a6fc582fb5cfd88ab73a61782f39894a37ba6/test/ruby/test_settracefunc.rb#L848
Here is the log when the TestSetTraceFunc#test_tracepoint_disable failed intermittently.
`2025-03-05T09:08:37.4075411Z e: call, f: /home/runner/work/ruby/ruby/src/lib/tempfile.rb, l: 386, i: call, d: Tempfile::FinalizerManager` is an unexpected events. Thus, I modified test code so that we can filter out unexpected trace events.
```
2025-03-05T09:08:37.4075411Z e: call, f: /home/runner/work/ruby/ruby/src/lib/tempfile.rb, l: 386, i: call, d: Tempfile::FinalizerManager
2025-03-05T09:08:37.4085009Z e: call, f: /home/runner/work/ruby/ruby/src/test/ruby/test_settracefunc.rb, l: 808, i: foo, d: TestSetTraceFunc
2025-03-05T09:08:37.4086042Z e: call, f: <internal:trace_point>, l: 295, i: disable, d: TracePoint
2025-03-05T09:08:37.4115693Z e: call, f: /home/runner/work/ruby/ruby/src/test/ruby/test_settracefunc.rb, l: 808, i: foo, d: TestSetTraceFunc
2025-03-05T09:08:37.4116734Z e: call, f: <internal:trace_point>, l: 295, i: disable, d: TracePoint
```
Notes:
Merged-By: ono-max <[email protected]>
|
|
[Bug #21170]
st_table reserves -1 as a special hash value to indicate that an entry
has been deleted. So that that's a valid value to be returned from the
hash function, do_hash replaces -1 with 0 so that it is not mistaken for
the sentinel.
Previously, when upgrading an AR table to an ST table,
rb_st_add_direct_with_hash was used which did not perform the same
conversion, this could lead to a hash in a broken state where one if its
entries which was supposed to exist being marked as a tombstone.
The hash could then become further corrupted when the ST table required
resizing as the falsely tombstoned entry would be skipped but it would
be counted in num entries, leading to an uninitialized entry at index
15.
In most cases this will be really rare, unless using a very poorly
implemented custom hash function.
This also adds two debug assertions, one that st_add_direct_with_hash
does not receive the reserved hash value, and a second in
rebuild_table_with, which ensures that after we rebuild/compact a table
it contains the expected number of elements.
Co-authored-by: Alan Wu <[email protected]>
Notes:
Merged: https://github.com/ruby/ruby/pull/12852
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12837
|
|
Fix: https://github.com/ruby/spec/issues/1249
JRuby and TruffleRuby can't implement this behavior.
While quite a lot of code out there relies on it, if it's
not implemented it will simply result in sligthly less efficient
code, so not the end of the world.
Notes:
Merged: https://github.com/ruby/ruby/pull/12850
|
|
`YJIT.enable()` (#12505)
* first commit
* yjit.rb change
* revert formatting
* rename mem-size to exec-mem-size for correctness
* wip, move setting into rb_yjit_enable directly
* remove unused helper functions
* add in call threshold
* input validation with extensive eprintln
* delete test script
* exec-mem-size -> mem-size
* handle input validation with asserts
* add test cases related to input validation
* modify test cases
* move validation out of rs, into rb
* add comments
* remove trailing spaces
* remove logging
Co-authored-by: Takashi Kokubun <[email protected]>
* remove helper fn
* Update test/ruby/test_yjit.rb
Co-authored-by: Takashi Kokubun <[email protected]>
* trailing white space
---------
Co-authored-by: Alan Wu <[email protected]>
Co-authored-by: Takashi Kokubun <[email protected]>
Co-authored-by: Maxime Chevalier-Boisvert <[email protected]>
Notes:
Merged-By: maximecb <[email protected]>
|
|
The following Location information has been added This is the information required for parse.y to be a universal parser:
```
❯ ruby --parser=prism --dump=parsetree -e "END { }"
@ ProgramNode (location: (1,0)-(1,8))
+-- locals: []
+-- statements:
@ StatementsNode (location: (1,0)-(1,8))
+-- body: (length: 1)
+-- @ PostExecutionNode (location: (1,0)-(1,8))
+-- statements: nil
+-- keyword_loc: (1,0)-(1,3) = "END"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- opening_loc: (1,4)-(1,5) = "{"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- closing_loc: (1,7)-(1,8) = "}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
|
|
Co-authored-by: Nobuyoshi Nakada <[email protected]>
Notes:
Merged: https://github.com/ruby/ruby/pull/12787
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12787
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12819
|
|
It was defined in `arg` only; moved that pattern to `op_asgn` rule to
share it with `command_asgn`.
|
|
Otherwise, changes to the buffer by the destination write method
could result in data changing for supposedly independent strings.
Fixes [Bug #21131]
Notes:
Merged: https://github.com/ruby/ruby/pull/12771
|
|
|
|
We should skip reference updating for entries in too complex generic ivars
that are special constants. This fixes the following crash:
MAX_SHAPES = 0x80000
MAX_SHAPES.times do |i|
o = []
o.instance_variable_set(:"@foo#{i}", 1)
end
o = []
o.instance_variable_set(:"@a", 123)
GC.compact
Notes:
Merged: https://github.com/ruby/ruby/pull/12781
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12746
|
|
The instruction counter is slowing multi-Ractor applications. I had
changed it to use a thread local, but using a thread local is slowing
single threaded applications. This commit only enables the instruction
counter in YJIT stats builds until we can figure out a way to gather the
information with lower overhead.
Co-authored-by: Randy Stauner <[email protected]>
Notes:
Merged: https://github.com/ruby/ruby/pull/12670
|
|
Previously, Ruby displayed backtraces for each thread on deadlock. However, it has not been shown since Ruby 3.0.
It should display the backtrace for debugging.
Co-authored-by: Jeremy Evans <[email protected]>
Notes:
Merged-By: pocke <[email protected]>
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12740
|
|
sometimes.
|