86825 Commits

Author SHA1 Message Date
Alan Wu
525008cd78
Delete newarraykwsplat
The pushtoarraykwsplat instruction was designed to replace newarraykwsplat,
and we now meet the condition for deletion mentioned in
77c1233f79a0f96a081b70da533fbbde4f3037fa.
2024-08-13 20:56:35 +00:00
Peter Zhu
b80b839926 Don't set stack end in rb_gc_mark_roots
We don't need to set the stack end in rb_gc_mark_roots because it is
already set in mark_current_machine_context.
2024-08-13 15:53:14 -04:00
John Hawthorn
87a85550ed Re-initialize vm->ractor.sched.lock after fork
Previously under certain conditions it was possible to encounter a
deadlock in the forked child process if ractor.sched.lock was held.

Co-authored-by: Nathan Froyd <froydnj@gmail.com>
2024-08-13 11:52:24 -07:00
Stan Lo
908305a297 Sync rdoc 2024-08-13 09:10:15 -04:00
Kevin Newton
a6581114b0 [ruby/prism] Fix up spacing in generated node.rb
https://github.com/ruby/prism/commit/50d79b734b
2024-08-13 12:41:07 +00:00
Naoto Ono
436d23f80d Make sure to wait for the thread to exit in TestProcess#test_wait_and_sigchild 2024-08-13 14:47:48 +09:00
Koichi Sasada
d5afa2cc95 do not show unused block on send
Some case it is difficult to know the calling method uses a block
or not with `send` on a general framework. So this patch stops
showing unused block warning on `send`.

example with test/unit:

```ruby
require 'test/unit'

class T < Test::Unit::TestCase
  def setup
  end

  def test_foo = nil
end
```

=> /home/ko1/ruby/install/master/lib/ruby/gems/3.4.0+0/gems/test-unit-3.6.2/lib/test/unit/fixture.rb:284: warning: the block passed to 'priority_setup' defined at /home/ko1/ruby/install/master/lib/ruby/gems/3.4.0+0/gems/test-unit-3.6.2/lib/test/unit/priority.rb:183 may be ignored

because test/unit can call any setup method (`priority_setup` in this case) with a block.

Maybe we can show the warning again when we provide a way to recognize
the calling method uses a block or not.
2024-08-13 12:17:56 +09:00
Lars Kanis
eedf6c35b3
Revert change of "mingw-ucrt" platform string
... of commit 00176cd40fe9f385231e9c20b956fc4a84d240b9.

The reverted change was made only for constistency, as discussed in
  https://github.com/ruby/ruby/pull/11358#issuecomment-2282222369

But the platform string "mingw-ucrt" should not be changed.
It is used as RUBY_PLATFORM and as the rubygems platform, so that there should
be a good reason to change the name of an established platform.
"mingw-ucrt" was introduced intentionally in commit
576b2e64cdc5ea42ad345dd3c1c215e006c06fca.

