96430 Commits

Author SHA1 Message Date
Nobuyoshi Nakada
27d6c96658
Add 4.0 to the spec_guards workflow 2025-12-30 18:33:20 +09:00
Nobuyoshi Nakada
3f616d5701
Update ruby/setup-ruby action to v1.276.0 2025-12-30 18:33:03 +09:00
Satoshi Tagomori
d5af8d7858 Box: allocate classes as boxable when it happens in the root box
Without this change, classes (including iclass) are allocated
as un-boxable classes after initializing user boxes (after starting
script evaluation). Under this situation, iclasses are created as
un-boxabled class when core modules are included by a class in the
root box, then it causes problems because it's in the root box but
it can't have multiple classexts.

This change makes it possible to allocate boxable classes even after
initializing user boxes. Classes create in the root box will be
boxable, and those can have 2 or more classexts.
2025-12-30 17:06:34 +09:00
Earlopain
65634d8df5 [ruby/prism] Optimize ruby visitor
`compact_child_nodes` allocates an array. We can skip that step by simply yielding the nodes.

Benchmark for visiting the rails codebase:

```rb
require "prism"
require "benchmark/ips"

files = Dir.glob("../rails/**/*.rb")
results = files.map { Prism.parse_file(it) }
visitor = Prism::Visitor.new

Benchmark.ips do |x|
  x.config(warmup: 3, time: 10)

  x.report do
    results.each do
      visitor.visit(it.value)
    end
  end
end

RubyVM::YJIT.enable

Benchmark.ips do |x|
  x.config(warmup: 3, time: 10)

  x.report do
    results.each do
      visitor.visit(it.value)
    end
  end
end
```

Before:
```
ruby 3.4.8 (2025-12-17 revision https://github.com/ruby/prism/commit/995b59f666) +PRISM [x86_64-linux]
Warming up --------------------------------------
                         1.000 i/100ms
Calculating -------------------------------------
                          2.691 (± 0.0%) i/s  (371.55 ms/i) -     27.000 in  10.089422s
ruby 3.4.8 (2025-12-17 revision https://github.com/ruby/prism/commit/995b59f666) +YJIT +PRISM [x86_64-linux]
Warming up --------------------------------------
                         1.000 i/100ms
Calculating -------------------------------------
                          7.278 (±13.7%) i/s  (137.39 ms/i) -     70.000 in  10.071568s
```
After:
```
ruby 3.4.8 (2025-12-17 revision https://github.com/ruby/prism/commit/995b59f666) +PRISM [x86_64-linux]
Warming up --------------------------------------
                         1.000 i/100ms
Calculating -------------------------------------
                          3.429 (± 0.0%) i/s  (291.65 ms/i) -     35.000 in  10.208580s
ruby 3.4.8 (2025-12-17 revision https://github.com/ruby/prism/commit/995b59f666) +YJIT +PRISM [x86_64-linux]
Warming up --------------------------------------
                         1.000 i/100ms
Calculating -------------------------------------
                         16.815 (± 0.0%) i/s   (59.47 ms/i) -    169.000 in  10.054668s
```

~21% faster on the interpreter, ~56% with YJIT

https://github.com/ruby/prism/commit/bf631750cf
2025-12-29 14:14:00 +00:00
Thomas Marshall
14fbcf0e6e [ruby/prism] Report missing end errors at opening token
This commit adds an `expect1_opening` function that expects a token and
attaches the error to the opening token location rather than the current
position. This is useful for errors about missing closing tokens, where
we want to point to the line with the opening token rather than the end
of the file.

For example:

```ruby
def foo
def bar
def baz
       ^ expected an `end` to close the `def` statement
       ^ expected an `end` to close the `def` statement
       ^ expected an `end` to close the `def` statement
```

This would previously produce three identical errors at the end of the
file. After this commit, they would be reported at the opening token
location:

```ruby
def foo
^~~ expected an `end` to close the `def` statement
def bar
^~~ expected an `end` to close the `def` statement
def baz
^~~ expected an `end` to close the `def` statement
```

I considered using the end of the line where the opening token is
located, but in some cases that would be less useful than the opening
token location itself. For example:

