Commit graph

93237 commits

Author SHA1 Message Date
Jean Boussier
846b5eec57 Convert marshal_compat_table to use rb_gc_mark_and_move
The `p->field = rb_gc_location(p->field)` isn't ideal because it means all
references are rewritten on compaction, regardless of whether the referenced
object has moved. This isn't good for caches nor for Copy-on-Write.

`rb_gc_mark_and_move` avoid needless writes, and most of the time allow to
have a single function for both marking and updating references.
2025-08-07 21:00:00 +02:00
Max Bernstein
a260bbc550
ZJIT: Set PC before StringCopy (#14141)
ZJIT: Set PC before StringCopy

This function allocates.
2025-08-07 18:28:10 +00:00
Peter Zhu
24d0b458cd Make Random write-barrier protected 2025-08-07 09:27:22 -04:00
John Hawthorn
fccd96cc6c Add stricter assertions on CC access 2025-08-06 15:57:13 -07:00
John Hawthorn
640a2f1dc7 Ensure ObjectSpace.dump won't call cc_cme on invalidated CC 2025-08-06 15:57:13 -07:00
John Hawthorn
a9f6fe0914 Avoid marking CC children after invalidation
Once klass becomes Qundef, it's disconnected and won't be invalidated
when the CME is. So once that happens we must not mark or attempt to
move the cme_ field.
2025-08-06 15:57:13 -07:00
Max Bernstein
ba4a36e226
ZJIT: Inline attr_reader/attr_accessor (#14126)
We can rewrite SendWithoutBlock to GetIvar.
2025-08-06 16:56:01 -04:00
Stan Lo
4a70f946a7
ZJIT: Implement SingleRactorMode invalidation (#14121)
* ZJIT: Implement SingleRactorMode invalidation

* ZJIT: Add macro for compiling jumps

* ZJIT: Fix typo in comment

* YJIT: Fix typo in comment

* ZJIT: Avoid using unexported types in zjit.h

`enum ruby_vminsn_type` is declared in `insns.inc` and is not exported.
Using it in `zjit.h` would cause build errors when the file including it
doesn't include `insns.inc`.
2025-08-06 13:51:41 -07:00
Alan Wu
e378a21a32 ZJIT: Run TestFixnum 2025-08-06 16:26:14 -04:00
Alan Wu
21cb1c9e92 ZJIT: x86: split: Fix live ranges index-out-of-range panic
Previously we crashed panicked due to index bounds check running
test_fixnum.rb.

On ARM and in other places in the x86 backend, this isn't a problem
because they inspect the output of instructions which is never replaced.
2025-08-06 16:26:14 -04:00
Peter Zhu
71b46938a7 Fix off-by-one in symbol next_id
Symbol last_id was changed to next_id, but it remained to be set to
tNEXT_ID - 1 initially, causing the initial static symbol to overlap with
the last built-in symbol in id.def.
2025-08-06 13:40:27 -04:00
Takashi Kokubun
ebb775be8d
ZJIT: Fix "immediate value too large" on cmp for x86_64 (#14125)
Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
2025-08-06 10:05:20 -07:00
S-H-GAMELINKS
bcd21053f7 Add MODULE NODE locations
Add `keyword_module` amd `keyword_end` locations to struct `RNode_MODULE`.

memo:
```
>ruby --dump=parsetree -e 'module A end'
@ ProgramNode (location: (1,0)-(1,12))
+-- locals: []
+-- statements:
    @ StatementsNode (location: (1,0)-(1,12))
    +-- body: (length: 1)
        +-- @ ModuleNode (location: (1,0)-(1,12))
            +-- locals: []
            +-- module_keyword_loc: (1,0)-(1,6) = "module"
            +-- constant_path:
            |   @ ConstantReadNode (location: (1,7)-(1,8))
            |   +-- name: :A
            +-- body: nil
            +-- end_keyword_loc: (1,9)-(1,12) = "end"
            +-- name: :A
```
2025-08-07 01:07:16 +09:00
ydah
7aa0e09bfe Fix typo in comment regarding symlink flags in autogen.sh 2025-08-07 01:06:50 +09:00
Jean Boussier
f3206cc79b Struct: keep direct reference to IMEMO/fields when space allows
It's not rare for structs to have additional ivars, hence are one
of the most common, if not the most common type in the `gen_fields_tbl`.

This can cause Ractor contention, but even in single ractor mode
means having to do a hash lookup to access the ivars, and increase
GC work.

Instead, unless the struct is perfectly right sized, we can store
a reference to the associated IMEMO/fields object right after the
last struct member.

```
compare-ruby: ruby 3.5.0dev (2025-08-06T12:50:36Z struct-ivar-fields-2 9a30d141a1) +PRISM [arm64-darwin24]
built-ruby: ruby 3.5.0dev (2025-08-06T12:57:59Z struct-ivar-fields-2 2ff3ec237f) +PRISM [arm64-darwin24]
warming up.....

|                      |compare-ruby|built-ruby|
|:---------------------|-----------:|---------:|
|member_reader         |    590.317k|  579.246k|
|                      |       1.02x|         -|
|member_writer         |    543.963k|  527.104k|
|                      |       1.03x|         -|
|member_reader_method  |    213.540k|  213.004k|
|                      |       1.00x|         -|
|member_writer_method  |    192.657k|  191.491k|
|                      |       1.01x|         -|
|ivar_reader           |    403.993k|  569.915k|
|                      |           -|     1.41x|
```

Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
2025-08-06 17:07:49 +02:00
Jean Boussier
9b3ad3449b Mark cross_ractor_require_data_type as embeddable
Nothing prevents it, so might as well.
2025-08-06 16:37:25 +02:00
Peter Zhu
06312377ad Make Ractor::Selector write-barrier protected 2025-08-06 09:02:30 -04:00
Jean Boussier
92688f7d57 variable.c: refactor accesses to the generic_fields_tbl
All accesses to `generic_fields_tbl_` are now encapsulated inside:

  - `rb_obj_fields`
  - `rb_obj_set_fields`
  - `rb_obj_replace_fields`
2025-08-06 12:33:44 +02:00
Stan Lo
e60e1952a4
ZJIT: Fix Kernel#Float's annotation (#14123)
As pointed out in https://github.com/ruby/ruby/pull/14078#discussion_r2255427676, the return type should be `Float` instead.
2025-08-05 22:52:59 -04:00
pjsk
fe3ed3e7f3
[rubygems/rubygems] Update tests to respect token for where v2 and v1 are invoked
261315e399
2025-08-06 10:46:46 +09:00
pjsk
374f7dbcbb
[rubygems/rubygems] removed global variables
42c5947dbe
2025-08-06 10:46:46 +09:00
pjsk
01ae9e4fb0
[rubygems/rubygems] implement fallback
e09a6ec815
2025-08-06 10:46:46 +09:00
pjsk
23b34517bd
[rubygems/rubygems] Surgery on test code to make fallback to imdsv1 easier to test
5b4eece722
2025-08-06 10:46:46 +09:00
pjsk
720ae3285e
[rubygems/rubygems] make things a bit more testable
29c085f5f5
2025-08-06 10:46:46 +09:00
Frank Olbricht
8691a4ada1
[rubygems/rubygems] Use IMDSv2 for S3 instance credentials
fa1c51ef59
2025-08-06 10:46:46 +09:00
Stan Lo
9c0ebff2cd
ZJIT: Avoid matching built-in iseq's HIR line numbers in tests (#14124)
ZJIT: Avoid matching built-in ISEQs' HIR line numbers in tests

Co-authored-by: Author: Takashi Kokubun <takashi.kokubun@shopify.com>
2025-08-05 17:00:04 -07:00
Hiroshi SHIBATA
4d26ccd2af [rubygems/rubygems] Allow to use Gem::Deprecate#rubygems_deprecate and rubygems_deprecate_command without rubygems.rb
4925403686
2025-08-06 06:23:03 +09:00
Hiroshi SHIBATA
052b38a5d9 [rubygems/rubygems] Deprecate Gem::Specification#datadir and will remove it at RG 4.1
e99cdab171
2025-08-06 06:23:02 +09:00
Hiroshi SHIBATA
51f88f9922 [rubygems/rubygems] Added ability for changing deprecated version from only next major
15177de84e
2025-08-06 06:23:02 +09:00
Hiroshi SHIBATA
19336a6392 [rubygems/rubygems] Removed compatibility.rb that file is for Ruby 1.9.
120c174e7f
2025-08-06 06:23:01 +09:00
Max Bernstein
ef95e5ba3d
ZJIT: Profile type+shape distributions (#13901)
ZJIT uses the interpreter to take type profiles of what objects pass through
the code. It stores a compressed record of the history per opcode for the
opcodes we select.

Before this change, we re-used the HIR Type data-structure, a shallow type
lattice, to store historical type information. This was quick for bringup but
is quite lossy as profiles go: we get one bit per built-in type seen, and if we
see a non-built-in type in addition, we end up with BasicObject. Not very
helpful. Additionally, it does not give us any notion of cardinality: how many
of each type did we see?

This change brings with it a much more interesting slice of type history: a
histogram. A Distribution holds a record of the top-N (where N is fixed at Ruby
compile-time) `(Class, ShapeId)` pairs and their counts. It also holds an
*other* count in case we see more than N pairs.

Using this distribution, we can make more informed decisions about when we
should use type information. We can determine if we are strictly monomorphic,
very nearly monomorphic, or something else. Maybe the call-site is polymorphic,
so we should have a polymorphic inline cache. Exciting stuff.

I also plumb this new distribution into the HIR part of the compilation
pipeline.
2025-08-05 16:56:04 -04:00
Burdette Lamar
52312d53ca
[DOC] Tweaks for GC.start (#14093) 2025-08-05 15:58:00 -04:00
S-H-GAMELINKS
6bc07f1422 [ruby/prism] Convert implicit parameter it to local variable in parse_expression_infix function
fb136c6eb5
2025-08-05 13:58:09 -04:00
S-H-GAMELINKS
a12e0c1db1 [ruby/prism] Remove uneeded test
a6b448b10f
2025-08-05 13:58:09 -04:00
S-H-GAMELINKS
02200ac81c [ruby/prism] Add it read and assignment test
659d769621
2025-08-05 13:58:09 -04:00
S-H-GAMELINKS
b482e3d7cd [ruby/prism] Make it = it assign nil to match parse.y behavior [Bug #21139]
Currently Prism returns `42` for code like this:
```ruby
42.tap { it = it; p it } # => 42
```

But parse.y returns `nil`:
```ruby
42.tap { it = it; p it } # => nil
```

In parse.y, it on the right-hand side is parsed as a local variable.
In Prism, it was parsed as the implicit block parameter it, which caused this inconsistent behavior.

This change makes the right-hand side it to be parsed as a local variable, aligning with parse.y's behavior.

Bug ticket: https://bugs.ruby-lang.org/issues/21139

cf3bbf9d2c
2025-08-05 13:58:09 -04:00
Kevin Newton
6e2b139d6a [ruby/prism] Ensure context terminators terminate expressions
915f6b3ae9
2025-08-05 13:58:09 -04:00
Kevin Newton
2e672fdee0 [ruby/prism] Bump JRuby version
27d284bbb8
2025-08-05 13:58:09 -04:00
Kevin Newton
2936da902c [ruby/prism] Handle new ractor stuff
f5ded5104d
2025-08-05 13:58:09 -04:00
ydah
087190fcd2 [ruby/prism] Improve error handling for missing parentheses after 'not' in command calls
d9151b8a82
2025-08-05 13:58:09 -04:00
Yusuke Endoh
f814a77755 [ruby/prism] Reject true && not true
A command-call-like `not true` must be rejected after `&&` and `||`.

https://bugs.ruby-lang.org/issues/21337

0513cf22ad
2025-08-05 13:58:09 -04:00
Kevin Newton
18e37ac430 [ruby/prism] Optimize context_terminator with a lookup table
483aa89234
2025-08-05 13:58:09 -04:00
Jean Boussier
3ef8d833ab rb_gc_impl_mark_and_move: avoid needless writes
Assuming not all objects are moved during compaction, it
is preferable to avoid rewriting references that haven't moved
as to avoid invalidating potentially shared memory pages.
2025-08-05 18:41:40 +02:00
Peter Zhu
95320f1ddf Fix RUBY_FREE_AT_EXIT for static symbols
Since static symbols allocate memory, we should deallocate them at shutdown
to prevent memory leaks from being reported with RUBY_FREE_AT_EXIT.
2025-08-05 12:04:27 -04:00
Nobuyoshi Nakada
0e33256c8e
CI: Use \e instead of \033 [ci skip] 2025-08-06 00:22:43 +09:00
Étienne Barrié
4cfe5baf3d Use snprintf instead of deprecated sprintf
When compiling with -fsanitize=address on macOS, the deprecation of
sprintf is effective and prevents compiling yjit.c.

More details: https://openradar.appspot.com/FB11761475.
2025-08-05 17:18:32 +02:00
Nobuyoshi Nakada
79d8a3159f Check if the found pkg-config is usable actually 2025-08-05 23:37:51 +09:00
Nobuyoshi Nakada
8e9ea4c202 Convert PKG_CONFIG_PATH to msys/cygwin path 2025-08-05 23:37:51 +09:00
BurdetteLamar
72b8bb4caf [DOC] Tweaks for String#gsub! 2025-08-05 10:11:11 -04:00
Burdette Lamar
409da39afb
[DOC] Tweaks for String#gsub 2025-08-05 10:06:47 -04:00