Related to GH-11358
2024-08-12 21:48:29 -04:00
Naoto Ono
00e2e24e6f Launchable: Fix condition for bootstraptest 2024-08-13 10:28:14 +09:00
Kevin Newton
d012f6d49f [ruby/prism] Add sample for generating tags
https://github.com/ruby/prism/commit/7c9ca47ac5
2024-08-12 18:44:18 +00:00
Peter Zhu
568d7ab7f5 Fix memory leak reported in -test-/random/loop.c
RUBY_TYPED_DEFAULT_FREE will only free the rand_loop_t, but it will cause
the buf to be leaked. This commit fixes the memory leak by implementing
a free function for the rand_loop_t type.
2024-08-12 09:33:20 -04:00
tompng
992596fb7a Fix next inside block argument stack underflow
[Bug #20344]
Fix compile_next adding removable adjust label
2024-08-12 18:09:32 +09:00
git
2a7da0b6e7 Update bundled gems list as of 2024-08-12 2024-08-12 07:01:02 +00:00
Jean Boussier
ca5b7276c6 compile.c: don't allocate empty default values list
It just wastes memory.
2024-08-11 15:04:35 +02:00
Nobuyoshi Nakada
1fd0a1b4ce
Fix sign-conversion warning
```
../../.././include/ruby/internal/special_consts.h:349:36: error: conversion to ‘VALUE’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Werror=sign-conversion]
  349 |     return RB_SPECIAL_CONST_P(obj) * RUBY_Qtrue;
      |            ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
```
2024-08-11 16:04:37 +09:00
Nobuyoshi Nakada
1db8586279
Show mkmf.log when failed 2024-08-11 15:57:56 +09:00
Nobuyoshi Nakada
21a9d7664c
Fix flag test macro
`RBOOL` is a macro to convert C boolean to Ruby boolean.
2024-08-11 02:36:37 +09:00
Nobuyoshi Nakada
04d57e2c5c
Evaluate macro arguments just once
And fix unclosed parenthesis.
2024-08-11 02:36:11 +09:00
Nobuyoshi Nakada
9416bfb83d
Increase timeout of test-bundler-parallel
Even if it succeeds, it takes almost 40 minutes.
2024-08-11 00:19:20 +09:00
Raed Rizqie
00176cd40f fix ucrt arch 2024-08-11 00:10:28 +09:00
Raed Rizqie
f1224e55fd fix i386-ucrt build 2024-08-11 00:10:28 +09:00
Jean Boussier
b1f4222fc5 Cherry-pick test for [Bug #20668]
The bug didn't impact master because this was largely refactored,
but it's still valuable to add the test for it to prevent future
regressions.
2024-08-10 12:41:35 +02:00
Koichi ITO
ad23bbe574 [ruby/prism] [Doc] Tweak the docs for lex APIs
`Prism.lex` and `Prism.lex_file` return `ParseLexResult` instead of `Array`.
`Prism::parse_lex` and `Prism::parse_lex_file` return `ParseLexResult` instead of `ParseResult`.
This PR updates the documentation to reflect these return values.

https://github.com/ruby/prism/commit/ee331941c0
2024-08-10 08:42:36 +00:00
Jean Boussier
6ee9a08d32 rb_setup_fake_ary: use precomputed flags
Setting up the fake array is a bit more expensive than would be
expected because `rb_ary_freeze` does a lot of checks and lookup
a shape transition.

If we assume fake arrays will always be frozen, we can precompute
the flags state and just assign it.
2024-08-10 10:09:14 +02:00
Peter Zhu
7b7dde37f5 [ruby/psych] Guard from memory leak in Psych::Emitter#start_document
When an exception is raised, it can leak memory in `head`. There are two
places that can leak memory:

1. `Check_Type(tuple, T_ARRAY)` can leak memory if `tuple` is not an
   array.
2. `StringValue(name)` and `StringValue(value)` if they are not strings
   and the call to `to_str` does not return a string.

This commit fixes these memory leaks by wrapping the code around a
rb_ensure so that the memory is freed in all cases.

The following code demonstrates the memory leak:

    emitter = Psych::Emitter.new(StringIO.new)
    nil_to_string_tags = [[nil, "tag:TALOS"]] + ([1] * 1000)
    expected_array_tags = [1] * 1000

    10.times do
      1_000.times do
        # Raises `no implicit conversion of nil into String`
        emitter.start_document([], nil_to_string_tags, 0)
      rescue TypeError
      end

      1_000.times do
        # Raises `wrong argument type Integer (expected Array)`
        emitter.start_document([], expected_array_tags, 0)
      rescue TypeError
      end

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

Before:

    47248
    79728
    111968
    144224
    176480
    208896
    241104
    273280
    305472
    337664

After:

    14832
    15088
    15344
    15344
    15360
    15632
    15632
    15632
    15648
    15648

https://github.com/ruby/psych/commit/053af73818
2024-08-09 20:28:53 +00:00
Jean Boussier
4e85b6b4c4 rb_str_bytesplice: skip encoding check if encodings are the same
If both strings have the same encoding, all this work is useless.
2024-08-09 22:06:44 +02:00
Jean Boussier
3bac5f6af5 string.c: add fastpath in str_ensure_byte_pos
If the string only contain single byte characters we can
skips all the costly checks.
2024-08-09 22:06:44 +02:00
Jean Boussier
a332367dad string.c: Add fastpath to single_byte_optimizable
`rb_enc_from_index` is a costly operation so it is worth avoiding
to call it for the common encodings.

Also in the case of UTF-8, it's more efficient to scan the
coderange if it is unknown that to fallback to the slower
algorithms.
2024-08-09 22:06:44 +02:00
Alan Wu
5a570421a5 [DOC] Regexp.last_match returns $~, not $! 2024-08-09 16:02:36 -04:00
Peter Zhu
ee482f48ee Add psych expand tabs commit to .git-blame-ignore-revs [ci skip] 2024-08-09 15:38:19 -04:00
Peter Zhu
d1474affa8 [ruby/psych] Convert tabs to spaces in test/psych/test_yaml.rb
https://github.com/ruby/psych/commit/64bfc308f8
2024-08-09 19:35:29 +00:00
Peter Zhu
712ac99e4d [ruby/psych] Convert missed tabs to spaces in C files
https://github.com/ruby/psych/commit/74a6b4d226
2024-08-09 19:35:28 +00:00
Peter Zhu
c8708c72c4 Add expand tabs commit in psych to .git-blame-ignore-revs 2024-08-09 14:51:40 -04:00
Peter Zhu
e63a2115f6 [ruby/psych] Convert tabs to spaces in C files
https://github.com/ruby/psych/commit/e7d64c9848
2024-08-09 18:29:46 +00:00
Peter Zhu
c91ec7ba1e Remove rb_gc_impl_objspace_mark
It's not necessary for the GC implementation to call rb_gc_mark_roots
which calls back into the GC implementation's rb_gc_impl_objspace_mark.
2024-08-09 10:27:40 -04:00
Jean Boussier
2bd5dc47ac string.c: str_capacity don't check for immediates
`STR_EMBED_P` uses `FL_TEST_RAW` meaning we already assume `str`
isn't an immediate, so we can use `FL_TEST_RAW` here too.
2024-08-09 15:20:58 +02:00
Jean Boussier
af44af238b str_independent: add a fastpath with a single flag check
If we assume that most strings we modify are not frozen and
are independent, then we can optimize this case by replacing
multiple flag checks by a single mask check.
2024-08-09 15:20:58 +02:00
Naoto Ono
f57167d338 Increase timeout in test_darwin_invalid_call method 2024-08-09 12:16:23 +09:00
Takashi Kokubun
77ffdfe79f
YJIT: Allow tracing fallback counters (#11347)
* YJIT: Allow tracing fallback counters

* Update yjit.md about --yjit-trace-exits=counter
2024-08-08 16:13:16 -07:00
Burdette Lamar
ec5436bc3a
[DOC] Tweaks for Array#[]= (#11329) 2024-08-08 16:09:32 -04:00
BurdetteLamar
e008f0553d [DOC] Add remark about in-brief for method doc 2024-08-08 16:08:47 -04:00
BurdetteLamar
b9a9564c1f [DOC] Tweaks for Array#[] 2024-08-08 16:08:15 -04:00
BurdetteLamar
d657205c58 [DOC] Tweaks for Array#[] 2024-08-08 16:08:15 -04:00
BurdetteLamar
6fee51069c [DOC] Tweaks for Array#== 2024-08-08 16:05:42 -04:00
Stan Lo
64a7b87e1d
Sync rdoc to fix master doc's display issue (#11345)
Sync rdoc

This syncs changes made in https://github.com/ruby/rdoc/pull/1148, which
will fix https://docs.ruby-lang.org/en/master/'s display on certain screens.
2024-08-08 13:02:46 -07:00
Peter Zhu
0bff07644b
Make YJIT a GC root rather than an object (#11343)
YJIT currently uses the YJIT root object to mark objects during GC and
update references during compaction. This object otherwise serves no
purpose.

This commit changes it YJIT to be step when marking the GC root. This
saves some memory from being allocated from the system and the GC.
2024-08-08 12:19:35 -04:00
Peter Zhu
868d63f0a3 Disable GC even during finalizing
We're seeing a crash during shutdown in rb_gc_impl_objspace_free because
it's running lazy sweeping during shutdown. It appears that it's due to
`finalizing` being set, which causes GC to not be aborted and not
disabled which causes it to be in lazy sweeping at shutdown.

The full stack trace is:

    #6  rb_bug (fmt=fmt@entry=0x5643b8ebde78 "lazy sweeping underway when freeing object space") at error.c:1095
    #7  0x00005643b8a3c697 in rb_gc_impl_objspace_free (objspace_ptr=<optimized out>) at gc/default.c:9507
    #8  0x00005643b8c269eb in ruby_vm_destruct (vm=0x7e2fdc84d000) at vm.c:3141
    #9  0x00005643b8a5147b in rb_ec_cleanup (ec=<optimized out>, ex=<optimized out>) at eval.c:263
    #10 0x00005643b8a51c93 in ruby_run_node (n=<optimized out>) at eval.c:319
    #11 0x00005643b8a4c7c7 in rb_main (argv=0x7fffef15e7f8, argc=18) at ./main.c:43
    #12 main (argc=<optimized out>, argv=<optimized out>) at ./main.c:62
2024-08-08 10:11:49 -04:00
Hiroshi SHIBATA
da8cf99cb5
Added test scenario for https://github.com/ruby/ruby/pull/11322 2024-08-08 16:23:49 +09:00
Hiroshi SHIBATA
7e0910a82c
We should use uplevel:2 in another case.
Like the following scenario with bootsnap, that frames are same or smaller than frame_to_skip(=3).

---
"/Users/hsbt/.local/share/rbenv/versions/3.3-dev/lib/ruby/3.3.0/bundled_gems.rb:69:in `block (2 levels) in replace_require'"
"/Users/hsbt/.local/share/gem/gems/bootsnap-1.18.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'"
"test_warn_bootsnap.rb:11:in `<main>'"
---
2024-08-08 16:20:22 +09:00
Jean Boussier
7594a292b1
lib/bundled_gems.rb: more reliable caller detection
The `2` skipped frames went out of sync and now it should be `3`.

Rather than just update the offset, we can implement a way that
is adaptative as long as all require decorators are also called require.

Also we should compute the corresponding `uplevel` otherwise the
warning will still point decorators.

Co-authored-by: "Hiroshi SHIBATA" <hsbt@ruby-lang.org>
2024-08-08 15:50:26 +09:00