```ruby
def foo def bar def baz
```

Here the end of the line where the opening token is located would be the
same for each of the unclosed `def` nodes.

https://github.com/ruby/prism/commit/2d7829f060
2025-12-29 14:12:20 +00:00
Thomas Marshall
8afd4fade6 [ruby/prism] Add unterminated construct tests
https://github.com/ruby/prism/commit/166764f794
2025-12-29 14:12:20 +00:00
Peter Zhu
782d959f67 Implement moving Immix in MMTk
This commit implements moving Immix in MMTk, which allows objects to move
in the GC.

The performance of this implementation is not yet amazing. It is very
similar to non-moving Immix in many of them and slightly slower in others.
The benchmark results is shown below.

    --------------  -----------------  ----------  ---------
    bench           Moving Immix (ms)  stddev (%)  RSS (MiB)
    activerecord    241.9              0.5         86.6
    chunky-png      447.8              0.8         74.9
    erubi-rails     1183.9             0.8         136.1
    hexapdf         1607.9             2.6         402.3
    liquid-c        45.4               6.7         44.9
    liquid-compile  44.1               9.3         53.0
    liquid-render   105.4              4.5         55.9
    lobsters        650.1              9.7         418.4
    mail            115.4              2.1         64.4
    psych-load      1656.8             0.8         43.6
    railsbench      1653.5             1.3         149.8
    rubocop         127.0              15.6        142.1
    ruby-lsp        130.7              10.5        99.4
    sequel          52.8               7.2         45.6
    shipit          1187.0             3.9         311.0
    --------------  -----------------  ----------  ---------

    --------------  ---------------------  ----------  ---------
    bench           Non-moving Immix (ms)  stddev (%)  RSS (MiB)
    activerecord    218.9                  2.7         86.1
    chunky-png      464.6                  0.8         66.7
    erubi-rails     1119.0                 4.3         132.7
    hexapdf         1539.8                 1.8         425.2
    liquid-c        40.6                   6.9         45.2
    liquid-compile  40.6                   8.1         52.9
    liquid-render   99.3                   2.3         48.3
    mail            107.4                  5.3         65.4
    psych-load      1535.6                 1.0         39.5
    railsbench      1565.6                 1.1         149.6
    rubocop         122.5                  14.3        146.7
    ruby-lsp        128.4                  10.7        106.4
    sequel          44.1                   4.0         45.7
    shipit          1154.5                 2.7         358.5
    --------------  ---------------------  ----------  ---------
2025-12-29 09:03:31 -05:00
Peter Zhu
7902ae34d0 Add rb_gc_move_obj_during_marking 2025-12-29 09:03:31 -05:00
Peter Zhu
01cd9c9fad Add rb_gc_register_pinning_obj 2025-12-29 09:03:31 -05:00
Peter Zhu
56147001ec Move MEMO_NEW to imemo.c and rename to rb_imemo_memo_new 2025-12-29 09:03:31 -05:00
Nobuyoshi Nakada
da89f7f58d
Prefer ALLOCV over ALLOCA for unknown size
`ALLOCA` with too large size may result in stack overflow.
Incidentally, this suppresses the GCC false maybe-uninitialized
warning in `product_each`.

