86825 Commits

Author SHA1 Message Date
Hiroshi SHIBATA
5e6f04abc8 [ruby/net-http] Fix wrong hostname with test_max_version test
https://github.com/ruby/net-http/commit/f00d198433
2024-07-10 23:06:07 +00:00
Hiroshi SHIBATA
c7eb9ac6f9 [ruby/net-http] Rewrite WEBrick server with TCPServer and OpenSSL::SSL::SSLServer
https://github.com/ruby/net-http/commit/b01bcf6d7f
2024-07-10 23:06:06 +00:00
Jeremy Evans
0ee3960685 Eliminate array allocations for single splat followed by mutable keywords
For calls such as:

  m(*ary, a: 2, **h)
  m(*ary, **h, **h, **h)

Where m does not take a positional argument splat, there was previously
an array allocation (splatarray true) to dup ary, even though it was not
necessary to do so.  This is because the elimination of the array allocation
(splatarray false) was performed in the optimizer, and the optimizer didn't
handle this case, because the instructions for the keywords can be of
arbitrary length.

Move part of the optimization from the optimizer to the compiler,
detecting parse trees of the form:

  ARGS_PUSH:
    head: SPLAT
    tail: HASH (without brace)

And using splatarray false instead of splatarray true for them.

Unfortunately, moving part of the optimization to the compiler broke
the hash allocation elimination optimization for calls of the
form:

  m(*ary, a: 2)

That's because the compiler had already set splatarray false,
and the optimizer code was looking for splatarray true.

