92050 Commits

Author SHA1 Message Date
Jean Boussier
675f33508c Get rid of TOO_COMPLEX shape type
Instead it's now a `shape_id` flag.

This allows to check if an object is complex without having
to chase the `rb_shape_t` pointer.
2025-06-04 13:13:50 +02:00
Yusuke Endoh
8d49c05c13 Use the edge version of debug gem 2025-06-04 19:53:16 +09:00
Yusuke Endoh
caa6ba1a46 Make rb_debug_inspector_backtrace_locations return a raw backtrace
Previously, a user of the debug inspector API was supposed to use
`rb_debug_inspector_backtrace_locations` to get an array of
`Thread::Backtrace::Location`, and then used its index to get more
information from `rb_debug_inspector _frame_binding_get(index)`, etc.

However, `rb_debug_inspector_backtrace_locations` returned an array of
backtraces excluding rescue/ensure frames. On the other hand,
`rb_debug_inspector_frame_binding_get(index)` interprets index with
rescue/ensure frames. This led to inconsistency of the index, and it was
very difficult to correctly use the debug inspector API.

This is a minimal fix for the issue by making
`rb_debug_inspector_backtrace_locations` return a raw backtrace
including rescue/ensure frames.
2025-06-04 19:53:16 +09:00
Alan Wu
8d14d6ea2d ZJIT: Spill to the stack using arguments instead of FrameState
The FrameState on the SendWithoutBlock represents the entry state,
but for instructions that push to the stack in the middle of the
instruction before actually doing the send like opt_aref_with,
the FrameState is incorrect. We need to write to the stack using the
arguments for the instruction.
2025-06-04 06:23:30 -04:00
Alan Wu
6f0f84e5dd ZJIT: Parse opt_aref_with into HIR 2025-06-04 06:23:30 -04:00
Koichi Sasada
8070d5d97d Ractor#take and warn
`Ractor#take` was deprecated but some libraries can use it as
an alias for `Ractor#value` (i.e., to wait for a Ractor's
temrination and retrieve its result).
Therefore `Ractor#take` is simply an alias for `Ractor#value`.

This method will remain available until the end of August 2025,
unless there is further discussion.
2025-06-04 19:18:16 +09:00
Nobuyoshi Nakada
9fddb8d954
Suppress dangling pointer warning by gcc
`__has_warning` is clang, not gcc.
2025-06-04 15:31:40 +09:00
Nobuyoshi Nakada
7ddc5e6187
Suppress overflow warning at ALLOC_N in iseq_set_local_table
`xmalloc2` checks the overflow of arguments multiplication.
2025-06-04 15:31:40 +09:00
Nobuyoshi Nakada
c5f7d274d7
Check for 64bit atomic operations
May not be supported on some 32bit architectures.

```
/usr/lib/gcc-cross/m68k-linux-gnu/14/../../../../m68k-linux-gnu/bin/ld: ../../libruby-static.a(vm.o): in function `rbimpl_atomic_u64_set_relaxed':
/home/ubuntu/build/ruby/master/m68k-linux/../src/ruby_atomic.h:60:(.text+0x2468): undefined reference to `__atomic_store_8'
/usr/lib/gcc-cross/m68k-linux-gnu/14/../../../../m68k-linux-gnu/bin/ld: ../../libruby-static.a(vm.o): in function `rbimpl_atomic_u64_load_relaxed':
/home/ubuntu/build/ruby/master/m68k-linux/../src/ruby_atomic.h:43:(.text+0x2950):
undefined reference to `__atomic_load_8'
```
2025-06-04 15:31:28 +09:00
Nobuyoshi Nakada
47f55b4b44
Mark as NORETURN 2025-06-04 15:27:45 +09:00
Jean Boussier
206110a2a8 Add missing lock in rb_ivar_defined
If called on a class, we should acquire the lock.
2025-06-04 08:26:20 +02:00
Hiroshi SHIBATA
1f4913db97 [ruby/did_you_mean] Revert "Alias value to take in old Ruby"
This reverts commit https://github.com/ruby/did_you_mean/commit/15d7b0bfa573.