Also shrink `struct product_state` when `sizeof(int) < sizeof(VALUE)`.
2025-12-29 20:26:00 +09:00
Nobuyoshi Nakada
26088dcd4a
[DOC] State that rb_unexpected_type is private 2025-12-29 18:41:58 +09:00
Nobuyoshi Nakada
56a6a21f28
Return NULL in a void * function 2025-12-29 18:40:48 +09:00
Nobuyoshi Nakada
0f64da9672
Make rb_check_typeddata and rbimpl_check_typeddata identical 2025-12-29 18:40:47 +09:00
Nobuyoshi Nakada
72627d85e3
Declare rb_data_typed_t parameters and return values as nonull 2025-12-29 18:20:36 +09:00
Luke Jahnke
4e0bb58a0a fix underflow 2025-12-29 17:21:33 +09:00
Jeremy Evans
38701a4de8 Remove deprecated support for to_set taking arguments 2025-12-29 14:54:41 +09:00
Nobuyoshi Nakada
cb01b9023e
rtypeddata.h: Add missing RBIMPL_CAST
In public headers, casts should be enclosed in `RBIMPL_CAST` for
compilation in C++.
2025-12-29 10:33:31 +09:00
Peter Zhu
9e78353c0f Fix maybe uninitialized warnings in random.c
Fixes the following compiler warnings:

    random.c: In function `random_init`:
    random.c:416:38: warning: `rng` may be used uninitialized in this function [-Wmaybe-uninitialized]
      416 |     unsigned int major = rng->version.major;
          |                          ~~~~~~~~~~~~^~~~~~
    random.c: In function `random_bytes`:
    random.c:1284:8: warning: `rng` may be used uninitialized in this function [-Wmaybe-uninitialized]
    1284 |     rng->get_bytes(rnd, ptr, n);
         |     ~~~^~~~~~~~~~~
    random.c:1299:34: note: `rng` was declared here
    1299 |     const rb_random_interface_t *rng;
         |                                  ^~~
    random.c: In function `rand_random_number`:
    random.c:1606:12: warning: `rng` may be used uninitialized in this function [-Wmaybe-uninitialized]
    1606 |     return rand_range(obj, rng, rnd, vmax);
         |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    random.c:1624:34: note: `rng` was declared here
    1624 |     const rb_random_interface_t *rng;
          |                                  ^~~
    random.c: In function `random_rand`:
    random.c:1120:15: warning: `rng` may be used uninitialized in this function [-Wmaybe-uninitialized]
    1120 |     return rng->get_int32(rnd);
         |            ~~~^~~~~~~~~~~
    random.c:1573:34: note: `rng` was declared here
    1573 |     const rb_random_interface_t *rng;
         |                                  ^~~
2025-12-28 16:25:49 -05:00
Burdette Lamar
d615dbf4e2
[DOC] Japanese for multi-byte characters 2025-12-28 15:51:10 -05:00
Nobuyoshi Nakada
44e762a99c
Extract rb_random_interface_t alongside rb_random_t as well 2025-12-29 02:01:12 +09:00
Nobuyoshi Nakada
68cd46353c
Ensure T_DATA before RTYPEDDATA_P
For the precondition of `RTYPEDDATA_P` that the argument must be a
Ruby object of `::RUBY_T_DATA`.
2025-12-29 02:01:12 +09:00
Peter Zhu
eaa83e505f Always allocate Fiber objects in Thread
Currently, root fibers of threads do not have a corresponding Ruby object
backing it by default (it does have one when an object is required, such
as when Fiber.current is called). This is a problem for the new GC weak
references design in #12606 since Thread is not declared as having weak
references but it does hold weak references (the generic ivar cache).