Split the array allocation elimination and hash allocation
elimination in the optimizer so that the hash allocation
elimination will still apply if the compiler performs the
splatarray false optimization.
2024-07-10 14:45:38 -07:00
Maxime Chevalier-Boisvert
48e7112baa
YJIT: increase context cache size to 1024 (#10983)
* YJIT: increase context cache size to 1024

The other day I ran into a mysterious bug while increasing the
cache size to 1024. I was not able to reproduce this locally.
Opening this PR for testing/debugging.

* Add extra debug assertions

* Add more comments to context code

* Update yjit/src/core.rs

Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>

* Update yjit/src/core.rs

* Comment out potentially problematic assertion

* Revert cache size to 512 so we can merge other changes

---------

Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2024-07-10 19:45:23 +00:00
Peter Zhu
52a0dfd4bf Revert all changes to dln.c, dmydln.c, dln.h for the shared GC 2024-07-10 14:28:10 -04:00
Peter Zhu
64988e66d7 Allow miniruby to load shared GC
Since dln.c is replaced with dmydln.c for miniruby, we cannot load shared
GC for miniruby. This means that many tests do not have the shared GC
loaded and many tests fail because of the warning that emits in miniruby.

This commit changes shared GC to directly use dlopen for loading the
shared GC.
2024-07-10 14:28:10 -04:00
Peter Zhu
623eecce99 Use absolute path for shared_gc_dir 2024-07-10 09:21:12 -04:00
David Rodríguez
133fec4ce9 [rubygems/rubygems] Fix another strange error when running bundle add in frozen mode
If there's a lockfile, but it's out of sync with the Gemfile because a
dependency has been deleted, and frozen mode is set, Bundler will print
the following strange error:

```
$ bundle add rake
, but the lockfile can't be updated because frozen mode is set

You have deleted from the Gemfile:
* rake (~> 13.2)

Run `bundle install` elsewhere and add the updated Gemfile to version control.
```

This commit changes the error to:

```
Some dependencies were deleted from your gemfile, but the lockfile can't be updated because frozen mode is set

You have deleted from the Gemfile:
* rake (~> 13.2)

Run `bundle install` elsewhere and add the updated Gemfile to version control.
```

https://github.com/rubygems/rubygems/commit/452da4048d
2024-07-10 08:04:07 +00:00
David Rodríguez
7e612b7414 [rubygems/rubygems] Fix strange error when running bundle add with frozen mode set
If Gemfile is empty and there's no lockfile (situation after `bundle init`), and
`frozen` is configured, running `bundle add` will result in an strange
error, like this:

```
$ bundle add rake
, but the lockfile can't be updated because frozen mode is set

You have deleted from the Gemfile:
* rake (~> 13.2)

Run `bundle install` elsewhere and add the updated Gemfile to version control.
```

This commit fixes the problem to instead print

https://github.com/rubygems/rubygems/commit/152331a9dc
2024-07-10 08:04:07 +00:00
Yusuke Endoh
182822683f Use rb_block_call2 for some Enumerable methods
Enumerable#all?, #any?, #one?, and #none? do not use yielded arguments
as an Array. So they can use rb_block_call2 to omit array allocatoin.

Enumerable#find does not have to immediately accept yielded arguments as
an Array. It can delay array allocation until the predicate block
returns truthy.

(TODO: Enumerable#count and #find_all seem to be optimizable as well.)
2024-07-10 13:00:47 +09:00
Yusuke Endoh
114e32b357 Add rb_block_call2, a flexible variant of rb_block_call
This function accepts flags:

RB_NO_KEYWORDS, RB_PASS_KEYWORDS, RB_PASS_CALLED_KEYWORDS:
Works as the same as rb_block_call_kw.

RB_BLOCK_NO_USE_PACKED_ARGS:
The given block ("bl_proc") does not use "yielded_arg" of rb_block_call_func_t.
Instead, the block accesses the yielded arguments via "argc" and "argv".
This flag allows the called method to yield arguments without allocating an Array.
2024-07-10 13:00:47 +09:00
卜部昌平
77b12a8aaf GC_DEBUG is always defined
`#ifdef` is inadequate.
2024-07-10 12:15:35 +09:00
卜部昌平
c49eda91bf rb_source_location_cstr is banned in this file
Raison d'etre du gc_impl.c is to purge any internal constructs and rely
solely on our public APIs. rb_source_location_cstr is not public.
2024-07-10 12:15:35 +09:00
卜部昌平
1f15149e98 rb_gc_obj_slot_size is banned in this file
Raison d'etre du gc_impl.c is to purge any internal constructs and rely
solely on our public APIs. rb_gc_obj_slot_size is not public.
2024-07-10 12:15:35 +09:00
dependabot[bot]
ef2afe82eb Bump ruby/setup-ruby from 1.185.0 to 1.186.0
Bumps [ruby/setup-ruby](https://github.com/ruby/setup-ruby) from 1.185.0 to 1.186.0.
- [Release notes](https://github.com/ruby/setup-ruby/releases)
- [Changelog](https://github.com/ruby/setup-ruby/blob/master/release.rb)
- [Commits](3a77c29278...2a9a743e19)

---
updated-dependencies:
- dependency-name: ruby/setup-ruby
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-10 11:57:21 +09:00
eileencodes
6f6aff56b1 Don't shrink array in ary_make_shared
This change adds back the assertions removed in #11092 and removes the
call to `ary_shrink_capa` from `ary_make_shared` when the array is
frozen.
2024-07-09 10:22:29 -07:00
Peter Zhu
c1ff8d519f Fix grammar of ruby_shared_gc.m4 2024-07-09 13:14:28 -04:00
David Rodríguez
140d8318db [rubygems/rubygems] Fix generic platform gems getting incorrectly removed when locked for a specific platform
If they are already in the lockfile as the most specific variant for a
platform, we shouldn't change that unless explicitly unlocking.

https://github.com/rubygems/rubygems/commit/a901660498
2024-07-09 16:34:09 +00:00
David Rodríguez
e6c7a309d0 [rubygems/rubygems] Refactor selecting specs from a SpecSet
https://github.com/rubygems/rubygems/commit/bcbbff5149
2024-07-09 16:34:09 +00:00
David Rodríguez
dd05191bc3 [rubygems/rubygems] Resolve all platforms directly
Instead of having to do a complete pass after resolve.

To do this, we add to the ruby group all the platform specs with the
same dependencies as the ruby specs.

https://github.com/rubygems/rubygems/commit/e50415f2a6
2024-07-09 16:34:08 +00:00
David Rodríguez
00acc70348 [rubygems/rubygems] Don't memoize sorted_spec_names
It's just for debugging and a simple method, so no need.

https://github.com/rubygems/rubygems/commit/3230425a9a
2024-07-09 16:34:08 +00:00
David Rodríguez
086cde1651 [rubygems/rubygems] Instantiate Resolver::SpecGroup with explicit priority
https://github.com/rubygems/rubygems/commit/e2c1bc1b6c
2024-07-09 16:34:07 +00:00
David Rodríguez
5fdfdc30f1 [rubygems/rubygems] Let resolver consider unique specs from the beginning
It results in more consistent error messages.

https://github.com/rubygems/rubygems/commit/a4b34361cc
2024-07-09 16:34:07 +00:00
David Rodríguez
a333e867aa [rubygems/rubygems] Fix spec to also pass outside of Linux
https://github.com/rubygems/rubygems/commit/fc8c853345
2024-07-09 16:34:06 +00:00
David Rodríguez
1d97c46b35 [rubygems/rubygems] Minor Bundler spec improvements
While working on something else I noticed:

* Usage of uppercased "RUBY" and "JAVA" as platforms, when those don't
  really exist.
* Usage of some test gems with "1.0" as gemspec version and "1.0.0" as
  actual version.

This commit fixes both inconsistencies to make things more expectable.

https://github.com/rubygems/rubygems/commit/e3ec32e247
2024-07-09 14:43:18 +00:00
dependabot[bot]
ac0e0f0c76 [rubygems/rubygems] Bump rb-sys
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.97 to 0.9.98.
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.97...v0.9.98)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

https://github.com/rubygems/rubygems/commit/d2846130bc
2024-07-09 14:42:40 +00:00
Burdette Lamar
30b9912bb7
[DOC] Doc for Float#ceil (#11125) 2024-07-09 09:43:07 -04:00
Peter Zhu
ab3fa8dece [DOC] Use backticks instead of HTML tags 2024-07-09 08:55:58 -04:00
Peter Zhu
5de6d0b35f [DOC] Fix granularity calculation
The granularity is calculated as `10 ** ndigits.abs` rather than
`ndigits.abs * 10`. For example, if `ndigits` is `-2`, it should be
`10 ** 2 == 100` rather than `2 * 10 == 20`.
2024-07-09 08:55:58 -04:00
David Rodríguez
ad6b2e8985 [rubygems/rubygems] Test using latest rubies
https://github.com/rubygems/rubygems/commit/6d6646b8bc
2024-07-09 11:26:10 +00:00
Hiroshi SHIBATA
f9004fc8aa [rubygems/rubygems] Suppress SSLError warning because it's only for debugging.
http://ci.rvm.jp/logfiles/brlog.trunk.20240709-010435#L1554

https://github.com/rubygems/rubygems/commit/a1a46f413b
2024-07-09 09:09:14 +00:00
Hiroshi SHIBATA
e09df57427 [ruby/open-uri] Try Windows tests again
https://github.com/ruby/open-uri/commit/50f265ba29
2024-07-09 07:27:48 +00:00
Hiroshi SHIBATA
5d82abdfc8 Removed duplicate server thread 2024-07-09 16:21:55 +09:00
Hiroshi SHIBATA
e62ac3aac7 Reapply "Reverts related commits with https://github.com/ruby/open-uri/pull/37"
This reverts commit 02c4f0c89db3689c5272f00c548ca3008120459b.
2024-07-09 16:21:55 +09:00
Nobuyoshi Nakada
690b56440b
Use File.write instead of Kernel#open 2024-07-09 13:01:44 +09:00
Koichi Sasada
e500222de1 fix last commit
`th` is gone.
2024-07-09 06:43:28 +09:00
Koichi Sasada
ffc69eec0a struct rb_thread_sched_waiting
Introduce `struct rb_thread_sched_waiting` and `timer_th.waiting`
can contain other than `rb_thread_t`.
2024-07-09 05:57:03 +09:00
Peter Zhu
a9f6bd028a Add make target shared-gc
Allows building shared GC using `make shared-gc SHARED_GC=gc_impl`
2024-07-08 16:47:25 -04:00
Alan Wu
3be9ce3cf6
YJIT: dump-disasm: Print comments and bytes in release builds
This change implements a fallback mode for the `--yjit-dump-disasm`
development command-line option to make it usable in release builds.
Previously, using the option with release builds of YJIT yielded only
a warning asking the user to build with `--enable-yjit=dev`.

While builds that use the `disasm` feature still give the best output,
just having the comments is useful enough for many kinds of debugging.
Having it usable in release builds is nice for new hackers, too, since
this allows for tinkering without having to learn how to build YJIT in
development mode.

Sample output on A64:

```
  # regenerate_branch
  # Insn: 0001 opt_send_without_block (stack_size: 1)
  # guard known object with singleton class
  0x11f7e0034: 4b 00 00 58 03 00 00 14 08 ce 9c 04 01 00 00
  0x11f7e0043: 00 3f 00 0b eb 81 06 01 54 1f 20 03 d5
  # RUBY_VM_CHECK_INTS(ec)
  0x11f7e0050: 8b 02 42 b8 cb 07 01 35
  # stack overflow check
  0x11f7e0058: ab 62 02 91 7f 02 0b eb 69 07 01 54
  # save PC to CFP
  0x11f7e0064: 0b 3b 9a d2 2b 2f a0 f2 0b 00 cc f2 6b 02 00
  0x11f7e0073: f8 ab 82 00 91
```

To ensure this feature doesn't incur too much cost when running without
the `--yjit-dump-disasm` option, I checked that there is no significant
impact to compile time and memory usage with the `compile_time_ns` and
`yjit_alloc_size` entry in `RubyVM::YJIT.runtime_stats`. For each
sample, I ran 3 iterations of the `lobsters` YJIT benchmark. The
statistics summary and done with the `summary` function in R.

Compile time, sample size of 60, lower is better:

```
       Before              After
 Min.   :2.054e+09   Min.   :2.028e+09
 1st Qu.:2.069e+09   1st Qu.:2.044e+09
 Median :2.081e+09   Median :2.060e+09
 Mean   :2.089e+09   Mean   :2.066e+09
 3rd Qu.:2.109e+09   3rd Qu.:2.085e+09
 Max.   :2.146e+09   Max.   :2.144e+09
```

Allocation size, sample size of 20, lower is better:

```
       Before             After
 Min.   :21804742   Min.   :21794082
 1st Qu.:21826682   1st Qu.:21816282
 Median :21844042   Median :21826814
 Mean   :21960664   Mean   :22026291
 3rd Qu.:21861228   3rd Qu.:22040439
 Max.   :22587426   Max.   :22930614
```

The `yjit_alloc_size` samples are noisy, but since the average increased
by only 0.3%, and the median is lower, I feel safe saying that there is
no significant change.
2024-07-08 20:02:30 +00:00
BurdetteLamar
a57b4340d0 Doc fixes 2024-07-08 14:35:29 -04:00
David Rodríguez
ae6a2d0641 [rubygems/rubygems] Fix wrong version is comment
This RubyGems feature is being released as 3.5.15, so we can stop
monkeypatching RubyGems once support for the previous version is
dropped.

https://github.com/rubygems/rubygems/commit/36f146840d
2024-07-08 17:06:26 +00:00
David Rodríguez
39826f384a [rubygems/rubygems] Backport binstub race condition fix to Bundler
https://github.com/rubygems/rubygems/commit/b07e46820d
2024-07-08 17:06:25 +00:00
Peter Zhu
0c61e21277 Rename rb_gc_impl_verify_internal_consistency to gc_verify_internal_consistency
It's an internal function so we can drop the rb_gc_impl
2024-07-08 09:08:22 -04:00
Peter Zhu
e148db70ea Make rb_gc_impl_verify_internal_consistency static
The function is not used outside of this file.
2024-07-08 09:06:45 -04:00
Hiroshi SHIBATA
02c4f0c89d
Reverts related commits with https://github.com/ruby/open-uri/pull/37
It caused Timeout failure with RJIT and chkbuild

http://rubyci.s3.amazonaws.com/debian11/ruby-master/log/20240708T063006Z.fail.html.gz
https://github.com/ruby/ruby/actions/runs/9836594303/job/27152644853
2024-07-08 20:00:01 +09:00
Jean Boussier
9594db0cf2 Implement Hash.new(capacity:)
[Feature #19236]

When building a large hash, pre-allocating it with enough
capacity can save many re-hashes and significantly improve
performance.

```
/opt/rubies/3.3.0/bin/ruby --disable=gems -rrubygems -I./benchmark/lib ./benchmark/benchmark-driver/exe/benchmark-driver \
	            --executables="compare-ruby::../miniruby-master -I.ext/common --disable-gem" \
	            --executables="built-ruby::./miniruby --disable-gem" \
	            --output=markdown --output-compare -v $(find ./benchmark -maxdepth 1 -name 'hash_new' -o -name '*hash_new*.yml' -o -name '*hash_new*.rb' | sort)
compare-ruby: ruby 3.4.0dev (2024-03-25T11:48:11Z master f53209f023) +YJIT dev [arm64-darwin23]
last_commit=[ruby/irb] Cache RDoc::RI::Driver.new (https://github.com/ruby/irb/pull/911)
built-ruby: ruby 3.4.0dev (2024-03-25T15:29:40Z hash-new-rb 77652b08a2) +YJIT dev [arm64-darwin23]
warming up...

|                    |compare-ruby|built-ruby|
|:-------------------|-----------:|---------:|
|new                 |      7.614M|    5.976M|
|                    |       1.27x|         -|
|new_with_capa_1k    |     13.931k|   15.698k|
|                    |           -|     1.13x|
|new_with_capa_100k  |     124.746|   148.283|
|                    |           -|     1.19x|
```
2024-07-08 12:24:33 +02:00
Hiroshi SHIBATA
bfb8cad771
Expand RJIT timeout to 60min 2024-07-08 17:58:46 +09:00
Hiroshi SHIBATA
a5f4014738
Load net-http explicitly for SimpleHTTPProxyServer 2024-07-08 17:05:12 +09:00
Hiroshi SHIBATA
b903d9f09f [ruby/tempfile] typofix
https://github.com/ruby/tempfile/commit/82a74b017e
2024-07-08 06:18:57 +00:00
Hiroshi SHIBATA
4658d65242 Load socket explicitly for TCPServer 2024-07-08 15:15:46 +09:00