https://github.com/ruby/did_you_mean/commit/86a7daca19
2025-06-04 06:14:27 +00:00
Jean Boussier
6b8dcb7c8f shape.c: fix off by one error in shape_tree_mark 2025-06-04 07:59:20 +02:00
Jean Boussier
bbd5a5a81d vm_getivar: normalize shape_id to ignore frozen state
Freezing an object changes its `shape_id` This is necessary
so that `setivar` routines can use the `shape_id` as a cache key
and save on checking the frozen status every time.

However for `getivar` routines, this causes needless cache misses.
By clearing that bit we increase hit rate in codepaths that see
both frozen and mutable objects.
2025-06-04 07:59:20 +02:00
Jean Boussier
625d6a9cbb Get rid of frozen shapes.
Instead `shape_id_t` higher bits contain flags, and the first one
tells whether the shape is frozen.

This has multiple benefits:
  - Can check if a shape is frozen with a single bit check instead of
    dereferencing a pointer.
  - Guarantees it is always possible to transition to frozen.
  - This allow reclaiming `FL_FREEZE` (not done yet).

The downside is you have to be careful to preserve these flags
when transitioning.
2025-06-04 07:59:20 +02:00
Hiroshi SHIBATA
6b7e3395a4 [ruby/psych] Revert "Alias value or join to take in old Ruby"
This reverts commit https://github.com/ruby/psych/commit/1a4d383efe0b.

https://github.com/ruby/psych/commit/2f51c02280
2025-06-04 05:51:19 +00:00
Hiroshi SHIBATA
a88ff32559 [ruby/uri] Revert "Alias value or join to take in old Ruby"
This reverts commit https://github.com/ruby/uri/commit/443ed0cf8540.

https://github.com/ruby/uri/commit/9e51838a04
2025-06-04 05:35:09 +00:00
Hiroshi SHIBATA
ac1dfee44a [ruby/date] Removed workaround for assert_ractor
https://github.com/ruby/date/commit/700e44ef54
2025-06-04 05:28:25 +00:00
Hiroshi SHIBATA
803526786a [ruby/time] Removed workaround for assert_ractor
https://github.com/ruby/time/commit/337410e971
2025-06-04 05:12:15 +00:00
Hiroshi SHIBATA
04b26db5ef
Support Ractor#value and Ractor#join for old versions of Ruby
https://github.com/ruby/test-unit-ruby-core/pull/9
https://github.com/ruby/test-unit-ruby-core/pull/10
2025-06-04 14:08:04 +09:00
Hiroshi SHIBATA
50400f3bb2 [ruby/etc] Removed workaround for assert_ractor
https://github.com/ruby/etc/commit/fd61177b71
2025-06-04 05:03:18 +00:00
Hiroshi SHIBATA
a84f734343
Added warning for CGI.parse 2025-06-04 12:47:29 +09:00
Nobuyoshi Nakada
0ecb689617
Correct comments for packed shape and index [ci skip] 2025-06-04 11:38:45 +09:00
Jean Boussier
553753cd3e Fix scheduler warning
```
test/fiber/test_scheduler.rb:98: warning: Scheduler should implement #fiber_interrupt
```
2025-06-03 21:55:37 +02:00
Peter Zhu
89d49433a9 Fix memory leak of Ractor ports
Memory leak reported:

    3   miniruby                              0x1044b6c1c ractor_init + 164  ractor.c:460
    2   miniruby                              0x1043fd6a0 ruby_xmalloc + 44  gc.c:5188
    1   miniruby                              0x104402840 rb_gc_impl_malloc + 148  default.c:8140
    0   libsystem_malloc.dylib                0x19ab3912c _malloc_zone_malloc_instrumented_or_legacy + 152
