Граф коммитов

81759 Коммитов

Автор SHA1 Сообщение Дата
David Rodríguez 01a2a0abc6 [rubygems/rubygems] Migrate documentation to be generated with nronn
https://github.com/rubygems/rubygems/commit/55281f0eaa
2023-12-08 16:01:01 +09:00
David Rodríguez 1c3aa4b977 [rubygems/rubygems] Add extra blank line to `bundle outdated` docs
If it's not there, when migrating to `nronn`, generated man page is
messed up.

https://github.com/rubygems/rubygems/commit/7161347648
2023-12-08 16:01:01 +09:00
David Rodríguez dc64a04a12 [rubygems/rubygems] Revert "Merge pull request #7148 from Paul-Bob/improvement/include_response_body_on_fetch_http_error"
This reverts commit https://github.com/rubygems/rubygems/commit/e5a4fd9eb617, reversing
changes made to https://github.com/rubygems/rubygems/commit/c5a5363b0c98.

https://github.com/rubygems/rubygems/commit/e21c45c4c3
2023-12-08 16:01:01 +09:00
Hiroshi SHIBATA 8f6cf72e66
Skip to warn like 'bigdecimal/util' feature. 2023-12-08 15:57:08 +09:00
David Rodríguez 64e985333f Improve bundled gems warnings for subfeatures
Before, when requiring "bigdecimal/math" in a Bundler context:

> /Users/deivid/.asdf/installs/ruby/3.3.0-dev/lib/ruby/3.3.0+0/bigdecimal/math.rb:2: warning: bigdecimal was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add bigdecimal to your Gemfile or gemspec.

After:

> foo.rb:1: warning: bigdecimal/math is found in bigdecimal, which will no longer be part of the default gems since Ruby 3.4.0. Add bigdecimal to your Gemfile or gemspec.
2023-12-08 15:55:15 +09:00
David Rodríguez a530dfef2b Improve bundled gem warnings
Before, when requiring "bigdecimal" in a Bundler context:

> foo.rb:1: warning: bigdecimal which will no longer be part of the default gems since Ruby 3.4.0. Add bigdecimal to your Gemfile or gemspec.

After:

> foo.rb:1: warning: bigdecimal was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add bigdecimal to your Gemfile or gemspec.
2023-12-08 15:55:15 +09:00
David Rodríguez d61af5c49a The SINCE and WARNED hashes take gem names, not features 2023-12-08 15:55:15 +09:00
Samuel Giddins 4817166e54 [rubygems/rubygems] Extract generate_index command to rubygems-generate_index gem
So generate_index can be implemented with dependencies, such as the compact index

Took this approach from feedback in https://github.com/rubygems/rubygems/pull/6853

Running `gem generate_index` by default will use an installed rubygems-generate_index, or install and then use the command from the gem

Apply suggestions from code review

https://github.com/rubygems/rubygems/commit/fc1cb9bc9e

Co-authored-by: Hiroshi SHIBATA <hsbt@ruby-lang.org>
2023-12-08 06:09:51 +00:00
Martin Emde 0166d56f2b [rubygems/rubygems] Don't memoize in NameTuple lock_name
The result of this is already memoized and no other NameTuple
methods memoize.

https://github.com/rubygems/rubygems/commit/b7cce0c64a
2023-12-08 05:51:03 +00:00
卜部昌平 51ab9ebca1 [ci skip] comment for commit be1bbd5b7d 2023-12-08 13:17:56 +09:00
Koichi Sasada 352a885a0f Thread specific storage APIs
This patch introduces thread specific storage APIs
for tools which use `rb_internal_thread_event_hook` APIs.

* `rb_internal_thread_specific_key_create()` to create a tool specific
  thread local storage key and allocate the storage if not available.
* `rb_internal_thread_specific_set()` sets a data to thread and tool
  specific storage.
* `rb_internal_thread_specific_get()` gets a data in thread and tool
  specific storage.

