Commit graph

93345 commits

Author SHA1 Message Date
Stan Lo
2b16f27a35
ZJIT: Fix ObjToString rewrite (#14196)
ZJIT: Fix ObjToString rewrite

Currently, the rewrite for `ObjToString` always replaces it with a
`SendWithoutBlock(to_s)` instruction when the receiver is not a
string literal. This is incorrect because it calls `to_s` on the
receiver even if it's already a string.

This change fixes it by:
- Avoiding the `SendWithoutBlock(to_s)` rewrite
- Implement codegen for `ObjToString`
2025-08-13 13:03:26 -07:00
BurdetteLamar
ff622978d0 [DOC] Tweaks for GC total time methods
Some checks failed
Windows / Windows 11-arm/Visual C++ (btest test-basic test-tool) (push) Waiting to run
Windows / Windows 2022/Visual C++ 2022 (check) (push) Waiting to run
Windows / Windows 2025/Visual C++ 2022 (check) (push) Waiting to run
Windows / Windows 2025/Visual C++ 2022 (test-bundled-gems) (push) Waiting to run
Windows / result (push) Blocked by required conditions
Ubuntu on WSL / wsl (push) Waiting to run
Annocheck / test-annocheck (push) Has been skipped
BASERUBY Check / BASERUBY (push) Has been skipped
parse.y / make (test-bundler-parallel) (push) Has been skipped
Check Dependencies / Dependency checks (push) Failing after 58s
CodeQL / Analyze (push) Has been skipped
Compilations / omnibus compilations, trigger (push) Has been skipped
Misc / Miscellaneous checks (push) Failing after 1m3s
Update default gems list / Update default gems list (push) Has been skipped
parse.y / make (check) (push) Has been skipped
parse.y / make (test-bundled-gems) (push) Has been skipped
WebAssembly / make (map[debugflags: name:O2 optflags:-O2 wasmoptflags:-O2]) (push) Has been skipped
Compilations / omnibus compilations, #1 (push) Has been skipped
Compilations / omnibus compilations, #2 (push) Has been skipped
Compilations / omnibus compilations, #3 (push) Has been skipped
Compilations / omnibus compilations, #4 (push) Has been skipped
Compilations / omnibus compilations, #5 (push) Has been skipped
Compilations / omnibus compilations, #6 (push) Has been skipped
Compilations / omnibus compilations, #7 (push) Has been skipped
Compilations / omnibus compilations, #8 (push) Has been skipped
Compilations / omnibus compilations, #9 (push) Has been skipped
Compilations / omnibus compilations, #10 (push) Has been skipped
Compilations / omnibus compilations, #11 (push) Has been skipped
Compilations / omnibus compilations, #12 (push) Has been skipped
Compilations / omnibus compilations, result (push) Successful in 58s
2025-08-13 14:42:17 -04:00
Max Bernstein
943d9f828d ZJIT: Don't eliminate NewHash with operands
Hashing and checking operands for equality is re-entrant. We could later
optimize this to check for hash/eq methods on operands and eliminate if
they don't have side effects, but this is fine for now.
2025-08-13 14:01:34 -04:00
Jean Boussier
2083fa89fc Implement gen_fields_tbl cache
There is a high likelyhood that `rb_obj_fields` is called
consecutively for the same object.

If we keep a cache of the last IMEMO/fields we interacted with,
we can save having to lookup the `gen_fields_tbl`, synchronize
the VM lock, etc.

On yjit-bench's, I instrumented the hit rate of this cache at:

  - `shipit`: 38%, with 111k hits.
  - `lobsters`: 59%, with 367k hits.
  - `rubocop`: 100% with only 300 hits.

I also ran a micro-benchmark which shows that ivar access is:

  - 1.25x faster when the cache is hit in single ractor mode.
  - 2x faster when the cache is hit in multi ractor mode.
  - 1.06x slower when the cache miss in single ractor mode.
  - 1.01x slower when the cache miss in multi ractor mode.

```yml
prelude: |
  class GenIvar < Array
    def initialize(...)
      super
      @iv = 1
    end

    attr_reader :iv
  end

  a = GenIvar.new
  b = GenIvar.new
benchmark:
  hit: a.iv; a.iv; a.iv; a.iv; a.iv; a.iv; a.iv; a.iv; a.iv; a.iv; a.iv; a.iv; a.iv; a.iv; a.iv; a.iv; a.iv; a.iv; a.iv; a.iv;
  miss: a.iv; b.iv; a.iv; b.iv; a.iv; b.iv; a.iv; b.iv; a.iv; b.iv; a.iv; b.iv; a.iv; b.iv; a.iv; b.iv; a.iv; b.iv; a.iv; b.iv;
```

Single ractor:
```
compare-ruby: ruby 3.5.0dev (2025-08-12T02:14:57Z master 428937a536) +YJIT +PRISM [arm64-darwin24]
built-ruby: ruby 3.5.0dev (2025-08-12T09:25:35Z gen-fields-cache 9456c35893) +YJIT +PRISM [arm64-darwin24]
warming up..

|      |compare-ruby|built-ruby|
|:-----|-----------:|---------:|
|hit   |      4.090M|    5.121M|
|      |           -|     1.25x|
|miss  |      3.756M|    3.534M|
|      |       1.06x|         -|
```

Multi-ractor:
```
compare-ruby: ruby 3.5.0dev (2025-08-12T02:14:57Z master 428937a536) +YJIT +PRISM [arm64-darwin24]
built-ruby: ruby 3.5.0dev (2025-08-12T09:25:35Z gen-fields-cache 9456c35893) +YJIT +PRISM [arm64-darwin24]
warming up..

|      |compare-ruby|built-ruby|
|:-----|-----------:|---------:|
|hit   |      2.205M|    4.460M|
|      |           -|     2.02x|
|miss  |      2.117M|    2.094M|
|      |       1.01x|         -|
```
2025-08-13 19:54:56 +02:00
Jean Boussier
10aa4134d4 imemo_fields: store owner object in RBasic.klass
It is much more convenient than storing the klass, especially
when dealing with `object_id` as it allows to update the id2ref
table without having to dereference the owner, which may be
garbage at that point.
2025-08-13 19:53:18 +02:00
Max Bernstein
ad12db4b3d ZJIT: Only validate HIR in debug mode 2025-08-13 13:52:41 -04:00
Peter Zhu
31ff07ed1e Add link to Ruby options doc in help text
Adds link to https://docs.ruby-lang.org/en/master/ruby/options_md.html in
Ruby help text (-h and --help).
2025-08-13 11:24:50 -04:00
Burdette Lamar
7595ac9a9e
[DOC] Tweaks for GC.count 2025-08-13 10:53:22 -04:00
Kazuhiro NISHIYAMA
40d07f268e [DOC] Move Therad#join under Thread in NEWS-3.0.0.md
Some checks failed
Update default gems list / Update default gems list (push) Has been skipped
Misc / Miscellaneous checks (push) Failing after 1m4s
2025-08-13 11:45:18 +09:00
Stan Lo
df7d9812cc
ZJIT: Prepare non-leaf calls for SetGlobal (#14197)
Some checks failed
Windows / Windows 11-arm/Visual C++ (btest test-basic test-tool) (push) Waiting to run
Windows / Windows 2022/Visual C++ 2022 (check) (push) Waiting to run
Windows / Windows 2025/Visual C++ 2022 (check) (push) Waiting to run
Windows / Windows 2025/Visual C++ 2022 (test-bundled-gems) (push) Waiting to run
Windows / result (push) Blocked by required conditions
Ubuntu on WSL / wsl (push) Waiting to run
Annocheck / test-annocheck (push) Failing after 59s
Check Dependencies / Dependency checks (push) Failing after 56s
Misc / Miscellaneous checks (push) Failing after 1m4s
CodeQL / Analyze (push) Failing after 56s
Compilations / omnibus compilations, trigger (push) Failing after 52s
Update default gems list / Update default gems list (push) Has been skipped
parse.y / make (check) (push) Failing after 56s
parse.y / make (test-bundled-gems) (push) Failing after 56s
parse.y / make (test-bundler-parallel) (push) Failing after 57s
WebAssembly / make (map[debugflags: name:O2 optflags:-O2 wasmoptflags:-O2]) (push) Failing after 1m1s
Compilations / omnibus compilations, #5 (push) Has been skipped
Compilations / omnibus compilations, #6 (push) Has been skipped
Compilations / omnibus compilations, #8 (push) Has been skipped
Compilations / omnibus compilations, #10 (push) Has been skipped
Compilations / omnibus compilations, #11 (push) Has been skipped
BASERUBY Check / BASERUBY (push) Failing after 52s
Compilations / omnibus compilations, #1 (push) Has been skipped
Compilations / omnibus compilations, #2 (push) Has been skipped
Compilations / omnibus compilations, #3 (push) Has been skipped
Compilations / omnibus compilations, #4 (push) Has been skipped
Compilations / omnibus compilations, #7 (push) Has been skipped
Compilations / omnibus compilations, #9 (push) Has been skipped
Compilations / omnibus compilations, #12 (push) Has been skipped
Compilations / omnibus compilations, result (push) Successful in 1m14s
When trace_var is used, setting a global variable can cause exceptions
to be raised. We need to prepare for that.
2025-08-12 17:39:46 -07:00
Luke Gruber
1afc07e815 Allow encodings to be autoloaded through transcoding functions
Make sure VM lock is not held when calling `load_transcoder_entry`, as
that causes deadlock inside ractors. `String#encode` now works inside
ractors, among others.

Atomic load the rb_encoding_list

Without this, wbcheck would sometimes hit a missing write barrier.

Co-authored-by: John Hawthorn <john.hawthorn@shopify.com>

Hold VM lock when iterating over global_enc_table.names

This st_table can be inserted into at runtime when autoloading
encodings.

minor optimization when calling Encoding.list
2025-08-12 15:19:02 -07:00
BurdetteLamar
31e8a9fced [DOC] Tweaks for GC.latest_gc_info 2025-08-12 17:06:15 -04:00
BurdetteLamar
8b530e1282 [DOC] Tweaks for GC.enable 2025-08-12 17:04:25 -04:00
BurdetteLamar
b934f989b9 [DOC] Tweaks for GC.disable 2025-08-12 17:04:06 -04:00
Takashi Kokubun
231407c251
ZJIT: Avoid compiling failed ISEQs repeatedly (#14195) 2025-08-12 13:40:42 -07:00
Jean Boussier
360be94d04 RTypedData: keep direct reference to IMEMO/fields
Similar to f3206cc79b but for TypedData.

It's quite common for TypedData objects to have a mix of reference in
their struct and some ivars.
Since we do happen to have 8B free in the RtypedData struct, we could
use it to keep a direct reference to the IMEMO/fields saving having
to synchronize the VM and lookup the `gen_fields_tbl` on every ivar
access.

For old school Data classes however, we don't have free space, but
this API is soft-deprecated and no longer very common.
2025-08-12 21:57:16 +02:00
Jean Boussier
85c52079aa set.c: Store set_table->bins at the end of set_table->entries
This saves one pointer in `struct set_table`, which would allow
`Set` objects to still fit in 80B TypedData slots even if RTypedData
goes from 32B to 40B large.

The existing set benchmark seem to show this doesn't have a very
significant impact. Smaller sets are a bit faster, larger sets
a bit slower.

It seem consistent over multiple runs, but it's unclear how much
of that is just error margin.

```
compare-ruby: ruby 3.5.0dev (2025-08-12T02:14:57Z master 428937a536) +YJIT +PRISM [arm64-darwin24]
built-ruby: ruby 3.5.0dev (2025-08-12T07:22:26Z set-entries-bounds da30024fdc) +YJIT +PRISM [arm64-darwin24]
warming up........

|                         |compare-ruby|built-ruby|
|:------------------------|-----------:|---------:|
|new_0                    |     15.459M|   15.823M|
|                         |           -|     1.02x|
|new_10                   |      3.484M|    3.574M|
|                         |           -|     1.03x|
|new_100                  |    546.992k|  564.679k|
|                         |           -|     1.03x|
|new_1000                 |     49.391k|   48.169k|
|                         |       1.03x|         -|
|aref_0                   |     18.643M|   19.350M|
|                         |           -|     1.04x|
|aref_10                  |      5.941M|    6.006M|
|                         |           -|     1.01x|
|aref_100                 |    822.197k|  814.219k|
|                         |       1.01x|         -|
|aref_1000                |     83.230k|   79.411k|
|                         |       1.05x|         -|
```
2025-08-12 21:56:57 +02:00
Kazuki Yamaguchi
507b1e4bde [ruby/openssl] pkey: skip tests using invalid keys in the FIPS mode
Some checks failed
parse.y / make (check) (push) Failing after 55s
Windows / Windows 2022/Visual C++ 2022 (check) (push) Waiting to run
Windows / Windows 2025/Visual C++ 2022 (check) (push) Waiting to run
Windows / Windows 2025/Visual C++ 2022 (test-bundled-gems) (push) Waiting to run
Windows / result (push) Blocked by required conditions
Ubuntu on WSL / wsl (push) Waiting to run
Annocheck / test-annocheck (push) Failing after 56s
Check Dependencies / Dependency checks (push) Failing after 59s
Update default gems list / Update default gems list (push) Has been skipped
CodeQL / Analyze (push) Failing after 55s
BASERUBY Check / BASERUBY (push) Failing after 52s
Misc / Miscellaneous checks (push) Failing after 1m1s
bundled_gems / update (push) Failing after 1m52s
Compilations / omnibus compilations, trigger (push) Failing after 52s
Compilations / omnibus compilations, #4 (push) Has been skipped
Compilations / omnibus compilations, #5 (push) Has been skipped
Compilations / omnibus compilations, #6 (push) Has been skipped
Compilations / omnibus compilations, #7 (push) Has been skipped
parse.y / make (test-bundled-gems) (push) Failing after 55s
WebAssembly / make (map[debugflags: name:O2 optflags:-O2 wasmoptflags:-O2]) (push) Failing after 55s
parse.y / make (test-bundler-parallel) (push) Failing after 56s
Compilations / omnibus compilations, #1 (push) Has been skipped
Compilations / omnibus compilations, #2 (push) Has been skipped
Compilations / omnibus compilations, #3 (push) Has been skipped
Compilations / omnibus compilations, #12 (push) Has been skipped
Compilations / omnibus compilations, #8 (push) Has been skipped
Compilations / omnibus compilations, #9 (push) Has been skipped
Compilations / omnibus compilations, #10 (push) Has been skipped
Compilations / omnibus compilations, #11 (push) Has been skipped
Compilations / omnibus compilations, result (push) Successful in 1m7s
In OpenSSL's master branch, importing/loading a key in the FIPS mode
automatically performs a pair-wise consistency check. This breaks tests
for OpenSSL::PKey::EC#check_key and DH#params_ok? as they use
deliberately invalid keys. These methods would not be useful in the
FIPS mode anyway.

Fixes https://github.com/ruby/openssl/issues/926

25ad8f4bdb
2025-08-12 18:08:37 +00:00
John Hawthorn
4cf05ea77a Replace stdatomic ops with explicit mem order
My previous pass missed these atomic operations using operators.
2025-08-12 10:38:00 -07:00
John Hawthorn
cb360b0b4b Implement rbimpl_atomic_value_load
This only adds the rbimpl_ version to include/ruby/atomic.h so that it
is not a new public interface.

We were already using RUBY_ATOMIC_VALUE_LOAD in a few locations. This
will allow us to use other memory orders internally when desired.
2025-08-12 10:38:00 -07:00
John Hawthorn
77d29ef73c Convert ATOMIC_LOAD_RELAXED to use new rbimpl_* 2025-08-12 10:38:00 -07:00
John Hawthorn
1d9f76096e Update rbimpl_atomic_* to all take a memory order 2025-08-12 10:38:00 -07:00
John Hawthorn
2f95eb4e80 Rename rbimpl_atomic.*_set to _store
"store" is the terminology the C11 standard uses, which allows us to use
this as a fallback.

This only changes the private rbimpl_ version of the method,
RUBY_ATOMIC_SET et al. keep the same name.
2025-08-12 10:38:00 -07:00
Peter Zhu
a9230e76ee Make Enumerator::Product write-barrier protected 2025-08-12 13:32:41 -04:00
Peter Zhu
3e1e2bda49 Make Enumerator::Chain write-barrier protected 2025-08-12 13:32:41 -04:00
Max Bernstein
998be6b3a4
ZJIT: Add flag to disable the HIR optimizer (#14181)
Also add a check in the bisect script that can assign blame to the HIR
optimizer.
2025-08-12 13:00:22 -04:00
Takashi Kokubun
e26ab5dbf2
ZJIT: Avoid splitting add_into/sub_into for x86_64 (#14177)
* ZJIT: Avoid splitting add_into/sub_into

* Require add_into/sub_into to take a Reg
2025-08-12 09:54:50 -07:00
Nobuyoshi Nakada
c5c894c6e4
[DOC] Markup example code as ruby 2025-08-12 23:43:46 +09:00
Nobuyoshi Nakada
cefd4a233f
[DOC] Use backticks instead of <tt> except for nested markups 2025-08-12 23:43:45 +09:00
Nobuyoshi Nakada
74b45dc3ee
[DOC] Use backticks instead of + in markdown mode 2025-08-12 23:43:45 +09:00
Nobuyoshi Nakada
e07510d1a3
[DOC] Markup constants as code 2025-08-12 23:43:45 +09:00
Nobuyoshi Nakada
58dbfe5285
[DOC] Fix a typo 2025-08-12 23:43:44 +09:00
Nobuyoshi Nakada
8f6f9e88c7
[DOC] Try the latest RDoc 2025-08-12 23:35:40 +09:00
Nobuyoshi Nakada
37e991b02c
[DOC] Use the specified revision RDoc 2025-08-12 23:33:48 +09:00
Peter Zhu
814eaf336a Use rb_gc_mark_and_move for autoload_data 2025-08-12 10:12:19 -04:00
Peter Zhu
0019e7c702 Use rb_gc_mark_and_move for autoload_const 2025-08-12 10:12:19 -04:00
Jun Aruga
9fa87a6688 CI: ubuntu.yml: Skip user ground id test on ppc64le and s390x
This is a temporary workaround.
2025-08-12 15:24:53 +02:00
Jun Aruga
05b654b43f CI: ubuntu.yml: Set HOME env on ppc64le and s390x
This is a temporary workaround.
2025-08-12 15:24:53 +02:00
Jun Aruga
099df0b40b CI: ubuntu.yml: Add GitHub Actions s390x case
Add the s390x case using GitHub Actions ppc64le/s390x service.
https://github.com/IBM/actionspz

We can run the ppc64le/s390x cases only in the registered upstream repositories.
https://github.com/IBM/actionspz/blob/main/docs/FAQ.md#what-about-forked-repos

The following matrix upstream logic is to skip the ppc64le/s390x in the
downstream (fork) repositories.

```
+        upstream:
+          - ${{ github.repository == 'ruby/ruby' }}
```

Use the "os" list to determine the excluded ppc64le/s390x cases by using the
"exclude" syntax. Because the "exclude" syntax are executed before the
"include" syntax.

Add the ubuntu-24.04-ppc64le as a comment, because the GitHub Actions ppc64le
case has the following test errors and failures.
https://bugs.ruby-lang.org/issues/21534
2025-08-12 15:24:53 +02:00
Nobuyoshi Nakada
e2aeb7d977
Use $(SRC_FILE) and $(OS_DEST_FILE)
NMake combines VPATH and stem with a backslash.  The resulting source
name is embedded verbatim, backslash included, into the generated file
using the `#line` pragma (e.g., "src\gc.rb").  This causes the warning
"C4129: Unrecognized character escape sequence".
2025-08-12 18:54:23 +09:00
Nobuyoshi Nakada
401932c18f
NMake needs caret to escape a hash sign 2025-08-12 18:19:09 +09:00
Nobuyoshi Nakada
6b2d9ed2a5
Handle preperly comments in middle of lines in gems/bundled_gems 2025-08-12 16:04:57 +09:00
Peter Zhu
428937a536 [DOC] Fix docs for GC.config
After commit 61fff8a, GC.config now returns the same hash for getting and
setting.
2025-08-11 22:14:57 -04:00
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