2025-06-03 15:48:38 -04:00
Peter Zhu
7a40f1f06c Fix memory leak of Ractor recv_queue
Memory leak reported:

    3   miniruby                              0x104702c1c ractor_init + 164  ractor.c:460
    2   miniruby                              0x1046496a0 ruby_xmalloc + 44  gc.c:5188
    1   miniruby                              0x10464e840 rb_gc_impl_malloc + 148  default.c:8140
    0   libsystem_malloc.dylib                0x19ab3912c _malloc_zone_malloc_instrumented_or_legacy + 152
2025-06-03 15:48:38 -04:00
Jean Boussier
e27404af9e Use all 32bits of shape_id_t on all platforms
Followup: https://github.com/ruby/ruby/pull/13341 / [Feature #21353]

Even thought `shape_id_t` has been make 32bits, we were still limited
to use only the lower 16 bits because they had to fit alongside `attr_index_t`
inside a `uintptr_t` in inline caches.

By enlarging inline caches we can unlock the full 32bits on all
platforms, allowing to use these extra bits for tagging.
2025-06-03 21:15:41 +02:00
Peter Zhu
ea8b53a539 Allow pass special constants to the write barrier
Some GC implementations want to always know when an object is written to,
even if the written value is a special constant. Checking special constants
in rb_obj_written was a micro-optimization that made assumptions about
the GC implementation.
2025-06-03 12:04:24 -04:00
harasho
5f247416b6 [ruby/prism] Document ClassNode fields - Adds documentation for the fields of the ClassNode. - Part of #2123
https://github.com/ruby/prism/commit/99615b43ac
2025-06-03 14:07:43 +00:00
Peter Zhu
34b407a4a8 Fix memory leak in Prism's RubyVM::InstructionSequence.new
[Bug #21394]

There are two ways to make RubyVM::InstructionSequence.new raise which
would cause the options->scopes to leak memory:

1. Passing in any (non T_FILE) object where the to_str raises.
2. Passing in a T_FILE object where String#initialize_dup raises. This is
   because rb_io_path dups the string.

Example 1:

    10.times do
      100_000.times do
        RubyVM::InstructionSequence.new(nil)
      rescue TypeError
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    13392
    17104
    20256
    23920
    27264
    30432
    33584
    36752
    40032
    43232

After:

    9392
    11072
    11648
    11648
    11648
    11712
    11712
    11712
    11744
    11744

Example 2:

    require "tempfile"

    MyError = Class.new(StandardError)
    String.prepend(Module.new do
      def initialize_dup(_)
        if $raise_on_dup
          raise MyError
        else
          super
        end
      end
    end)

    Tempfile.create do |f|
      10.times do
        100_000.times do
          $raise_on_dup = true
          RubyVM::InstructionSequence.new(f)
        rescue MyError
        else
          raise "MyError was not raised during RubyVM::InstructionSequence.new"
        end

        puts `ps -o rss= -p #{$$}`
      ensure
        $raise_on_dup = false
      end
    end

Before:

    14080
    18512
    22000
    25184
    28320
    31600
    34736
    37904
    41088
    44256

After:

    12016
    12464
    12880
    12880
    12880
    12912
    12912
    12912
    12912
    12912
2025-06-03 10:00:15 -04:00
Hiroshi SHIBATA
135583e37c
[ruby/tmpdir] Restore Ractor.yield style test for old version of Ruby
https://github.com/ruby/tmpdir/commit/f12c766996
2025-06-03 18:13:15 +09:00
Hiroshi SHIBATA
365d5b6bf4
[ruby/time] Alias value or join to take in old Ruby
https://github.com/ruby/time/commit/2a1827b0ce
2025-06-03 18:13:15 +09:00
Jean Boussier
d609a23115
[ruby/json] Update JSONInRactorTest to handle Ruby 3.5 Ractors.
https://github.com/ruby/json/commit/d42b36963d
2025-06-03 18:13:15 +09:00
Hiroshi SHIBATA
267d8a04b3
[ruby/strscan] Support Ractor#value
(https://github.com/ruby/strscan/pull/157)

This is same as https://github.com/ruby/stringio/pull/134

---------

https://github.com/ruby/strscan/commit/141f9cf9b6

Co-authored-by: Koichi Sasada <ko1@atdot.net>
2025-06-03 18:13:15 +09:00
Hiroshi SHIBATA
8ab4935ddf [ruby/pathname] Alias value or join to take in old Ruby
https://github.com/ruby/pathname/commit/c501767d12
2025-06-03 08:40:55 +00:00
Hiroshi SHIBATA
a79e9ab390 [ruby/uri] Alias value or join to take in old Ruby
https://github.com/ruby/uri/commit/443ed0cf85
2025-06-03 08:40:46 +00:00
Hiroshi SHIBATA
6609ba0514 [ruby/io-wait] Alias value or join to take in old Ruby
https://github.com/ruby/io-wait/commit/cf84aea70d
2025-06-03 08:24:14 +00:00
Hiroshi SHIBATA
ce459c1df3 [ruby/did_you_mean] Omit some tests with JRuby
https://github.com/ruby/did_you_mean/commit/a7a438ae27
2025-06-03 08:24:03 +00:00
Hiroshi SHIBATA
0266e4def2 [ruby/did_you_mean] Alias value to take in old Ruby
https://github.com/ruby/did_you_mean/commit/15d7b0bfa5
2025-06-03 08:24:03 +00:00
Hiroshi SHIBATA
a77ec9a22c [ruby/psych] Alias value or join to take in old Ruby
https://github.com/ruby/psych/commit/1a4d383efe
2025-06-03 07:56:39 +00:00
Hiroshi SHIBATA
7d1190059f [ruby/stringio] Support Ractor#value
(https://github.com/ruby/stringio/pull/134)

from https://bugs.ruby-lang.org/issues/21262

We need to alias `Ractor#value` to `Ractor#take` for old versions of
Ruby.

---------

https://github.com/ruby/stringio/commit/9954dabd80

Co-authored-by: Koichi Sasada <ko1@atdot.net>
Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2025-06-03 07:44:36 +00:00
Hiroshi SHIBATA
c6c51569cb [ruby/io-console] Alias value or join to take in old Ruby
https://github.com/ruby/io-console/commit/7106d05219
2025-06-03 07:02:18 +00:00
Hiroshi SHIBATA
17401792fa [ruby/etc] Alias value or join to take in old Ruby
https://github.com/ruby/etc/commit/3dbe760bed
2025-06-03 06:59:51 +00:00
Hiroshi SHIBATA
9991edcc41 [ruby/digest] Alias value to take in old Ruby
https://github.com/ruby/digest/commit/1eaee7d4fe
2025-06-03 06:57:30 +00:00
Hiroshi SHIBATA
52d85c0efb [ruby/date] Alias value to take in old Ruby
https://github.com/ruby/date/commit/1ce29a26dd
2025-06-03 06:46:56 +00:00
David Rodríguez
6f4eaa100f
Remove hardcoded version of rake from Bundler tests
Let them run against the version resolved by the `test_gems.rb` gemfile.

This should fix ruby-core CI job that was broken by the release of rake
13.3.0.
2025-06-03 08:12:09 +09:00
TangRufus
710f5b7711 [rubygems/rubygems] Follow coding style
https://github.com/rubygems/rubygems/commit/bfac93100e
2025-06-03 08:06:50 +09:00
TangRufus
792414678d [rubygems/rubygems] Test bin/ is included in the ignore list
https://github.com/rubygems/rubygems/commit/7afe81fd45
2025-06-03 08:06:45 +09:00
TangRufus
204e3c58e1 [rubygems/rubygems] Only ignore .gitignore when generating gems with git
https://github.com/rubygems/rubygems/commit/aec5a7887d
2025-06-03 08:06:39 +09:00
TangRufus
9024caa1d6 [rubygems/rubygems] Ignore Gemfile, gems.rb & gems.locked according to init_gems_rb preference
https://github.com/rubygems/rubygems/commit/88aeb66f41
2025-06-03 08:06:31 +09:00