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

72335 Коммитов

Автор SHA1 Сообщение Дата
git ab10f111c3 * 2022-06-15 [ci skip] 2022-06-15 01:06:06 +09:00
Alan Wu 9357e310fb [ruby/psych] Fix libyaml download failure rescue under miniruby
I tried to build Ruby on a system without libyaml today and realized
that my attempt from <https://github.com/ruby/psych/pull/557> doesn't
fix the error in <https://github.com/ruby/psych/issues/552>. I still got
the same `LoadError` from `digest` which stopped the build.

Since `LoadError` is not a `StandardError`, a plain `rescue` doesn't catch
it. Catch `LoadError` explicitly instead and reduce the scope of the
`begin` block.

I tested this change in a Ruby build on macOS without libyaml installed
and confirmed that `make` continues with a warning instead of aborting:

    *** Following extensions are not compiled:
    psych:
            Could not be configured. It will not be installed.
            ...

This should address <https://bugs.ruby-lang.org/issues/18790>.

https://github.com/ruby/psych/commit/251289ba83
2022-06-15 01:05:51 +09:00
Alan Wu 9f09397bfe
YJIT: On-demand executable memory allocation; faster boot (#5944)
This commit makes YJIT allocate memory for generated code gradually as
needed. Previously, YJIT allocates all the memory it needs on boot in
one go, leading to higher than necessary resident set size (RSS) and
time spent on boot initializing the memory with a large memset().

Users should no longer need to search for a magic number to pass to
`--yjit-exec-mem` since physical memory consumption should now more
accurately reflect the requirement of the workload.

YJIT now reserves a range of addresses on boot. This region start out
with no access permission at all so buggy attempts to jump to the region
crashes like before this change. To get this hardening at finer
granularity than the page size, we fill each page with trapping
instructions when we first allocate physical memory for the page.

Most of the time applications don't need 256 MiB of executable code, so
allocating on-demand ends up doing less total work than before. Case in
point, a simple `ruby --yjit-call-threshold=1 -eitself` takes about
half as long after this change. In terms of memory consumption, here is
a table to give a rough summary of the impact:

    | Peak RSS in MiB | -eitself example | railsbench once |
    | :-------------: | ---------------: | --------------: |
    |     before      |              265 |             377 |
    |      after      |               11 |             143 |
    |     no YJIT     |               10 |             101 |

A new module is introduced to handle allocation bookkeeping.
`CodePtr` is moved into the module since it has a close relationship
with the new `VirtualMemory` struct. This new interface has a slightly
smaller surface than before in that marking a region as writable is no
longer a public operation.
2022-06-14 10:23:13 -04:00
Burdette Lamar 9b9cc8ad34 [ruby/fileutils] [DOC] More on paths and lists (https://github.com/ruby/fileutils/pull/86)
* More on paths and lists

https://github.com/ruby/fileutils/commit/c3d92d34f4
2022-06-14 22:52:22 +09:00
Nobuyoshi Nakada 1a70973f75 ripper: Check if anonymous parameters defined [Bug #18828] 2022-06-14 20:41:41 +09:00
Nobuyoshi Nakada 048f14221c
Add placeholder to let braces match 2022-06-14 10:21:55 +09:00
Matt Valentine-House 56cc3e99b6 Move String RVALUES between pools
And re-embed any strings that can now fit inside the slot they've been
moved to
2022-06-13 10:11:27 -07:00
Takashi Kokubun f8502a2699
Drop MinGW support of MJIT (#6012)
[Feature #18824]
2022-06-13 09:28:28 -07:00
git c3ee80ff46 * 2022-06-14 [ci skip] 2022-06-14 00:39:59 +09:00
Burdette Lamar 9a381c240c [ruby/fileutils] [DOC] Clarify path arguments (https://github.com/ruby/fileutils/pull/85)
https://github.com/ruby/fileutils/commit/5f9ef9ddc8
2022-06-14 00:39:44 +09:00
Burdette Lamar 753da6deca [ruby/fileutils] [DOC] Enhanced Rdoc (https://github.com/ruby/fileutils/pull/84)
Treats:

    ::chown_R
    ::touch
    ::commands
    ::options
    ::have_option?
    ::options_of
    ::collect_method

https://github.com/ruby/fileutils/commit/5df0324f52
2022-06-13 21:11:45 +09:00
st0012 b1397e96da [ruby/reline] Revert "Merge pull request #441 from nevans/workaround-linker-script-so"
This reverts commit https://github.com/ruby/reline/commit/4ccf128ffa18, reversing
changes made to https://github.com/ruby/reline/commit/a2651419e9a0.

https://github.com/ruby/reline/commit/51053138a4
2022-06-13 19:33:15 +09:00
Jun Aruga a80f5c5365 Enable "make annocheck" on platforms other than Linux.
The annocheck supports ELF format binaries compiled for any OS and for any
architecture. It can work in not only Linux but also FreeBSD and Solaris.
It is designed to be independent of the host OS and the architecture.

Even in Mac, as the binaries are Mach-O foramt, the annocheck fails correctly
with the message.

e.g. Test binaries compiled for Mac OSX 10.13.6 (target_os: darwin17) in Fedora 35.

```
$ cat /etc/fedora-release
Fedora release 35 (Thirty Five)

$ file ruby
ruby: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|PIE>

$ annocheck ruby
annocheck: Version 10.66.
annocheck: Warning: ruby: is not an ELF format file.
```

See <https://sourceware.org/bugzilla/show_bug.cgi?id=29173> for details.
2022-06-13 12:12:18 +02:00
Yusuke Endoh b2e58b02ae compile.c (add_adjust_info): Remove `insns_info_index > 0`
... because insns_info_index could not be zero here. Also it adds an
invariant check for that.

This change will prevent the following warning of GCC 12.1

http://rubyci.s3.amazonaws.com/arch/ruby-master/log/20220613T000004Z.log.html.gz
```
compile.c:2230:39: warning: array subscript 2147483647 is outside array bounds of ‘struct iseq_insn_info_entry[2147483647]’ [-Warray-bounds]
 2230 |         insns_info[insns_info_index-1].line_no != adjust->line_no) {
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
```
2022-06-13 15:22:32 +09:00
Yusuke Endoh 5060c9d852 cont.c: prevent a warning of GCC 12.1
... by assigning a dummy value to the allocated stack.

http://rubyci.s3.amazonaws.com/arch/ruby-master/log/20220613T000004Z.log.html.gz
```
cont.c: In function ‘cont_restore_0.constprop’:
cont.c:1489:28: warning: ‘*sp’ may be used uninitialized [-Wmaybe-uninitialized]
 1489 |                 space[0] = *sp;
      |                            ^~~
```

Also it adds some comments about the hack of dummy stack allocation.
2022-06-13 15:18:28 +09:00
Samuel Williams 425a46131a Handle case where write result is zero. 2022-06-13 16:12:18 +12:00
Nobuyoshi Nakada d9ccb6b372 [ruby/reline] Check the ambiguous char width only on tty
It sent the char to check even to non-tty, e.g., pipe.
This causes `unknown command: "\xE2\x96\xBDstart ` warnings on
ruby's parallel test on Windows, where non-standard FDs cannot be
passed to child processes.

https://github.com/ruby/reline/commit/0d373647fb
2022-06-13 12:17:04 +09:00
Yusuke Endoh abc828bc67 Prevent a "warning: `*' interpreted as argument prefix" 2022-06-13 10:38:51 +09:00
git 54be0e4fd3 * 2022-06-13 [ci skip] 2022-06-13 10:38:06 +09:00
Yusuke Endoh 670de71628 Prevent a warning: assigned but unused variable - out
http://rubyci.s3.amazonaws.com/ubuntu1804/ruby-master/log/20220613T003003Z.log.html.gz
```
/home/chkbuild/chkbuild/tmp/build/20220613T003003Z/ruby/test/ruby/test_yjit_exit_locations.rb:96: warning: assigned but unused variable - out
/home/chkbuild/chkbuild/tmp/build/20220613T003003Z/ruby/test/ruby/test_yjit_exit_locations.rb:96: warning: assigned but unused variable - err
/home/chkbuild/chkbuild/tmp/build/20220613T003003Z/ruby/test/ruby/test_yjit_exit_locations.rb:96: warning: assigned but unused variable - status
```
2022-06-13 10:37:26 +09:00
git ee7aca31f5 * 2022-06-12 [ci skip] 2022-06-12 02:02:35 +09:00
David Rodríguez d0bf31e6cf [rubygems/rubygems] Don't on gemspecs with invalid `require_paths`, just warn
These gemspecs already work most of the times. When they are installed
normally, the require_paths in the gemspec stub line becomes actually
correct, and the incorrect value in the real gemspec is ignored. It only
becomes an issue in standalone mode.

In Ruby 3.2, `Kernel#=~` has been removed, and that means that it
becomes harder for us to gracefully deal with this error in standalone
mode, because it now happens earlier due to calling `Array#=~` for this
invalid gemspec (since require_paths is incorrectly an array of arrays).

The easiest way to fix this is to actually make this just work instead
by automatically fixing the issue when reading the packaged gemspec.

https://github.com/rubygems/rubygems/commit/d3f2fe6d26
2022-06-12 02:02:20 +09:00
Takayoshi Nishida 28e27ee76e
Fix typo in yjit.c comments [ci skip] 2022-06-11 21:26:03 +09:00
David Rodríguez 7f9eb888a3 [rubygems/rubygems] Reuse package from the installer for extracting the specification
Previously we would instantiate two different packages and extract the
specification from the package twice for each gem installed. We can
reuse the installer for this so that we just need to do it once.

https://github.com/rubygems/rubygems/commit/e454f850b1
2022-06-11 18:43:28 +09:00
David Rodríguez 965c314e34 [rubygems/rubygems] Move security exception handling to the only place using it
https://github.com/rubygems/rubygems/commit/ba975b3b7f
2022-06-11 18:43:27 +09:00
David Rodríguez bf8dc36e40 [rubygems/rubygems] Swapping should not raise any errors
https://github.com/rubygems/rubygems/commit/600a9ac658
2022-06-11 18:43:27 +09:00
David Rodríguez 6292b36529 [rubygems/rubygems] Remove unclear comment
This is the explanation of why we do the swapping, not of why we
download the gem.

https://github.com/rubygems/rubygems/commit/1a25eb7e7b
2022-06-11 18:43:26 +09:00
David Rodríguez 52cc76d134 [rubygems/rubygems] `Gem::Specification.loaded_from` is already set by the installer
https://github.com/rubygems/rubygems/commit/796eebfdbf
2022-06-11 18:43:26 +09:00
David Rodríguez 22c97ab8ae [rubygems/rubygems] Refactor some more duplicated logic
https://github.com/rubygems/rubygems/commit/9bd389e1b6
2022-06-11 18:43:25 +09:00
David Rodríguez 95f5194b3c [rubygems/rubygems] Move `no_install` setting check to a more sensible place
It's only related to the `bundle cache` command, so it should be checked
there.

https://github.com/rubygems/rubygems/commit/cf749f8ffa
2022-06-11 18:43:25 +09:00
David Rodríguez 3f69774b76 [rubygems/rubygems] No need to redownload if package already there
https://github.com/rubygems/rubygems/commit/285ccbc07e
2022-06-11 18:43:24 +09:00
David Rodríguez a9077af75b [rubygems/rubygems] No need to overwrite path when there's a remote
https://github.com/rubygems/rubygems/commit/d86fb2c316
2022-06-11 18:43:24 +09:00
David Rodríguez 870e5a39d5 [rubygems/rubygems] Remove another unnecessary require
https://github.com/rubygems/rubygems/commit/04e6a5ae31
2022-06-11 18:43:24 +09:00
David Rodríguez 692fec4e72 [rubygems/rubygems] Simplify `Gem::Security::Exception` handling
These days all these errors are raised as `Gem::Security::Exception` so
there's no need to do any matching on the exception message.

https://github.com/rubygems/rubygems/commit/bd3403da57
2022-06-11 18:43:23 +09:00
David Rodríguez 572f3240fe [rubygems/rubygems] Remove unnecessary require
The `security_policies` method already requires it.

https://github.com/rubygems/rubygems/commit/d19b088f2f
2022-06-11 18:43:23 +09:00
David Rodríguez 4a75849680 [rubygems/rubygems] Remove unnecessary `spec.remote` guard
It's checked before calling the method already.

https://github.com/rubygems/rubygems/commit/4eb00e9586
2022-06-11 18:43:22 +09:00
David Rodríguez d5288c8aad [rubygems/rubygems] Refactor ambiguous gems check
https://github.com/rubygems/rubygems/commit/a00c79a4da
2022-06-11 18:43:22 +09:00
Jaeson Lauritzen 7e1788e180
fix typo in dir documentation (#6002) 2022-06-10 22:22:16 -07:00
John Hawthorn 52da90acee Make method id explicit in rb_exec_recursive_outer
Previously, because opt_aref and opt_aset don't push a frame, when they
would call rb_hash to determine the hash value of the key, the initial
level of recursion would incorrectly use the method id at the top of the
stack instead of "hash".

This commit replaces rb_exec_recursive_outer with
rb_exec_recursive_outer_mid, which takes an explicit method id, so that
we can make the hash calculation behave consistently.

rb_exec_recursive_outer was documented as being internal, so I believe
this should be okay to change.
2022-06-10 14:48:21 -07:00
John Hawthorn f4747958e5 Add mid argument to exec_recursive 2022-06-10 14:48:21 -07:00
Burdette Lamar 44b3daa0d7 [ruby/fileutils] Enhanced RDoc (https://github.com/ruby/fileutils/pull/83)
Treats ::chmod_R and ::chown.

https://github.com/ruby/fileutils/commit/df4ac84bef
2022-06-11 06:41:27 +09:00
Jemma Issroff fc484be5e5 Add assertion for embedded to embedded ivar copy 2022-06-10 13:47:42 -07:00
Noah Gibbs 9ed9cc9852
Add tests for a variety of string-subclass operations (#5999)
This way YJIT has to match CRuby for each of them.
Remove unused string_p() Rust function
2022-06-10 13:52:43 -04:00
git 46333f59d4 * 2022-06-11 [ci skip] 2022-06-11 01:29:47 +09:00
Noah Gibbs e777ac9161
Don't return a value from jit_guard_known_klass. We never return anything but true at this point and we don't usually check the returned value. (#6000) 2022-06-10 12:29:26 -04:00
Koichi Sasada 1e528e8cbe small fix on `setup_debug_log()`
* print `ruby_debug_log_mode` at first.
* show filters when `ruby_debug_log_mode` is not "disabled".
2022-06-10 23:56:49 +09:00
Eileen M. Uchitelle c54f4264c2
Remove duplicated rb_yjit_get_stats (#5997)
`rb_yjit_get_stats` is defined twice in yjit.c, it only needs to be
defined once.
2022-06-10 10:12:58 -04:00
Alan Wu e75cb61d46 Fix nested bmethod TracePoint and memory leak
df317151a5 removed the code to free
rb_hook_list_t, so repeated targeting of the same bmethod started
to leak the hook list. You can observe how the maximum memory use
scales with input size in the following script with `/usr/bin/time -v`.

```ruby
o = Object.new
o.define_singleton_method(:foo) {}
trace = TracePoint.new(:return) {}

bmethod = o.method(:foo)

ARGV.first.to_i.times { trace.enable(target:bmethod){} }
4.times {GC.start}
```

After this change the maximum doesn't grow as quickly.

To plug the leak, check whether the hook list is already allocated
when enabling the targeting TracePoint for the bmethod. This fix
also allows multiple TracePoints to target the same bmethod, similar
to other valid TracePoint targets.

Finally, free the rb_hook_list_t struct when freeing the method
definition it lives on. Freeing in the GC is a good way to avoid
lifetime problems similar to the one fixed in df31715.

[Bug #18031]
2022-06-10 10:10:27 +09:00
Takashi Kokubun cedc36ec57
Remove a leftover require
I thought about using it in 2931957d6f
once and then ended up not using it.
2022-06-09 16:17:26 -07:00
Eileen M. Uchitelle e69e47f8d6
Fix exit locations test (#5995)
I originally added the check for
RubyVM::YJIT.trace_exit_locations_enabled? to fix errors when these
tests run without the stats feature enabled. However I forgot that this
will never be true when this test is booting, so nothing was running
when the stats feature is turned on.

Instead I've decided to make a new hash in the dump file and check if
exit locations are enabled there. If they aren't enabled we return early
to avoid checking for keys that won't exit in the dumped exit locations.
I chose to add this additional enabled check because empty exit
locations might not indicate that stats isn't enabled, it could mean the
feature is entirely broken. I do want these tests to fail if stats are
on and nothing was collected.

Followup to #5970
2022-06-09 17:59:41 -04:00