94632 Commits

Author SHA1 Message Date
Koichi Sasada
bc00c4468e use SET_SHAREABLE
to adopt strict shareable rule.

* (basically) shareable objects only refer shareable objects
* (exception) shareable objects can refere unshareable objects
  but should not leak reference to unshareable objects to Ruby world
2025-10-23 13:08:26 +09:00
Koichi Sasada
45907b1b00 add SET_SHAREABLE macros
* `RB_OBJ_SET_SHAREABLE(obj)` makes obj shareable.
  All of reachable objects from `obj` should be shareable.
* `RB_OBJ_SET_FROZEN_SHAREABLE(obj)` same as above
  but freeze `obj` before making it shareable.

Also `rb_gc_verify_shareable(obj)` is introduced to check
the `obj` does not violate shareable rule (an shareable object
only refers shareable objects) strictly.

The rule has some exceptions (some shareable objects can refer to
unshareable objects, such as a Ractor object (which is a shareable
object) can refer to the Ractor local objects.
To handle such case, `check_shareable` flag is also introduced.

`STRICT_VERIFY_SHAREABLE` macro is also introduced to verify
the strict shareable rule at `SET_SHAREABLE`.
2025-10-23 13:08:26 +09:00
Daniel Colson
271be0a225
ZJIT: Implement classvar get and set (#14918)
https://github.com/Shopify/ruby/issues/649

Class vars are a bit more involved than ivars, since we need to get the
class from the cref, so this calls out to `rb_vm_getclassvariable` and
`rb_vm_setclassvariable` like YJIT.
2025-10-22 20:01:26 -07:00
Burdette Lamar
da214cf3a9 [DOC] Tweaks for StringIO#binmode (#147) 2025-10-23 01:00:26 +00:00
Burdette Lamar
f762e50bcb [ruby/stringio] [DOC] Tweaks for StringIO.open
(https://github.com/ruby/stringio/pull/146)

https://github.com/ruby/stringio/commit/141c6c0edf
2025-10-23 00:52:17 +00:00
Hiroshi SHIBATA
4368e6c42e [ruby/rubygems] Removed credential assertion from stdout
https://github.com/ruby/rubygems/commit/3946be008c
2025-10-23 00:49:07 +00:00
Hiroshi SHIBATA
8b014b1bbf [ruby/rubygems] Bump up vendored uri to 1.0.4
https://github.com/ruby/rubygems/commit/bc77ec0bf2
2025-10-23 00:49:07 +00:00
niku
36e7db00c9 [DOC] Tweaks for TCPSocket.new 2025-10-23 09:16:15 +09:00
Max Bernstein
c3404d736f ZJIT: Use InvokeBuiltin leaf attribute in codegen 2025-10-22 17:10:14 -07:00
Max Bernstein
fa5481bc06 ZJIT: Fetch Primitive.attr!(leaf) for InvokeBuiltin
Fix https://github.com/Shopify/ruby/issues/670
2025-10-22 17:10:14 -07:00
Peter Zhu
da4bd3b3df Fix memory leak when RUBYOPT is invalid
When RUBYOPT is invalid, it raises an error which causes moreswitches
to leak memory. It can be seen when building with LSAN enabled:

    $ RUBY_FREE_AT_EXIT=1 RUBYOPT=f ruby
    ruby: invalid option -f  (-h will show valid options) (RuntimeError)

    Direct leak of 16 byte(s) in 1 object(s) allocated from:
        #0 0x618cef8efa23 in malloc (miniruby+0x64a23)
        #1 0x618cefa0e8d8 in rb_gc_impl_malloc gc/default/default.c:8182:5
        #2 0x618cef9f7f01 in ruby_xmalloc2_body gc.c:5182:12
        #3 0x618cef9f7eac in ruby_xmalloc2 gc.c:5176:34
        #4 0x618cefb547b2 in moreswitches ruby.c:919:18
        #5 0x618cefb526fe in process_options ruby.c:2350:9
        #6 0x618cefb524ac in ruby_process_options ruby.c:3202:12
        #7 0x618cef9dc11f in ruby_options eval.c:119:16
        #8 0x618cef8f2fb5 in rb_main main.c:42:26
        #9 0x618cef8f2f59 in main main.c:62:12
2025-10-22 19:36:47 -04:00
Alan Wu
dfcb79ca63 ZJIT: Fix unused warnings in make zjit-test [ci skip] 2025-10-22 19:35:24 -04:00
Max Bernstein
ae767b6ca8
ZJIT: Inline Kernel#block_given? (#14914)
Fix https://github.com/Shopify/ruby/issues/832
2025-10-22 23:26:37 +00:00
Max Bernstein
a763e6dd48
ZJIT: Disable not-annotated cfuncs in --zjit-stats (#14915)
It's mostly a duplicate of not-inlined-cfuncs right now.
2025-10-22 22:40:52 +00:00
BurdetteLamar
d4ea1686b5 [DOC] Tweaks for String#split 2025-10-22 18:13:58 -04:00
BurdetteLamar
f9338a95af [DOC] Tweaks for String#squeeze 2025-10-22 18:04:20 -04:00
Alan Wu
71e3ef3d9c ZJIT: Buffer writes to the perf map 2025-10-22 17:24:21 -04:00
Alan Wu
fee863b4df YJIT: Buffer writes to the perf map 2025-10-22 17:24:21 -04:00
Aiden Fox Ivey
3861918fd3
ZJIT: Handle invalid Counter on --zjit-trace-exits=counter (#14911) 2025-10-22 21:16:52 +00:00
Benoit Daloze
fa3a6f5cde Add docs for --zjit-debug 2025-10-22 22:52:25 +02:00
Max Bernstein
9ad902e55c ZJIT: Inline String#==, String#=== 2025-10-22 12:39:57 -07:00
Max Bernstein
d792de29bc ZJIT: Fix Type::from_class for subclasses of built-in types 2025-10-22 12:39:57 -07:00
Aiden Fox Ivey
18e8e446ac
ZJIT: Revert removal of empty samples from zjit trace exits (#14905)
ZJIT: Revert 9a75c05
2025-10-22 18:53:12 +00:00
Max Bernstein
6fdcd08eb5 ZJIT: Fix land race 2025-10-22 11:22:53 -07:00
Max Bernstein
ceed406958
ZJIT: Inline simple SendWithoutBlockDirect (#14888)
Copy the YJIT simple inliner except for the kwargs bit. It works great!
2025-10-22 11:19:08 -07:00
Takashi Kokubun
f09e74ce2b
ZJIT: Fix some dead code in the backend (#14897) 2025-10-22 11:14:39 -07:00
Max Bernstein
87fdd6d53b
ZJIT: Support make in zjit_bisect.rb (#14584)
Find ZJIT options in RUN_OPTS/SPECOPTS and put new ones from the bisection script
there too.
2025-10-22 17:56:02 +00:00
Earlopain
4c60fc48b1 [ruby/prism] Test against parse.y
17a6a19bba broke ruby/ruby CI
because some tests are only run against parse.y
This will catch that in the future.

https://github.com/ruby/prism/commit/98e1cd5c04
2025-10-22 17:11:46 +00:00
Alan Wu
619110b1db ZJIT: A64: Fix Lea with large displacement and overlapping register
Previously, when the output register and the base register are the same
in `out = Lea(Mem(out, disp))`, we did

    out = disp
    out = out + out

Which wasn't the desired `out = out + disp`.

Fixes a SEGV with `--zjit-call-threshold=2` in
`bootstraptest/test_yjit.rb`.
2025-10-22 12:43:33 -04:00
Aiden Fox Ivey
839b1fa54f
ZJIT: Specialize String#<< to StringAppend (#14861)
Fixes https://github.com/Shopify/ruby/issues/805
2025-10-22 16:07:26 +00:00
Earlopain
6047eada20 [ruby/prism] Make error and snapshot tests multi-version aware
This one has been on my mind for a while now.

Currently, there are only tests against the latest syntax version.

This changes the snapshot structure as follows:
* Snapshots at their current location are tested against all syntax versions
* Snapshots inside a version folder like "3.3" are tested against all versions starting from that version
* Snapshots inside a version folder like "3.3-4.2" are tested against all versions in the given range.

This makes sure that as new syntax is added, older versions still work as expected.
I also added a few tests for now valid syntax that should be invalid in older versions (and the other way around as well)

These tests run really fast. So even though it does 3x the work for these, I am still able to run the whole test suite in just 11 seconds.

https://github.com/ruby/prism/commit/5191b1aa68
2025-10-22 14:50:11 +00:00
git
66c12bd519 Update bundled gems list as of 2025-10-22 2025-10-22 06:53:46 +00:00
Peter Zhu
f46ebed2ff Fix memory leak of darray in loaded_features_index 2025-10-21 20:21:45 -04:00
Alan Wu
a2a107c2d7 ZJIT: Handle when SetIvar raises FrozenError 2025-10-21 18:52:14 -04:00
Peter Zhu
4a23b6a89f Fix memory leak in RCLASS_SET_NAMESPACE_CLASSEXT
The st_insert in RCLASS_SET_NAMESPACE_CLASSEXT may overwrite an existing
rb_classext_t, causing it to leak memory. This commit changes it to use
st_update to free the existing one before overwriting it.
2025-10-21 18:42:17 -04:00
Peter Zhu
cd42096f5a Move rb_class_classext_free to class.c 2025-10-21 18:42:17 -04:00
Benoit Daloze
0cc4819f24 Improve test_fixnum_{and,or}* by checking all results and using more interesting inputs 2025-10-22 00:03:39 +02:00
Benoit Daloze
89472d8911 ZJIT: Inline Fixnum#^
* Handled in cruby_methods.rs because there is no basic operation for Fixnum#^.
2025-10-22 00:03:39 +02:00
Alan Wu
b14fac9440 ZJIT: Issue SendWithoutBlockDirect to VM_METHOD_TYPE_BMETHOD
This helps ZJIT optimize ~300,000 more sends in ruby-bench's lobsters

Top-6 not optimized method types for send_without_block
            Before                           After
       iseq: 713,899 (48.0%)            iseq: 725,668 (62.4%)
  optimized: 359,864 (24.2%)       optimized: 359,940 (31.0%)
    bmethod: 339,040 (22.8%)           alias:  73,541 ( 6.3%)
      alias:  73,392 ( 4.9%)            null:   2,521 ( 0.2%)
       null:   2,521 ( 0.2%)         bmethod:     979 ( 0.1%)
      cfunc:       4 ( 0.0%)           cfunc:       4 ( 0.0%)
2025-10-21 16:48:45 -04:00
Alan Wu
bb7f3d17ed YJIT: ZJIT: Extract common bindings to jit.c and remove unnamed enums.
The type name bindgen picks for anonymous enums creates desync issues on
the bindgen CI checks.
2025-10-21 16:48:45 -04:00
Alan Wu
35c2230734 ZJIT: Fix binding to INVALID_SHAPE_ID under -std=c99 -pedantic
```
  /src/jit.c:19:5: error: ISO C restricts enumerator values to range of 'int' (4294967295 is too large) [-Werror,-Wpedantic]
     19 |     RB_INVALID_SHAPE_ID = INVALID_SHAPE_ID,
        |     ^                     ~~~~~~~~~~~~~~~~
```
2025-10-21 16:48:45 -04:00
BurdetteLamar
193b299b8d [DOC] ”Tweaks for String#setbyte 2025-10-21 16:48:29 -04:00
Burdette Lamar
cb52809ca1
[DOC] Tweaks for String#scrub (#14892) 2025-10-21 16:48:11 -04:00
Burdette Lamar
862b42a52c
[DOC] Tweaks for String#scrub! (#14893) 2025-10-21 16:46:40 -04:00
Burdette Lamar
42c0409781
[DOC] Tweaks for String#scan (#14884) 2025-10-21 16:44:41 -04:00
Burdette Lamar
caff9b9065
[DOC] Tweaks for String#rstrip (#14881) 2025-10-21 16:44:03 -04:00
BurdetteLamar
3b87e76cc6 [DOC] Tweaks for String#rpartition 2025-10-20 21:38:18 -04:00
BurdetteLamar
e930bd3eae [DOC] Tweaks for String#rstrip! 2025-10-20 21:37:26 -04:00
Max Bernstein
17368234bf
ZJIT: Implement codegen for FixnumMod (#14857)
This is mostly to see what happens to the loops-times benchmark.
2025-10-20 21:30:48 +00:00
Luke Gruber
6e9f7974df [DOC] Create doc/contributing/concurrency_guide.md
This guide is for those that want to contribute to ruby but don't
understand where they need to use locks or other concurrency mechanisms.
It teaches them how to use these locks safely and what is prohibited in
certain circumstances.
2025-10-20 13:55:39 -07:00