93655 Commits

Author SHA1 Message Date
Jeremy Evans
5c7dfe85a1
Initialize class dup/clone before calling initialize_dup/initialize_clone
Previously, you could override the class initialize_dup/initialize_clone
method and the class hierarchy would not be set correctly inside the
method before calling super.

This removes Module#initialize_copy, and instead makes Object#dup/clone
call the underlying C function (rb_mod_init_copy) before calling the
appropriate initialize_dup/initialize_clone method.

This results in the following fixes:

* The appropriate initialize_dup method is called (dup on a class
  will respect superclass initialize_dup).

* Inside class initialize_dup/initialize_clone/initialize_copy,
  class ancestor hierarchy is correct.

* Calling singleton_class inside initialize_dup no longer raises
  a TypeError later in dup.

* Calling singleton_class.ancestors inside initialize_dup no
  longer results in missing ancestors.

Fixes [Bug #21538]
2025-08-30 11:24:25 -07:00
S-H-GAMELINKS
dd4e7801f3 Add NODE SCLASS locations
Add locations to struct `RNode_SCLASS`.

memo:

```
@ ProgramNode (location: (1,0)-(1,18))
+-- locals: []
+-- statements:
    @ StatementsNode (location: (1,0)-(1,18))
    +-- body: (length: 1)
        +-- @ SingletonClassNode (location: (1,0)-(1,18))
            +-- locals: []
            +-- class_keyword_loc: (1,0)-(1,5) = "class"
            +-- operator_loc: (1,6)-(1,8) = "<<"
            +-- expression:
            |   @ SelfNode (location: (1,9)-(1,13))
            +-- body: nil
            +-- end_keyword_loc: (1,15)-(1,18) = "end"
```
2025-08-30 22:41:23 +09:00
Jean Boussier
395bda2fa1 object.c: make rb_obj_class_must static inline 2025-08-30 14:17:14 +02:00
Jean Boussier
d89e73471d object.c: refactor rb_obj_class and rb_class_real 2025-08-30 14:14:10 +02:00
Jean Boussier
f5da6395bd Kernel#class skip null check
`Kernel#class` can't possibly be called on an hidden object,
hence we don't need to check for `klass == 0`.

```
compare-ruby: ruby 3.5.0dev (2025-08-30T01:45:42Z obj-class 01a57bd6cd) +YJIT +PRISM [arm64-darwin24]
built-ruby: ruby 3.5.0dev (2025-08-30T10:21:10Z obj-class b67c16c477) +YJIT +PRISM [arm64-darwin24]

|           |compare-ruby|built-ruby|
|:----------|-----------:|---------:|
|obj        |     445.217|   642.446|
|           |           -|     1.44x|
|extended   |     136.826|   117.974|
|           |       1.16x|         -|
|singleton  |     166.269|   166.695|
|           |           -|     1.00x|
|immediate  |     380.243|   515.775|
|           |           -|     1.36x|
```
2025-08-30 14:14:10 +02:00
Jean Boussier
01b89528cb object.c: improve fake_class_p to also handle T_MODULE
This requires ensuring T_MODULE never has FL_SINGLETON set,
so RMODULE_IS_REFINEMENT had to be moved.
2025-08-30 14:14:10 +02:00
Jean Boussier
fd0c772db7 Micro-optimize Object#class
Since `BUILTIN_TYPE` and `RCLASS_SINGLETON_P` are both stored in
`RBasic.flags`, we can combine these two checks in a single bitmask.

This rely on `T_ICLASS` and `T_CLASS` not overlapping, and assume
`klass` is always either of these types.

Just combining the masks brings a small but consistent 1.08x speedup on the simple case benchmark.

```
compare-ruby: ruby 3.5.0dev (2025-08-30T01:45:42Z obj-class 01a57bd6cd) +YJIT +PRISM [arm64-darwin24]
built-ruby: ruby 3.5.0dev (2025-08-30T09:56:24Z obj-class 2685f8dbb4) +YJIT +PRISM [arm64-darwin24]

|           |compare-ruby|built-ruby|
|:----------|-----------:|---------:|
|obj        |     444.410|   478.895|
|           |           -|     1.08x|
|extended   |     135.139|   140.206|
|           |           -|     1.04x|
|singleton  |     165.155|   155.832|
|           |       1.06x|         -|
|immediate  |     380.103|   432.090|
|           |           -|     1.14x|
```

But with the RB_UNLIKELY compiler hint, it's much more significant, however
the singleton and enxtended cases are slowed down.
However we can assume the simple case is way more common than the other two.

```
compare-ruby: ruby 3.5.0dev (2025-08-30T01:45:42Z obj-class 01a57bd6cd) +YJIT +PRISM [arm64-darwin24]
built-ruby: ruby 3.5.0dev (2025-08-30T09:51:01Z obj-class 12d01a1b02) +YJIT +PRISM [arm64-darwin24]

|           |compare-ruby|built-ruby|
|:----------|-----------:|---------:|
|obj        |     444.951|   556.191|
|           |           -|     1.25x|
|extended   |     136.836|   113.871|
|           |       1.20x|         -|
|singleton  |     166.335|   167.747|
|           |           -|     1.01x|
|immediate  |     379.642|   509.515|
|           |           -|     1.34x|
```
2025-08-30 14:14:10 +02:00
Nobuyoshi Nakada
01a57bd6cd
CI: Warn longstanding development revision of bundled gems 2025-08-30 10:45:42 +09:00
Nobuyoshi Nakada
d94e0a7bca
CI: bundled_gems.yml: Split commit and push 2025-08-30 10:17:34 +09:00
Alan Wu
96c8938535
Shrink ruby_bug version guard in anticipation of 3.4.6 release
Fix for this bug was merged into ruby_3_4 in 5a42d267bfabc86f86cae2e83de24b1b86bc316a
and should go out in the next 3.4.x release.
2025-08-29 22:34:11 +00:00
Alan Wu
d4d510da18 Document Makefile rules in tool/enc-unicode.rb [ci skip] 2025-08-29 18:05:48 -04:00
Stan Lo
3f3a54efff Add rb_jit_vm_unlock and share it in ZJIT and YJIT 2025-08-29 12:55:14 -07:00
Stan Lo
561050496c Add rb_jit_vm_lock_then_barrier and share it in ZJIT and YJIT 2025-08-29 12:55:14 -07:00
Stan Lo
2f6a9c5167 Add rb_jit_multi_ractor_p and share it in ZJIT and YJIT 2025-08-29 12:55:14 -07:00
Alan Wu
cc07159fba [DOC] rb_str_resurrect(): Reword to remove wrong guess; used by zlib 2025-08-29 15:40:06 -04:00
Takashi Kokubun
39f3cab80d
YJIT: Stop sharing rb_vm_send among different instructions (#14393) 2025-08-29 11:43:33 -07:00
Max Bernstein
99bf47ab8c ZJIT: Report stats for unhandled call types 2025-08-29 10:42:39 -07:00
Max Bernstein
710c5c8ea1 ZJIT: Increment dynamic_send_count for Send too 2025-08-29 10:42:39 -07:00
Takashi Kokubun
dba0f72592 Extend timeout-minutes for macOS --repeat-count=2
https://github.com/ruby/ruby/actions/runs/17308244022/job/49136485007

I'm not sure if it's stuck forever at the end or happens to take that
much time around the end of it, but let me just try this first.

If it doesn't work, something's wrong with --repeat-count=2 on test-all.
2025-08-29 09:58:28 -07:00
Max Bernstein
b6f4b5399d
ZJIT: Specialize monomorphic GetIvar (#14388)
Specialize monomorphic `GetIvar` into:

* `GuardType(HeapObject)`
* `GuardShape`
* `LoadIvarEmbedded` or `LoadIvarExtended`

This requires profiling self for `getinstancevariable` (it's not on the operand
stack).

This also optimizes `GetIvar`s that happen as a result of inlining
`attr_reader` and `attr_accessor`.

Also move some (newly) shared JIT helpers into jit.c.
2025-08-29 12:46:08 -04:00
Takashi Kokubun
fc4f8c879a
YJIT: Drop yjit-bench CI job (#14394) 2025-08-29 09:40:15 -07:00
Max Bernstein
7f4a6afab8
ZJIT: Remove special case for defined?(method call) (#14401)
This was fixed in https://github.com/ruby/ruby/pull/14308

Thanks, Stan, for noticing.

Fixes https://github.com/Shopify/ruby/issues/703
2025-08-29 12:32:38 -04:00
Takashi Kokubun
df1334421f
ZJIT: Repurpose ExitCounters for unhandled YARV insns (#14392) 2025-08-29 07:22:40 -07:00
Nobuyoshi Nakada
dc555a48e7
Remove no longer used file [ci skip] 2025-08-29 16:25:05 +09:00
git
001299d32c Update bundled gems list as of 2025-08-29 2025-08-29 07:03:26 +00:00
Nobuyoshi Nakada
1f2a102f38
Module#attr family accepts strings as well as symbols 2025-08-29 11:35:28 +09:00
Hiroshi SHIBATA
85eb33d9ff
Relax thresholds for array, object, and string compaction verification
These tests failed with RHEL10

https://rubyci.s3.amazonaws.com/rhel10/ruby-master/log/20250828T093003Z.fail.html.gz
2025-08-29 09:33:17 +09:00
Takashi Kokubun
51cd877636 ZJIT: Add missing rb_zjit_cme_invalidate 2025-08-28 15:46:16 -07:00
Takashi Kokubun
3cc66977b2 ZJIT: Compile Insn::Send 2025-08-28 15:46:16 -07:00
Jean Boussier
4992d2c298 YJIT: rb_ivar_get_at skip ractor checks
Using `assume_single_ractor_mode` we can skip all ractor safety
checks if we're in single ractor mode.

```
compare-ruby: ruby 3.5.0dev (2025-08-27T14:58:58Z merge-vm-setivar-d.. 5b749d8e53) +YJIT +PRISM [arm64-darwin24]
built-ruby: ruby 3.5.0dev (2025-08-28T21:23:38Z yjit-get-exivar 3cc21b76d4) +YJIT +PRISM [arm64-darwin24]

|                           |compare-ruby|built-ruby|
|:--------------------------|-----------:|---------:|
|vm_ivar_get_on_obj         |     975.981|   975.772|
|                           |       1.00x|         -|
|vm_ivar_get_on_class       |     136.214|   470.912|
|                           |           -|     3.46x|
|vm_ivar_get_on_generic     |     148.315|   299.122|
|                           |           -|     2.02x|
```
2025-08-29 00:02:29 +02:00
Jean Boussier
3646596e5b YJIT: rb_ivar_get_at assume leaf-call when single ractor
The only exception it could raise is if we're in multi ractor mode.
2025-08-29 00:02:29 +02:00
Jean Boussier
b6d4882c05 YJIT: getinstancevariable cache indexes for types other than T_OBJECT
While accessing the ivars of other types is too complicated to
realistically generate the ASM for it, we can at least provide
the ivar index as to not have to lookup the shape tree every
time.

```
compare-ruby: ruby 3.5.0dev (2025-08-27T14:58:58Z merge-vm-setivar-d.. 5b749d8e53) +YJIT +PRISM [arm64-darwin24]
built-ruby: ruby 3.5.0dev (2025-08-28T17:58:32Z yjit-get-exivar efaa8c9b09) +YJIT +PRISM [arm64-darwin24]

|                           |compare-ruby|built-ruby|
|:--------------------------|-----------:|---------:|
|vm_ivar_get_on_obj         |     930.458|   936.865|
|                           |           -|     1.01x|
|vm_ivar_get_on_class       |     134.471|   431.622|
|                           |           -|     3.21x|
|vm_ivar_get_on_generic     |     146.679|   284.408|
|                           |           -|     1.94x|
```

Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
2025-08-29 00:02:29 +02:00
Jean Boussier
b1dbcd3ce3 YJIT simplify gen_get_iver and gen_set_ivar
The `shape_id` now includes 3 bits for the `heap_id`.
It is always non-zero for `T_OBJECT` and always zero for all
other types.

Hence all these allocator checks are no longer necessary.
2025-08-28 23:21:48 +02:00
Takashi Kokubun
bf3d6a17ee
ZJIT: Add code_region_bytes stat (#14389)
* ZJIT: Add code_region_bytes stat

* Share more logic among --zjit and --zjit-stats
2025-08-28 13:45:35 -07:00
Jean Boussier
041450ad41 rb_ivar_delete: also re-embed T_IMEMO/fields
Right now JITs don't generate any code to access ivar on types
other than T_OBJECT, but they might soon, so we must ensure
two IMEMO/fields can't have the same `shape_id` but diffent
embed/heap status.
2025-08-28 20:14:01 +02:00
Stan Lo
fa3c23eb81
ZJIT: Prepare getglobal for non-leaf call (#14387)
Depending on the user's warning level, getting certain global variables
may lead to calling `Warning#warn`, which can be redefined by the user.

This fixes another `bootstraptest/test_yjit.rb` failure.
2025-08-28 17:50:22 +00:00
Takashi Kokubun
b47ea34a9b ZJIT: Fix a flipped stat
I'm sorry.

Another follow-up on https://github.com/ruby/ruby/pull/14378
2025-08-28 10:35:16 -07:00
Takashi Kokubun
c2d99d0647 ZJIT: Fix a typo
follow-up on https://github.com/ruby/ruby/pull/14378
2025-08-28 10:31:47 -07:00
Max Bernstein
7d670ead30
ZJIT: Disable profiling in compile_iseq (#14385)
This catches both the interpreter-JIT and JIT-JIT cases.

Fixes https://github.com/Shopify/ruby/issues/719
2025-08-28 17:20:15 +00:00
Max Bernstein
8521725225 ZJIT: Generate code for ArrayExtend 2025-08-28 10:14:37 -07:00
Max Bernstein
07e28ba486 ZJIT: Generate code for DefinedIvar 2025-08-28 10:14:37 -07:00
Max Bernstein
b108f11708 ZJIT: Generate code for ToArray, ToNewArray 2025-08-28 10:14:37 -07:00
Max Bernstein
ec55b5b9aa ZJIT: Generate code for ArrayPush 2025-08-28 10:14:37 -07:00
Max Bernstein
ca0ef79497 ZJIT: Generate code for HashDup 2025-08-28 10:14:37 -07:00
Max Bernstein
11f115b0d2 ZJIT: Track if object is a T_OBJECT
We will (for now) only cache ivar reads from T_OBJECTs.
2025-08-28 09:40:59 -07:00
Max Bernstein
b95700f17c ZJIT: Track object embedded bit
This lets us know where to look for an ivar: in the object or indirect
elsewhere in the heap.
2025-08-28 09:40:59 -07:00
Stan Lo
737ffd3317
ZJIT: Add Ractor mode PatchPoint for ivar get/set (#14375)
* ZJIT: Add Ractor mode PatchPoint for ivar get/set

* ZJIT: Only add single ractor patchpoint to class/module receivers

* ZJIT: Improve Ractor mode patch point comments

Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>

---------

Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2025-08-28 09:31:26 -07:00
Takashi Kokubun
c4c93a0751
ZJIT: Refactor stats implementations (#14378)
* ZJIT: Refactor stats implementations

* s/num_send_dynamic/dynamic_send_count/
2025-08-28 08:58:23 -07:00
Jun Aruga
4fc0db7389 CI: ubuntu-ibm.yml: Add GitHub Actions ppc64le case
Note that the default configure option `./configure cppflags=-DRUBY_DEBUG` with
the default optimization level `-O3`, causes the following Ractor test and other
tests failing. So, we don't set the option in ppc64le case.

```
$ make btest BTESTS=bootstraptest/test_ractor.rb
```

See https://bugs.ruby-lang.org/issues/21534 for details.
2025-08-28 14:55:43 +01:00
Jun Aruga
dd09d8987c CI: ubuntu-ibm.yml: Refactor
* Remove logic that was used for the ubuntu.yml, but not used for
  ubuntu-ibm.yml.
* Add a dummy Ubuntu x86_64 case to make this CI pass on fork repositories.
  This case only runs on fork repositories.
2025-08-28 14:55:43 +01:00