Commit graph

93302 commits

Author SHA1 Message Date
Burdette Lamar
306df12949
[DOC] New .md file to replace doc/globals.rdoc 2025-08-11 22:02:59 -04:00
Sutou Kouhei
f2c7968a42 [ruby/stringio] Fix test name
(https://github.com/ruby/stringio/pull/139)

0edc8e22da
2025-08-12 01:16:46 +00:00
Alan Wu
8b1afbc6ed CI: Surface Rust warnings on PRs that touch any Rust code
Rust PRs will have a failed CI step if they trigger any warnings.
This helps us stay on top of warnings from new Rust releases and
also ones we accidentally write.

Fix a typo for demo, since this only runs when Rust files are changed.
2025-08-11 20:12:25 -04:00
Alan Wu
0070c26aec ZJIT: CI: Use Rust version built into GitHub Actions image
Saves the work of installing Rust for most jobs. Keep a job on each
platform that tests 1.85.0, the minimum supported version, though.
2025-08-11 18:53:48 -04:00
Stan Lo
4da569b53e [DOC] YJIT: Add YJIT to autolink_excluded_words 2025-08-11 18:37:51 -04:00
Stan Lo
39effad486 [DOC] ZJIT: Add ZJIT to autolink_excluded_words
This tells RDoc to not automatically link to the `ZJIT` module so we
don't need to keep escaping the word ZJIT in the documentation/comments.
2025-08-11 18:37:51 -04:00
Takashi Kokubun
9fb34f4f16
ZJIT: Add --zjit-exec-mem-size (#14175)
* ZJIT: Add --zjit-exec-mem-size

* Add a comment about the limit
2025-08-11 15:36:37 -07:00
Stan Lo
e29d333454
ZJIT: Implement concatstrings insn (#14154)
Co-authored-by: Alexander Momchilov <alexander.momchilov@shopify.com>
2025-08-11 15:07:26 -07:00
Takashi Kokubun
4f34eddbd3
YJIT, ZJIT: Fix JITs compiling prelude (#14171) 2025-08-11 14:35:34 -07:00
Takashi Kokubun
319550527f
ZJIT: Add compile/profile/GC/invalidation time stats (#14158)
Co-authored-by: Stan Lo <stan001212@gmail.com>
2025-08-11 13:21:45 -07:00
Takashi Kokubun
6968668570
ZJIT: Add RubyVM::ZJIT.enabled? (#14159)
Co-authored-by: Max Bernstein <tekknolagi@gmail.com>
2025-08-11 13:18:52 -07:00
Alan Wu
6e3790b17f YJIT: Fix mismatched_lifetime_syntaxes, new in Rust 1.89.0 2025-08-11 15:49:14 -04:00
Alan Wu
5b956fbf60 ZJIT: Fix mismatched_lifetime_syntaxes, new in Rust 1.89.0 2025-08-11 15:49:14 -04:00
Peter Zhu
61fff8a92f Fix return value of setting in GC.config
gc_config_set returned rb_gc_impl_config_get, but gc_config_get also added
the implementation key to the return value. This caused the return value
of GC.config to differ depending on whether the optional hash argument is
provided or not.
2025-08-11 10:20:33 -04:00
S-H-GAMELINKS
4775d1ffa8 Add NODE IN locations
Add locations to struct `RNode_IN`.

memo:

```bash
> ruby -e 'case 1; in 2 then 3; end' --parser=prism --dump=parsetree
@ ProgramNode (location: (1,0)-(1,24))
+-- locals: []
+-- statements:
    @ StatementsNode (location: (1,0)-(1,24))
    +-- body: (length: 1)
        +-- @ CaseMatchNode (location: (1,0)-(1,24))
            +-- predicate:
            |   @ IntegerNode (location: (1,5)-(1,6))
            |   +-- IntegerBaseFlags: decimal
            |   +-- value: 1
            +-- conditions: (length: 1)
            |   +-- @ InNode (location: (1,8)-(1,19))
            |       +-- pattern:
            |       |   @ IntegerNode (location: (1,11)-(1,12))
            |       |   +-- IntegerBaseFlags: decimal
            |       |   +-- value: 2
            |       +-- statements:
            |       |   @ StatementsNode (location: (1,18)-(1,19))
            |       |   +-- body: (length: 1)
            |       |       +-- @ IntegerNode (location: (1,18)-(1,19))
            |       |           +-- IntegerBaseFlags: decimal
            |       |           +-- value: 3
            |       +-- in_loc: (1,8)-(1,10) = "in"
            |       +-- then_loc: (1,13)-(1,17) = "then"
            +-- else_clause: nil
            +-- case_keyword_loc: (1,0)-(1,4) = "case"
            +-- end_keyword_loc: (1,21)-(1,24) = "end"
```
2025-08-11 22:25:47 +09:00
Burdette Lamar
e0b72ad2f1
[DOC] Update JIT options 2025-08-11 09:25:07 -04:00
BurdetteLamar
ad14632095 [DOC] Tweaks for GC.config 2025-08-11 09:24:06 -04:00
BurdetteLamar
62b5fe8984 [DOC] Tweaks for GC.config 2025-08-11 09:24:06 -04:00
Erim Icel
c914389ae8 Update string_casecmp.yml 2025-08-11 22:22:38 +09:00
Erim Icel
09d6cfc55c Update test_string.rb 2025-08-11 22:22:38 +09:00
Erim Icel
5e324ac11c Optimize str_casecmp length check using pointer end 2025-08-11 22:22:38 +09:00
Nobuyoshi Nakada
df11c073f3
[DOC] Fix vssetup.cmd arguments 2025-08-11 20:29:55 +09:00
Hiroshi SHIBATA
b0a4e2399b
CI: mingw: Use the official actions for msys2
Because ruby/setup-ruby is affected to test result.
2025-08-11 20:29:55 +09:00
Nobuyoshi Nakada
4adb6f6969
CI: mingw: Set up msys2 environment variables 2025-08-11 20:29:55 +09:00
Nobuyoshi Nakada
a443cd012a
CI: mingw: Set cmd as the default shell
It is used in more steps than `sh`.
2025-08-11 20:29:55 +09:00
Nobuyoshi Nakada
cc4eba000b
Win: Use @ instead of echo off in vssetup.cmd
`echo off` affects the batch files called from this file as well.
2025-08-11 20:29:55 +09:00
Nobuyoshi Nakada
c1f9f0a7ef
CI: windows: Windows-2019 or earlier no longer used 2025-08-11 20:29:55 +09:00
Nobuyoshi Nakada
90f8199412
CI: mingw: Tweak misc system & package info 2025-08-11 20:29:55 +09:00
Jean Boussier
2a6345e957 time.c: fix time_mark_and_move when WIDEVALUE_IS_WIDER
In such case the pointer need to be casted.
2025-08-09 13:32:53 +02:00
Nobuyoshi Nakada
77b3495e97 [ruby/stringio] Adjust indent [ci skip]
ac6292c17f
2025-08-09 11:16:03 +00:00
Nobuyoshi Nakada
b4d5ebcd12 [ruby/stringio] Fix SEGV at eof? on null StringIO
29b9133332
2025-08-09 11:12:48 +00:00
Nobuyoshi Nakada
31f2d8990d [ruby/stringio] Fix SEGV at read/pread on null StringIO
113dd5a55e
2025-08-09 11:12:48 +00:00
koh-sh
23c0113932 [ruby/stringio] fix: prevent segfault in StringIO#seek with SEEK_END
on null device
(https://github.com/ruby/stringio/pull/137)

Fixes segmentation fault when calling `seek` with `SEEK_END` on null
device StringIO created by
  `StringIO.new(nil)`.

```bash
ruby -e "require 'stringio'; StringIO.new(nil).seek(0, IO::SEEK_END)"
```

I tested with below versions.

```bash
[koh@Kohs-MacBook-Pro] ~
% ruby -v;gem info stringio;sw_vers
ruby 3.4.5 (2025-07-16 revision 20cda200d3) +PRISM [arm64-darwin24]

*** LOCAL GEMS ***

stringio (3.1.2)
    Authors: Nobu Nakada, Charles Oliver Nutter
    Homepage: https://github.com/ruby/stringio
    Licenses: Ruby, BSD-2-Clause
    Installed at (default): /Users/koh/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0

    Pseudo IO on String
ProductName:            macOS
ProductVersion:         15.5
BuildVersion:           24F74
[koh@Kohs-MacBook-Pro] ~
%
```

9399747bf9
2025-08-09 09:30:27 +00:00
Ethan
60ca525fce [DOC] Array#map! fix to indicate return is self 2025-08-09 11:10:51 +09:00
Ethan
4209ebb1e4 [DOC] Array#fill fix to indicate return is self
doc currently indicates the return value as `new_array` but then in the first sentence explains "always returns +self+ (never a new array)".
2025-08-09 11:10:51 +09:00
Carl Zulauf
22fe80f275 Fix Typo in Regular Expressions docs (_regexp.rdoc)
Small fix for a typo in the regular expression docs. The line of code above this change does not produce the output shown in the docs. With this change the docs will show the correct output for this example of using regex quantifiers.
2025-08-09 11:02:37 +09:00
John Hawthorn
d80c03d22a Fix id2ref table build when GC in progress
Previously, if GC was in progress when we're initially building the
id2ref table, it could see the empty table and then crash when trying to
remove ids from it. This commit fixes the bug by only publishing the
table after GC is done.

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2025-08-08 17:13:25 -07:00
Luke Gruber
07878ebe78 Fix lock ordering issue for rb_ractor_sched_wait() and rb_ractor_sched_wakeup()
In rb_ractor_sched_wait() (ex: Ractor.receive), we acquire
RACTOR_LOCK(cr) and then thread_sched_lock(cur_th). However, on wakeup
if we're a dnt, in thread_sched_wait_running_turn() we acquire
thread_sched_lock(cur_th) after condvar wakeup and then RACTOR_LOCK(cr).
This lock inversion can cause a deadlock with rb_ractor_wakeup_all()
(ex: port.send(obj)), where we acquire RACTOR_LOCK(other_r) and then
thread_sched_lock(other_th).

So, the error happens:

nt 1:   Ractor.receive
            rb_ractor_sched_wait() after condvar wakeup in thread_sched_wait_running_turn():
              - thread_sched_lock(cur_th) (condvar) # acquires lock
              - rb_ractor_lock_self(cr) # deadlock here: tries to acquire, HANGS

nt 2: port.send
            ractor_wakeup_all()
              - RACTOR_LOCK(port_r) # acquires lock
              - thread_sched_lock # tries to acquire, HANGS

To fix it, we now unlock the thread_sched_lock before acquiring the
ractor_lock in rb_ractor_sched_wait().

Script that reproduces issue:

```ruby
require "async"
class RactorWrapper
  def initialize
    @ractor = Ractor.new do
      Ractor.recv # Ractor doesn't start until explicitly told to
      # Do some calculations
      fib = ->(x) { x < 2 ? 1 : fib.call(x - 1) + fib.call(x - 2) }
      fib.call(20)
    end
  end

  def take_async
    @ractor.send(nil)
    Thread.new { @ractor.value }.value
  end
end

Async do |task|
  10_000.times do |i|
    task.async do
      RactorWrapper.new.take_async
      puts i
    end
  end
end
exit 0
```

Fixes [Bug #21398]

Co-authored-by: John Hawthorn <john.hawthorn@shopify.com>
2025-08-08 13:37:31 -07:00
Peter Zhu
e639e5fd1a Make rb_gc_impl_writebarrier_remember Ractor-safe
rb_gc_impl_writebarrier_remember is not Ractor safe because it writes to
bitmaps and also pushes onto the mark stack during incremental marking.
We should acquire the VM lock to prevent race conditions.

In the case that the object is not old, there is no performance impact.
However, we can see a performance impact in this microbenchmark where the
object is old:

    4.times.map do
      Ractor.new do
        ary = []

        3.times { GC.start }

        10_000_000.times do |i|
          ary.push(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)
          ary.clear
        end
      end
    end.map(&:value)

Before:

    Time (mean ± σ):     682.4 ms ±   5.1 ms    [User: 2564.8 ms, System: 16.0 ms]

After:

    Time (mean ± σ):      5.522 s ±  0.096 s    [User: 8.237 s, System: 7.931 s]

Co-Authored-By: Luke Gruber <luke.gruber@shopify.com>
Co-Authored-By: John Hawthorn <john@hawthorn.email>
2025-08-08 16:04:11 -04:00
Alan Wu
0ba488d7f5
ZJIT: Avoid compiling and direct sends to forwardable ISEQs
These `...` ISEQs have a special calling convention in the interpreter
and our stubs and JIT calling convention don't deal well. Reject for now.
Debugged with help from `@tekknolagi` and `tool/zjit_bisect.rb`.

Merely avoiding direct sends is enough to pass the attached test, but also
avoid compiling ISEQs with `...` parameter to limit exposure for now.

`SendWithoutBlock`, which does dynamic dispatch using interpreter code,
seems to handle calling into forwardable ISEQs correctly, so they are
fine -- we can't predict where these dynamic sends land anyways.
2025-08-08 18:54:53 +00:00
Takashi Kokubun
eb931a09c5
ZJIT: Fix "memory operand with non-register base" (#14153) 2025-08-08 11:24:39 -07:00
Max Bernstein
8eb26ebf91
ZJIT: Add a graphviz dumper for HIR (#14117)
This is moderately useful just in stdout (copy and paste into a renderer) but potentially more useful alongside a tool that parses stdout looking for `digraph G { ... }` and renders those automatically.
2025-08-08 13:56:19 -04:00
Jean Boussier
057d7c1c58 object_id_to_ref: complete incremental GC before iterating
Otherwise dealing with garbage objects is tricky.
2025-08-08 19:06:59 +02:00
Nobuyoshi Nakada
e4b386e090
CI: Remove Strawberry Perl pkg-config 2025-08-09 01:02:34 +09:00
Nobuyoshi Nakada
7b5cd5ce15
Revert "Convert PKG_CONFIG_PATH to msys/cygwin path"
This reverts commit 8e9ea4c202.

The environment variable is converted internally.
2025-08-09 01:01:47 +09:00
Max Bernstein
c6a27a0253 ZJII: Address review feedback 2025-08-08 08:15:18 -07:00
Max Bernstein
180469a3a7 ZJIT: Actually kill timed-out process in bisect 2025-08-08 08:15:18 -07:00
Max Bernstein
0782bd2826 ZJIT: Use OptionParser in bisect script 2025-08-08 08:15:18 -07:00
Max Bernstein
fd6d6a45cd ZJIT: Use shellwords in bisect script 2025-08-08 08:15:18 -07:00
Max Bernstein
0b30cf3b40 ZJIT: Print out command to repro in bisect script 2025-08-08 08:15:18 -07:00