Commit graph

93224 commits

Author SHA1 Message Date
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
BurdetteLamar
b7f65f01ee [DOC] Tweaks for String#grapheme_clusters 2025-08-05 09:26:42 -04:00
ArtSin
a6aaeb9acf load.c: fix prev_ext_config clobbering in require_internal
The variable `prev_ext_config` is modified by `ext_config_push` between
`setjmp` and `longjmp` calls. Since `ext_config_push` and `ext_config_pop`
are small and likely to be inlined, `prev_ext_config` can be allocated on
a register and get clobbered. Fix by making it `volatile`.

This bug can be observed by adding a check for values greater than 1 in
`th2->ext_config.ractor_safe` after `ext_config_pop` and building with Clang.
2025-08-05 22:19:55 +09:00
ydah
3d8af5df11 Fix typo in documentation comment for exc_inspect method in error.c 2025-08-05 21:58:12 +09:00
Nobuyoshi Nakada
d5e7e88f32
Show mkmf.log contents even when pkg-config command failed 2025-08-05 15:56:26 +09:00
Hiroshi SHIBATA
06b14f29a3 Added missing block argument 2025-08-05 13:11:18 +09:00
Hiroshi SHIBATA
015d874133 Sync https://github.com/ruby/test-unit-ruby-core/pull/8 2025-08-05 13:11:18 +09:00
Hiroshi SHIBATA
946165bd48 Added clang-22 build 2025-08-05 11:41:43 +09:00
Hiroshi SHIBATA
3c6bd9c9c7
Pathname is now core class.
We will restore this sync target when `lib/pathname.rb` is migrated to `pathname_builtin.rb`
and backport that file to `ruby/pathname` repo.
2025-08-05 10:33:53 +09:00
Takashi Kokubun
196155812b Resurrect another ZJIT skip on test_handle_interrupted?
Failed at:
4737899286

Partially reverting https://github.com/ruby/ruby/pull/14097
2025-08-04 17:49:43 -07:00
Takashi Kokubun
591849a1a5 Resurrect a ZJIT skip on test_switch_while_busy_loop
This can still hang:
4737338125

partially reverting https://github.com/ruby/ruby/pull/14097
2025-08-04 17:31:09 -07:00
Stan Lo
8091f3bce5
ZJIT: Remove passing tests from exclusions (#14097) 2025-08-04 15:20:07 -07:00
Takashi Kokubun
53b0462841
ZJIT: Add helpers to prepare for C calls (#14100) 2025-08-04 14:44:51 -07:00
Aaron Patterson
89d89fa49d When reading from stdin, put a wrapper around the IO object
The purpose of this commit is to fix Bug #21188.  We need to detect when
stdin has run in to an EOF case.  Unfortunately we can't _call_ the eof
function on IO because it will block.

Here is a short script to demonstrate the issue:

```ruby
x = STDIN.gets
puts x
puts x.eof?
```

If you run the script, then type some characters (but _NOT_ a newline),
then hit Ctrl-D twice, it will print the input string.  Unfortunately,
calling `eof?` will try to read from STDIN again causing us to need a
3rd Ctrl-D to exit the program.

Before introducing the EOF callback to Prism, the input loop looked
kind of like this:

```ruby
loop do
  str = STDIN.gets
  process(str)

  if str.nil?
    p :DONE
  end
end
```

Which required 3 Ctrl-D to exit.  If we naively changed it to something
like this:

```ruby
loop do
  str = STDIN.gets
  process(str)

  if STDIN.eof?
    p :DONE
  end
end
```

It would still require 3 Ctrl-D because `eof?` would block.  In this
patch, we're wrapping the IO object, checking the buffer for a newline
and length, and then using that to simulate a non-blocking eof? method.

This commit wraps STDIN and emulates a non-blocking `eof` function.

[Bug #21188]
2025-08-04 12:34:33 -07:00