This commit changes it to always allocate a Fiber object for the root
fiber.
2025-12-28 08:55:38 -05:00
Misaki Shioi
3fe2ebf8e4
Remove unnecessary comparison from is_local_port_fixed (#15757)
Simplify the conditions:
- Return false if the port is 0 or a negative number
- Return true if the port is a positive number
2025-12-28 17:23:50 +09:00
Nobuyoshi Nakada
6544c89708
Skip the hang-up test on mingw 2025-12-28 10:34:17 +09:00
BurdetteLamar
8415f8facc [DOC] Use Japanese for multi-byte characters 2025-12-27 13:28:57 -05:00
BurdetteLamar
a92c0342dd [DOC] Japanese only for multi-byte chars examples 2025-12-27 10:59:48 -05:00
BurdetteLamar
38d24294ac [DOC] Multibyte chars Japanese only 2025-12-27 10:59:23 -05:00
Misaki Shioi
a8c3d5e127
Fix: Do not fast_fallback if local_port is explicitly specified (#15732)
`fast fallback` cannot be used with explicitly specified local port,
because concurrent binds to the same `local_host:local_port`
can raise `Errno::EADDRINUSE`.

This issue is more likely to occur on hosts with `IPV6_V6ONLY` disabled,
because IPv6 binds can also occupy IPv4-mapped IPv6 address space.
2025-12-27 18:26:56 +09:00
Kazuki Yamaguchi
3c9e61f5ef [ruby/openssl] cipher: remove incorrect assertion in Cipher#update
Commit https://github.com/ruby/openssl/commit/1de3b80a46c2 (cipher: make output buffer String independent,
2024-12-10) ensures the output buffer String has sufficient capacity,
bu the length can be shorter. The assert() is simply incorrect and
should be removed.

Also remove a similar assert() in Cipher#final. While not incorrect, it
is not useful either.

https://github.com/ruby/openssl/commit/0ce6ab97dd
2025-12-27 07:46:03 +00:00
git
b8201a09e0 Update bundled gems list as of 2025-12-27 2025-12-27 06:53:51 +00:00
Burdette Lamar
dedde99676
[DOC] Use Japanese for multi-byte characters (#15745) 2025-12-26 14:06:21 -06:00
Peter Zhu
7b3b1a1442 [DOC] Use self in call-seq for Method#call 2025-12-26 10:14:04 -05:00
Peter Zhu
6ae69e9ac1 [DOC] Remove args from call-seq of Method#call 2025-12-26 10:14:04 -05:00
Jean Boussier
b304c149aa [DOC] Remove outdated documentation about command injection
[Feature #19630]

This dangerous behavior was removed in 4.0 (996cae65f3cc8fed60c6bb758b00882cac49389d)
but the documentation wasn't updated.
2025-12-26 13:05:29 +01:00
Nobuyoshi Nakada
c342461582
Remove an useless macro definition RSTRUCT_PTR
The underlying definition, `rb_struct_ptr`, was removed four years
ago.
2025-12-26 19:33:03 +09:00
Nobuyoshi Nakada
8c7b1401a5
Remove rb_iterate deprecated since 1.9 2025-12-26 17:53:23 +09:00
Nobuyoshi Nakada
2ac4cc0a1b
Remove RUBY_FL_DUPPED deprecated for 4 years 2025-12-26 17:53:23 +09:00
Nobuyoshi Nakada
a3ac83b7b8
Remove taintedness/trustedness enums/macros deprecated for 4 years 2025-12-26 17:53:22 +09:00
Nobuyoshi Nakada
a447d39da2
Remove rb_gc_force_recycle deprecated as "removed soon" 2025-12-26 17:02:42 +09:00
Nobuyoshi Nakada
cf60dc2642
Remove rb_clone_setup and rb_dup_setup deprecated for 4 years 2025-12-26 17:02:42 +09:00
Nobuyoshi Nakada
a41b154029
Remove rb_complex_polar deprecated for 7 years 2025-12-26 17:02:42 +09:00
Nobuyoshi Nakada
f84110e601
Remove old APIs to allocate a data object deprecated for 5 years 2025-12-26 17:02:41 +09:00
Nobuyoshi Nakada
5c2f6639c5
Remove rb_clear_constant_cache deprecated for 3 years 2025-12-26 16:48:16 +09:00
Nobuyoshi Nakada
1ca464347a
CI: Warn deprecated features to be removed at this version 2025-12-26 15:11:23 +09:00
Nobuyoshi Nakada
ccc8610b66
Remove RUBY_GC_HEAP_INIT_SLOTS environment variable 2025-12-26 15:11:23 +09:00
Nobuyoshi Nakada
4c07e61bc9
Deprecate old VC 2025-12-26 15:11:23 +09:00
Nobuyoshi Nakada
0b65ac6daf
Remove a no longer used prototype declaration in re.c
Include internal/error.h instead.
2025-12-26 15:11:23 +09:00
Yusuke Endoh
704ac72fb6 Clarify the intent of the test for "ruby -h" to fit in 80x25 2025-12-26 14:20:00 +09:00
Andrii Furmanets
b01fd2d8c3 Fix RSET_IS_MEMBER macro parameter mismatch
The RSET_IS_MEMBER macro had a parameter named 'sobj' but the macro
body used 'set' instead, causing the first argument to be ignored.

This worked by accident because all current callers use a variable
named 'set', but would cause compilation failure if called with a
differently named variable:

    error: use of undeclared identifier 'set'

Changed the parameter name from 'sobj' to 'set' to match the macro
body and be consistent with other RSET_* macros.
2025-12-26 14:05:11 +09:00