Commit graph

83750 commits

Author SHA1 Message Date
Nobuyoshi Nakada
01c7e16c0c Separate miniruby from dmyext.c 2024-02-21 23:37:20 +09:00
Samuel Williams
04729fe68d
Fix exception handling in rb_fiber_scheduler_set. (#10042) 2024-02-22 00:33:18 +13:00
Samuel Williams
78d9fe6947
Ensure that exiting thread invokes end-of-life behaviour. (#10039) 2024-02-22 00:32:59 +13:00
Yuta Saito
fd91354628 [DOC] Comment about logic to care about static/dynamic hetero build
The condition is rarely met in usual cases, so it's worth to note about
the situation and the reason why we care about it.
2024-02-21 19:37:06 +09:00
Nobuyoshi Nakada
6aa5067ab9
Revert rubygems tempdir check
This check was added to check if other tests still remain tempdir, and these tests do on Windows.

* `TestGemCommandsSetupCommand#test_destdir_flag_does_not_try_to_write_to_the_default_gem_home`
* `TestGemInstaller#test_install_build_root_when_gem_home_not_writable_does_not_fallback_to_user_install_inside_build_root`

Also some tests fail due to too long path names.
2024-02-21 10:28:23 +00:00
Yusuke Endoh
b1431ce427 Add comments to dmydln.c, dmyenc.c, and dmyext.c
They are used conditionally in miniruby, dynamically-linked ruby, and
statically-linked ruby (--with-static-linked-ext).
I asked @nobu about the conditions. and I leave comments because the
conditions are insanely difficult.
2024-02-21 17:57:48 +09:00
Nobuyoshi Nakada
6ecb14df2c [rubygems/rubygems] Reset Gem.state_file along with Gem.state_home
As `Gem.state_file` is placed under `Gem.state_home` directory, when
the latter is reset, also the former should be reset.
If left unreset, the file for a previously run test will be re-created
and will not be deleted.

1378d07afd
2024-02-21 08:14:34 +00:00
Nobuyoshi Nakada
1fa4d15ca7
Add Test::Unit::TestCase#method_name
For the compatibility with test-unit gem.
2024-02-21 15:45:53 +09:00
Hiroshi SHIBATA
fc1a7a46dc [rubygems/rubygems] Use Hash#compact
9d4ff6ff30

Co-authored-by: Samuel Giddins <segiddins@segiddins.me>
2024-02-21 06:39:37 +00:00
Nobuyoshi Nakada
c8fb4f308b [rubygems/rubygems] Skip nil-value keys to make metadata reproducible
Nil-value keys in a mapping end with a space or not depending on
libyaml versions, and result metadata are different per platforms.
This commit makes to skip such keys to make metadata reproducible
accross platforms.

74b4db8d30
2024-02-21 06:39:36 +00:00
Koichi Sasada
d578684989 rb_thread_lock_native_thread()
Introduce `rb_thread_lock_native_thread()` to allocate dedicated
native thread to the current Ruby thread for M:N threads.
This C API is similar to Go's `runtime.LockOSThread()`.

Accepted at https://github.com/ruby/dev-meeting-log/blob/master/2023/DevMeeting-2023-08-24.md
(and missed to implement on Ruby 3.3.0)
2024-02-21 15:38:29 +09:00
yui-knk
91cb303531 Remove not used universal parser macros and functions 2024-02-21 13:36:45 +09:00
Hiroshi SHIBATA
d0786cde3f [rubygems/rubygems] rake man:build
e0ef515732
2024-02-21 03:30:23 +00:00
Hiroshi SHIBATA
08753f2037 [rubygems/rubygems] Use https instead of http
bcbe6f7b7a
2024-02-21 03:30:22 +00:00
Yusuke Endoh
a605234bfa NEWS.md: Add a note for [Feature #16495] and [Feature #19117] 2024-02-20 16:17:20 +09:00
John Hawthorn
081ee3d355 Add memory leak test for eval kwargs 2024-02-20 18:55:00 -08:00
John Hawthorn
1c97abaaba De-dup identical callinfo objects
Previously every call to vm_ci_new (when the CI was not packable) would
result in a different callinfo being returned this meant that every
kwarg callsite had its own CI.

When calling, different CIs result in different CCs. These CIs and CCs
both end up persisted on the T_CLASS inside cc_tbl. So in an eval loop
this resulted in a memory leak of both types of object. This also likely
resulted in extra memory used, and extra time searching, in non-eval
cases.

For simplicity in this commit I always allocate a CI object inside
rb_vm_ci_lookup, but ideally we would lazily allocate it only when
needed. I hope to do that as a follow up in the future.
2024-02-20 18:55:00 -08:00
Alan Wu
2a6917b463 Fix string value in hash literal being forced frozen
We should pass `false` for `hash_key` for value nodes. Credits to
`@kddnewton` for noticing and bisecting.
2024-02-20 21:00:54 -05:00
yui-knk
5fb574ae4e rb_parser_warn_duplicate_keys doesn't need to take care of NODE_LIT anymore
NODE_LIT is created only for `shareable_constant_value`.
This means hash key node is never NODE_LIT.
2024-02-21 10:57:32 +09:00
Takashi Kokubun
ce4142bcb7
YJIT: rb_str_concat_literals is not leaf (#10035) 2024-02-20 17:23:08 -08:00
yui-knk
776dbbba72 Remove hack for ripper.y generation
Before Rearchitect Ripper (89cfc15), parser and ripper used different
semantic value data type for same symbols.
"ext/ripper/tools/preproc.rb" replaced these types when it generated
ripper.y. Starting the line with other than `%token` suppressed
the type replacement.
However, after Rearchitect Ripper, both parser and ripper use
same semantic value data type. Therefore these comments are not needed
anymore.
2024-02-21 09:16:09 +09:00
yui-knk
e7ab5d891c Introduce NODE_REGX to manage regexp literal 2024-02-21 08:06:48 +09:00
Peter Zhu
97d4363d3b [DOC] Improve docs for GC.latest_compact_info 2024-02-20 17:39:46 -05:00
Alan Wu
35fdf1a624 YJIT: Remove duplicate test 2024-02-20 16:53:36 -05:00
Alan Wu
8e1090487e YJIT: Fix calling leaf builtins with empty splat and kw_splat
These don't pass anything and just need to be popped off the stack.

2178009528 (step):13:104
2024-02-20 16:53:36 -05:00
Takashi Kokubun
9216a2ac43
YJIT: Verify the assumption of leaf C calls (#10002) 2024-02-20 13:42:29 -08:00
Burdette Lamar
d4b4b53bc0
[DOC] Fix links in doc (#9970) 2024-02-20 16:10:52 -05:00
Koichi Sasada
b3c13de858 skip a test on non-UTF-8 locale
`ruby --parser=prism -W:no-experimental --dump=parsetree -e :hi` prints
non-ASCII char(s) so the following test with non UTF-8 locale fails.

```
$ LANG=C make test-all TESTS='-n /parser/ ruby/rubyoptions' -o encs -o exts
Run options:
  --seed=32323
  "--ruby=./miniruby -I/home/ko1/ruby/src/master/lib -I. -I.ext/common  /home/ko1/ruby/src/master/tool/runruby.rb --extout=.ext  -- --disable-gems"
  --excludes-dir=/home/ko1/ruby/src/master/test/.excludes
  --name=!/memory_leak/
  -n
  /parser/

[1/1] TestRubyOptions#test_parser_flag = 0.04 s
  1) Failure:
TestRubyOptions#test_parser_flag [/home/ko1/ruby/src/master/test/ruby/test_rubyoptions.rb:300]:
pid 135869 exit 0.

1. [1/2] Assertion for "stdout"
   | invalid byte sequence in US-ASCII.

Finished tests in 0.044362s, 22.5416 tests/s, 225.4157 assertions/s.
1 tests, 10 assertions, 1 failures, 0 errors, 0 skips

ruby -v: ruby 3.4.0dev (2024-02-20T17:13:36Z master c0e5de9567) [x86_64-linux]
make: *** [uncommon.mk:945: yes-test-all] Error 1
```

Now simply skip the test if the locale is not UTF-8.
(I'm not familiar with encodings so please fix it if needed)
2024-02-21 03:59:19 +09:00
Jeremy Evans
77c1233f79 Add pushtoarraykwsplat instruction to avoid unnecessary array allocation
This is designed to replace the newarraykwsplat instruction, which is
no longer used in the parse.y compiler after this commit.  This avoids
an unnecessary array allocation in the case where ARGSCAT is followed
by LIST with keyword:

```ruby
a = []
kw = {}
[*a, 1, **kw]
```

Previous Instructions:

```
0000 newarray                               0                         (   1)[Li]
0002 setlocal_WC_0                          a@0
0004 newhash                                0                         (   2)[Li]
0006 setlocal_WC_0                          kw@1
0008 getlocal_WC_0                          a@0                       (   3)[Li]
0010 splatarray                             true
0012 putobject_INT2FIX_1_
0013 putspecialobject                       1
0015 newhash                                0
0017 getlocal_WC_0                          kw@1
0019 opt_send_without_block                 <calldata!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE>
0021 newarraykwsplat                        2
0023 concattoarray
0024 leave
```

New Instructions:

```
0000 newarray                               0                         (   1)[Li]
0002 setlocal_WC_0                          a@0
0004 newhash                                0                         (   2)[Li]
0006 setlocal_WC_0                          kw@1
0008 getlocal_WC_0                          a@0                       (   3)[Li]
0010 splatarray                             true
0012 putobject_INT2FIX_1_
0013 pushtoarray                            1
0015 putspecialobject                       1
0017 newhash                                0
0019 getlocal_WC_0                          kw@1
0021 opt_send_without_block                 <calldata!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE>
0023 pushtoarraykwsplat
0024 leave
```

pushtoarraykwsplat is designed to be simpler than newarraykwsplat.
It does not take a variable number of arguments from the stack, it
pops the top of the stack, and appends it to the second from the top,
unless the top of the stack is an empty hash.

During this work, I found the ARGSPUSH followed by HASH with keyword
did not compile correctly, as it pushed the generated hash to the
array even if the hash was empty.  This fixes the behavior, to use
pushtoarraykwsplat instead of pushtoarray in that case:

```ruby
a = []
kw = {}
[*a, **kw]

[{}] # Before

[] # After
```

This does not remove the newarraykwsplat instruction, as it is still
referenced in the prism compiler (which should be updated similar
to this), YJIT (only in the bindings, it does not appear to be
implemented), and RJIT (in a couple comments).  After those are
updated, the newarraykwsplat instruction should be removed.
2024-02-20 10:47:44 -08:00
Alan Wu
2e2e3d89af
YJIT: Support **nil for cfuncs
Similar to the iseq call support. Fairly straight forward.
2024-02-20 18:29:02 +00:00
Takashi Kokubun
c0e5de9567 Fix the version in missing-baseruby 2024-02-20 09:13:36 -08:00
Peter Zhu
c184aa8740 Use rb_gc_mark_and_move for imemo 2024-02-20 10:39:30 -05:00
Kevin Newton
20f03100d5 [ruby/prism] Fix eval encoding switching to UTF-8
24e3ff5d6d
2024-02-20 15:36:35 +00:00
Nobuyoshi Nakada
835fa98a62 Update warning flags before dump 2024-02-20 23:56:07 +09:00
Kevin Newton
bcfcdae58e [ruby/prism] Fix windows build checking for _POSIX_MAPPED_FILES
acf603603f
2024-02-20 14:31:03 +00:00
HASUMI Hitoshi
f0a46c6334 [ruby/prism] Include unistd.h before cheching _POSIX_MAPPED_FILES
84b3c294f0
2024-02-20 14:21:17 +00:00
HASUMI Hitoshi
15b53e901c [ruby/prism] Use _POSIX_MAPPED_FILES and _WIN32 to know if memory map interface is available in the target platform
88e2ff52d4
2024-02-20 14:21:16 +00:00
Hiroshi SHIBATA
c22cb960cf
Use commit with Ruby 3.4 support 2024-02-20 20:52:09 +09:00
Nobuyoshi Nakada
386b956ad8
Remove never used method 2024-02-20 20:14:37 +09:00
Nobuyoshi Nakada
e3917fc7da
Remove no longer used methods
`find_object_in_recycled_slot` and `memory_location` have not been
used since commit:b99833baec2e567e38758f4fd017c90c7ce57d75.
2024-02-20 20:14:37 +09:00
yui-knk
7cb8fd7800 Move ripper_validate_object to ripper_init.c.tmpl 2024-02-20 19:19:31 +09:00
Hiroshi SHIBATA
fa3d6aafb7 [ruby/uri] Use https instead of http
ad2591f0d1
2024-02-20 10:13:30 +00:00
yui-knk
474f41880f Suppress unused function warning for UNIVERSAL_PARSER build
Suppress the warning:

```
parse.y:2221:1: warning: unused function 'rb_parser_str_hash' [-Wunused-function]
 2221 | rb_parser_str_hash(rb_parser_string_t *str)
      | ^~~~~~~~~~~~~~~~~~
```
2024-02-20 19:07:40 +09:00
S-H-GAMELINKS
fba647087b Remove uneeded Universal Parser properties 2024-02-20 19:02:24 +09:00
yui-knk
2a4b6ed37c Workaround for Prism::ParseTest#test_filepath for "unparser/corpus/literal/def.txt"
See the discussion on https://github.com/ruby/ruby/pull/9923
2024-02-20 17:33:58 +09:00
yui-knk
20dbc7a5f4 Skip test_filepath of "unparser/corpus/literal/def.txt"
The previous commit changes Ripper lex state behavior of `tLABEL`.
For example, Ripper lex state for the second `bar` was changed
by the previous commit.

```
def foo(bar: bar())
end
```

Before the commit, Ripper didn’t add label `bar` id to `vtable`
because `formal_argument` function for Ripper didn’t return id
but returned `VALUE lhs`.
Therefore Ripper didn’t `SET_LEX_STATE(EXPR_END|EXPR_LABEL)` for following `bar`
in `parse_ident` because `lvar_defined` for following `bar` was not true.

Currently Ripper does `SET_LEX_STATE(EXPR_END|EXPR_LABEL)` then
the result of this test case is changed like below.

```
Prism::ParseTest#test_filepath_unparser/corpus/literal/def.txt [ruby/test/prism/parse_test.rb:280]:
<[[80, 13], :on_ident, “bar”, END|LABEL]> expected but was
<[[80, 13], :on_ident, “bar”, ARG]>.
```

Parser sets lex state to `END|LABEL` on master branch.
Therefore previous commit makes Ripper’s behavior aligned with parser’s behavior.

```
$ ruby -v -y -e "def foo(bar: bar())" -e "end"
ruby 3.4.0dev (2024-02-11T23:52:05Z master 697ade7bda) [arm64-darwin21]
...
Reading a token
parser_dispatch_scan_event:11210 (1: 12|1|7)
lex_state: ARG|LABELED -> ARG at line 11113
lex_state: ARG -> END|LABEL at line 11128
parser_dispatch_scan_event:11877 (1: 13|3|4)
Next token is token “local variable or method” (1.13-1.16: bar)
Shifting token “local variable or method” (1.13-1.16: bar)
```
2024-02-20 17:33:58 +09:00
yui-knk
89cfc15207 [Feature #20257] Rearchitect Ripper
Introduce another semantic value stack for Ripper so that
Ripper can manage both Node and Ruby Object separately.
This rearchitectutre of Ripper solves these issues.
Therefore adding test cases for them.

* [Bug 10436] https://bugs.ruby-lang.org/issues/10436
* [Bug 18988] https://bugs.ruby-lang.org/issues/18988
* [Bug 20055] https://bugs.ruby-lang.org/issues/20055

Checked the differences of `Ripper.sexp` for files under `/test/ruby`
are only on test_pattern_matching.rb.
The differences comes from the differences between
`new_hash_pattern_tail` functions between parser and Ripper.
Ripper `new_hash_pattern_tail` didn’t call `assignable` then
`kw_rest_arg` wasn’t marked as local variable.
This is also fixed by this commit.

```
--- a/./tmp/before/test_pattern_matching.rb
+++ b/./tmp/after/test_pattern_matching.rb
@@ -3607,7 +3607,7 @@
                  [:in,
                   [:hshptn, nil, [], [:var_field, [:@ident, “a”, [984, 13]]]],
                   [[:binary,
-                    [:vcall, [:@ident, “a”, [985, 10]]],
+                    [:var_ref, [:@ident, “a”, [985, 10]]],
                     :==,
                     [:hash, nil]]],
                   nil]]],
@@ -3662,7 +3662,7 @@
                  [:in,
                   [:hshptn, nil, [], [:var_field, [:@ident, “a”, [993, 13]]]],
                   [[:binary,
-                    [:vcall, [:@ident, “a”, [994, 10]]],
+                    [:var_ref, [:@ident, “a”, [994, 10]]],
                     :==,
                     [:hash,
                      [:assoclist_from_args,
@@ -3813,7 +3813,7 @@
                    [:command,
                     [:@ident, “raise”, [1022, 10]],
                     [:args_add_block,
-                     [[:vcall, [:@ident, “b”, [1022, 16]]]],
+                     [[:var_ref, [:@ident, “b”, [1022, 16]]]],
                      false]]],
                   [:else, [[:var_ref, [:@kw, “true”, [1024, 10]]]]]]]],
                nil,
@@ -3876,7 +3876,7 @@
                      [:@int, “0”, [1033, 15]]],
                     :“&&“,
                     [:binary,
-                     [:vcall, [:@ident, “b”, [1033, 20]]],
+                     [:var_ref, [:@ident, “b”, [1033, 20]]],
                      :==,
                      [:hash, nil]]]],
                   nil]]],
@@ -3946,7 +3946,7 @@
                      [:@int, “0”, [1042, 15]]],
                     :“&&“,
                     [:binary,
-                     [:vcall, [:@ident, “b”, [1042, 20]]],
+                     [:var_ref, [:@ident, “b”, [1042, 20]]],
                      :==,
                      [:hash,
                       [:assoclist_from_args,
@@ -5206,7 +5206,7 @@
                      [[:assoc_new,
                        [:@label, “c:“, [1352, 22]],
                        [:@int, “0”, [1352, 25]]]]]],
-                   [:vcall, [:@ident, “r”, [1352, 29]]]],
+                   [:var_ref, [:@ident, “r”, [1352, 29]]]],
                   false]]],
                [:binary,
                 [:call,
@@ -5299,7 +5299,7 @@
                       [:assoc_new,
                        [:@label, “c:“, [1367, 34]],
                        [:@int, “0”, [1367, 37]]]]]],
-                   [:vcall, [:@ident, “r”, [1367, 41]]]],
+                   [:var_ref, [:@ident, “r”, [1367, 41]]]],
                   false]]],
                [:binary,
                 [:call,
@@ -5931,7 +5931,7 @@
              [:in,
               [:hshptn, nil, [], [:var_field, [:@ident, “r”, [1533, 11]]]],
               [[:binary,
-                [:vcall, [:@ident, “r”, [1534, 8]]],
+                [:var_ref, [:@ident, “r”, [1534, 8]]],
                 :==,
                 [:hash,
                  [:assoclist_from_args,
```
2024-02-20 17:33:58 +09:00
Hiroshi SHIBATA
f75b9dbf7d [rubygems/rubygems] Keep Gem.install_extension_in_lib for compatibility
b2bf239147
2024-02-20 05:33:16 +00:00
Hiroshi SHIBATA
f2d453347f [rubygems/rubygems] re-order util methods
4b5eb7a02c
2024-02-20 05:33:15 +00:00
Hiroshi SHIBATA
018261eb92 [rubygems/rubygems] Added small tests
08a245bdf8
2024-02-20 05:33:15 +00:00