Note that `rb_internal_thread_specific_get|set(thread_val, key)`
can be called without GVL and safe for async signal and safe for
multi-threading (native threads). So you can call it in any internal
thread event hooks. Further more you can call it from other native
threads. Of course `thread_val` should be living while accessing the
data from this function.

Note that you should not forget to clean up the set data.
2023-12-08 13:16:19 +09:00
Nobuyoshi Nakada 9b7a964318 [Bug #19877] Flip-flop needs to be direct condition 2023-12-08 12:53:47 +09:00
Yuji Yaginuma 8bb90f4d77 [rubygems/rubygems] Use `Minitest::TestTask` in a template file for `minitest`
`minitest` has introduced a rake task for running test on 5.16.0.
https://github.com/minitest/minitest/blob/master/History.rdoc#5160--2022-06-14-

This has some tasks related to running tests and it's useful for
`minitest` user I think.
https://github.com/minitest/minitest#rake-tasks-

This PR changed to use the task in a template file for `minitest`

https://github.com/rubygems/rubygems/commit/7a86d13062
2023-12-08 03:25:43 +00:00
Takashi Kokubun ac5fd58700
YJIT: Fix on-stack ISEQ comparison for auto_compact (#9164) 2023-12-07 22:53:05 +00:00
David Rodríguez 2755cb1b2f [rubygems/rubygems] Use modern hashes consistently
https://github.com/rubygems/rubygems/commit/bb66253f2c
2023-12-07 22:29:33 +00:00
Aaron Patterson 9d696aa204 Support method calls inside `defined?`
This commit supports all kinds of method calls (including methods with
parameters) inside `defined?` calls.
2023-12-07 14:07:09 -08:00
BurdetteLamar f76881c9af RDoc for Complex 2023-12-07 16:34:41 -05:00
Adam Hess 6816e8efcf Free everything at shutdown
when the RUBY_FREE_ON_SHUTDOWN environment variable is set, manually free memory at shutdown.

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Co-authored-by: Peter Zhu <peter@peterzhu.ca>
2023-12-07 15:52:35 -05:00
Jemma Issroff b361a800c2 Added comment 2023-12-07 15:29:35 -05:00
Jemma Issroff a0c7bb4328 [PRISM] Account for multiple arguments when compiling ArgumentsNode
BreakNode, ReturnNode and NextNode all compile the ArgumentsNode
directly, but we weren't accounting for multiple arguments. If there
is more than one argument, we need to also emit a newarray
instruction to put the arguments onto the stack
2023-12-07 15:29:35 -05:00
Jeremy Evans 7738b31d39 Eliminate array allocation for f(1, *a, &arg), f(*a, **kw, &arg), and f(*a, kw: 1, &arg)
These are similar to the f(1, *a, &lvar), f(*a, **kw, &lvar) and
f(*a, kw: 1, &lvar) optimizations, but they use getblockparamproxy
instruction instead of getlocal.

This also fixes the else style to be more similar to the surrounding
code.
2023-12-07 11:27:55 -08:00
Jeremy Evans f5a01b0916 Add benchmark for recent optimization to avoid implicit allocations 2023-12-07 11:27:55 -08:00
Jeremy Evans 13cd963500 Prevent modification of splat array inside setup_parameters_complex
For the following:

```
def f(*a); a end
p f(*a, kw: 3)
```

`setup_parameters_complex` pushes `{kw: 3}` onto `a`.  This worked fine
back when `concatarray true` was used and `a` was already a copy. It
does not work correctly with the optimization to switch to
`concatarray false`.  This duplicates the array on the callee side
in such a case.

This affects cases when passing a regular splat and a keyword splat
(or literal keywords) in a method call, where the method does not
accept keywords.

This allocation could probably be avoided, but doing so would
make `setup_parameters_complex` more complicated.
2023-12-07 11:27:55 -08:00
Jeremy Evans aa808204bb Eliminate array allocation for f(*a, kw: 1, &lvar) and f(*a, kw: 1, &@iv)
Similar to the previous commit, but this handles the block pass
case.
2023-12-07 11:27:55 -08:00
Jeremy Evans 5e33f2b0e4 Eliminate array allocation for f(*a, kw: 1)
In cases where the compiler can detect the hash is static, it would
use duphash for the hash part. As the hash is static, there is no need
to allocate an array.
2023-12-07 11:27:55 -08:00
Jeremy Evans 95615872e3 Eliminate array allocation for f(*a, **lvar, &lvar) and f(*a, **@iv, &@iv)
The compiler already eliminates the array allocation for
f(*a, &lvar) and f(*a, &@iv).  If that is safe, then eliminating
it for f(*a, **lvar) and f(*a, **@iv) as the last commit did is
as safe, and eliminating it for f(*a, **lvar, &lvar) and
f(*a, **@iv, &@iv) is also as safe.
2023-12-07 11:27:55 -08:00
Jeremy Evans 1731dd05a7 Eliminate array allocation for f(*a, **lvar) and f(*a, **@iv)
The compiler already eliminates the array allocation for
f(*a, &lvar) and f(*a, &@iv), and eliminating the array allocation
for keyword splat is as safe as eliminating it for block passes.
2023-12-07 11:27:55 -08:00
Jeremy Evans c70c1d2a95 Eliminate array allocation for f(1, *a, &lvar) and f(1, *a, &@iv)
Due to how the compiler works, while f(*a, &lvar) and f(*a, &@iv)
do not allocate an array, but f(1, *a, &lvar) and f(1, *a, &@iv)
do.  It's probably possible to fix this in the compiler, but
seems easiest to fix this in the peephole optimizer.

Eliminating this array allocation is as safe as the current
elimination of the array allocation for f(*a, &lvar) and
f(*a, &@iv).
2023-12-07 11:27:55 -08:00
Jeremy Evans 40a2afd08f Eliminate array allocation for f(1, *a)
Due to how the compiler works, while f(*a) does not allocate an
array f(1, *a) does.  This is possible to fix in the compiler, but
the change is much more complex.  This attempts to fix the issue
in a simpler way using the peephole optimizer.

Eliminating this array allocation is safe, since just as in the
f(*a) case, nothing else on the caller side can modify the array.
2023-12-07 11:27:55 -08:00
Matt Valentine-House 41b299d639 [PRISM] Stop catch table entries being deleted by the optimiser 2023-12-07 14:12:20 -05:00
Jeremy Evans 3081c83169 Support tracing of struct member accessor methods
This follows the same approach used for attr_reader/attr_writer in
2d98593bf5, skipping the checking for
tracing after the first call using the call cache, and clearing the
call cache when tracing is turned on/off.

Fixes [Bug #18886]
2023-12-07 10:29:33 -08:00
Takashi Kokubun 1721bb9dc6 Skip a flaky objspace test on Visual Studio
This seems to happen only on VisualStudio:
https://github.com/ruby/ruby/actions/runs/7130917319/job/19418375386

It fails relatively frequently. Nobody seems actively working on it, so
let's skip it until somebody starts working on it.
2023-12-07 09:42:56 -08:00
Jeremy Evans 3a88de3ca7 Support eval "return" at toplevel
Since Ruby 2.4, `return` is supported at toplevel.  This makes `eval "return"`
also supported at toplevel.

This mostly uses the same tests as direct `return` at toplevel, with a couple
differences:

`END {return if false}` is a SyntaxError, but `END {eval "return" if false}`
is not an error since the eval is never executed. `END {return}` is a
SyntaxError, but `END {eval "return"}` is a LocalJumpError.

The following is a SyntaxError:

```ruby
class X
nil&defined?0--begin e=no_method_error(); return; 0;end
end
```

However, the following is not, because the eval is never executed:

```ruby
class X
nil&defined?0--begin e=no_method_error(); eval "return"; 0;end
end
```

Fixes [Bug #19779]
2023-12-07 09:30:36 -08:00
John Hawthorn 0c3593b657 Use free with ruby_dtoa
In ae0ceafb0c0d05cc80623b525070255e3abb34ef ruby_dtoa was switched to
use malloc instead of xmalloc, which means that consumers should be
using free instead of xfree. Otherwise we will artificially shrink
oldmalloc_increase_bytes.
2023-12-07 09:23:02 -08:00
John Hawthorn 5f81f58b26 Use xfree in hash_st_free
st.c redefines malloc and free to be ruby_xmalloc and ruby_xfree, so
when this was copied into hash.c it ended up mismatching an xmalloc with
a regular free, which ended up inflating oldmalloc_increase_bytes when
hashes were freed by minor GC.
2023-12-07 09:22:21 -08:00
Jeremy Evans ca204a2023
Fix keyword splat passing as regular argument
Since Ruby 3.0, Ruby has passed a keyword splat as a regular
argument in the case of a call to a Ruby method where the
method does not accept keyword arguments, if the method
call does not contain an argument splat:

```ruby
def self.f(obj) obj end
def self.fs(*obj) obj[0] end
h = {a: 1}
f(**h).equal?(h)  # Before: true; After: false
fs(**h).equal?(h) # Before: true; After: false

a = []
f(*a, **h).equal?(h)  # Before and After: false
fs(*a, **h).equal?(h) # Before and After: false
```

The fact that the behavior differs when passing an empty
argument splat makes it obvious that something is not
working the way it is intended.  Ruby 2 always copied
the keyword splat hash, and that is the expected behavior
in Ruby 3.

This bug is because of a missed check in setup_parameters_complex.
If the keyword splat passed is not mutable, then it points to
an existing object and not a new object, and therefore it must
be copied.

Now, there are 3 specs for the broken behavior of directly
using the keyword splatted hash.  Fix two specs and add a
new version guard. Do not keep the specs for the broken
behavior for earlier Ruby versions, in case this fix is
backported. For the ruby2_keywords spec, just remove the
related line, since that line is unrelated to what the
spec is testing.

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2023-12-07 08:35:55 -08:00
Nobuyoshi Nakada e6a6ea9dcf
Fix typo in a comment [ci skip] 2023-12-08 01:20:15 +09:00
Alan Wu 195dbf241f Fix potential compaction issue in env_copy()
`src_ep[VM_ENV_DATA_INDEX_ME_CREF]` was read out and held without
marking across the allocation in vm_env_new(). In case vm_env_new() ran
compaction, an invalid reference could have been written into
`copied_env`.

It might've been hard to actually produce a crash with this issue due to
the pinning marking of the field in rb_execution_context_mark().
2023-12-07 11:16:12 -05:00
Alan Wu 050806f425 Add missing write barrier to env_copy()
Previously, the following crashed with
`vm_assert_env:imemo_type_p(obj, imemo_env)` due to missing a missing
WB:

    o = Object.new
    def o.foo(n)
      freeze

      GC.stress = 1

      # inflate block nesting get an imemo_env for each level
      n.tap do |i|
        i.tap do |local|
          return Ractor.make_shareable(-> do
            local + i + n
          end)
        end
      end
    ensure
      GC.stress = false
      GC.verify_internal_consistency
    end

    p o.foo(1)[]

By the time the recursive env_copy() call returns, `copied_env` could
have aged or have turned greyed, so we need a WB for the
`ep[VM_ENV_DATA_INDEX_SPECVAL]` assignment which adds an edge.

Fix: 674eb7df7f
2023-12-07 11:16:12 -05:00
Stan Lo 5809b75019 [ruby/irb] Debugging command warning should not be specific to the
`debug` command
(https://github.com/ruby/irb/pull/806)

https://github.com/ruby/irb/commit/b7b57311cc
2023-12-07 16:09:15 +00:00
Kevin Newton c05278e425 [ruby/prism] Update ordering of integer base flags
https://github.com/ruby/prism/commit/d711950d5f
2023-12-07 16:00:41 +00:00
Peter Zhu 0dc40bd2b7 Check need_major_gc during GC stress
need_major_gc is set when a major GC is required. However, if
gc_stress_no_major is also set, then it will not actually run a major
GC.

For example, the following script will sometimes crash:

```
GC.stress = 1
50000.times.map { [] }
```

With the following message:

```
[BUG] cannot create a new page after major GC
```
2023-12-07 10:49:06 -05:00
Jemma Issroff b8df6b9e01 [PRISM] Don't pop arguments on a return node
Since ReturnNodes don't get popped, their arguments shouldn't either
2023-12-07 10:34:39 -05:00
KJ Tsanaktsidis cbc0e0bef0 Fix GC.verify_compaction_references not moving every object
The intention of GC.verify_compaction_references is, I believe, to force
every single movable object to be moved, so that it's possible to debug
native extensions which not correctly updating their references to
objects they mark as movable.

To do this, it doubles the number of allocated pages for each size pool,
and sorts the heap pages so that the free ones are swept first; thus,
every object in an old page should be moved into a free slot in one of
the new pages.

This worked fine until movement of objects _between_ size pools during
compaction was implemented. That causes some problems for
verify_compaction_references:

* We were doubling the number of pages in each size pool, but actually
  if some objects need to move into a _different_ pool, there's no
  guarantee that they'll be enough room in that one.
* It's possible for the sweep & compact cursors to meet in one size pool
  before all the objects that want to move into that size pool from
  another are processed by the compaction.

You can see these problems by changing some of the movement tests in
test_gc_compact.rb to try and move e.g. 50,000 objects instead of
500; the test is not able to actually move all of the objects in a
single compaction run.

To fix this, we do two things in verify_compaction_references:

* Firstly, we add enough pages to every size pool to make them the same
  size. This ensures that their compact cursors will all have space to
  move during compaction (even if that means empty pages are
  pointlessly compacted)
* Then, we examine every object and determine where it _wants_ to be
  compacted into. We use this information to add additional pages to
  each size pool to handle all objects which should live there.

With these two changes, we can move arbitrary amounts of objects into
the correct size pool in a single call to verify_compaction_references.

My _motivation_ for performing this work was to try and fix some test
stability issues in test_gc_compact.rb. I now no longer think that we
actually see this particular bug in rubyci.org, but I also think
verify_compaction_references should do what it says on the tin, so it's
worth keeping.

[Bug #20022]
2023-12-07 10:19:35 -05:00
KJ Tsanaktsidis 5d832d16d9 Add objspace_each_pages to gc.c
This works like objspace_each_obj, except instead of being called with
the start & end address of each page, it's called with the page
structure itself.

[Bug #20022]
2023-12-07 10:19:35 -05:00
Kevin Newton 10bc0bd4ab [ruby/prism] Remove warnings check from parse_success? method
https://github.com/ruby/prism/commit/e30a241fb3
2023-12-07 14:39:11 +00:00
Matt Valentine-House 8e86a4347e [PRISM] Ensure should set correct end_label 2023-12-07 09:38:24 -05:00
Matt Valentine-House c4b9695350 [PRISM] Rescue should set correct end_label
In order for a break inside the rescue to have the correct jump target
2023-12-07 09:38:24 -05:00
yui-knk 071df40495 Lrama v0.5.12 2023-12-07 21:07:38 +09:00
Yusuke Endoh 30a1ccbc5c NEWS: Move "interruptible name resolution" to "Stdlib updates" section 2023-12-07 19:50:55 +09:00