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

702 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada 33100797c4
Remove redundant parentheses [ci skip] 2022-07-01 09:37:00 +09:00
Nobuyoshi Nakada f4d70e1cd8
Make `FEATURE_SET_P` macro to include `FEATURE_BIT` 2022-06-30 16:51:39 +09:00
Nobuyoshi Nakada bd8ed1f904
Do not call `exit()` directly 2022-06-29 20:10:29 +09:00
Alan Wu eb1a84a9c3 When YJIT is not built, hide options and use MJIT for --jit
YJIT is now a build-time opt-in so on platforms that YJIT could support
it could still be unavailable due to user discretion. Use MJIT for --jit
and don't display YJIT related command line options in --help when YJIT
is not included in the build.
2022-06-23 18:12:25 -04:00
Chris Seaton 31b2cd38c5 Include JIT information in crash reports
Since enabling YJIT or MJIT drastically changes what could go wrong at
runtime, it's good to be front and center about whether they are enabled
when dumping a crash report. Previously, `RUBY_DESCRIPTION` and the
description printed when crashing can be different when a JIT is on.

Introduce a new internal data global, `rb_dynamic_description`, and set
it to be the same as `RUBY_DESCRIPTION` during initialization; use it
when crashing.

 * version.c: Init_ruby_description(): Initialize and use
       `rb_dynamic_description`.
 * error.c: Change crash reports to use `rb_dynamic_description`.
 * ruby.c: Call `Init_ruby_description()` earlier. Slightly more work
       for when we exit right after printing the description but that
       was deemed acceptable.
 * include/ruby/version.h: Talk about how JIT info is not in
      `ruby_description`.
 * test/-ext-/bug_reporter/test_bug_reporter.rb: Remove handling for
       crash description being different from `RUBY_DESCRIPTION`.
 * test/ruby/test_rubyoptions.rb: ditto

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Co-authored-by: Alan Wu <alanwu@ruby-lang.org>
2022-06-20 17:18:29 -04:00
Alan Wu f90549cd38 Rust YJIT
In December 2021, we opened an [issue] to solicit feedback regarding the
porting of the YJIT codebase from C99 to Rust. There were some
reservations, but this project was given the go ahead by Ruby core
developers and Matz. Since then, we have successfully completed the port
of YJIT to Rust.

The new Rust version of YJIT has reached parity with the C version, in
that it passes all the CRuby tests, is able to run all of the YJIT
benchmarks, and performs similarly to the C version (because it works
the same way and largely generates the same machine code). We've even
incorporated some design improvements, such as a more fine-grained
constant invalidation mechanism which we expect will make a big
difference in Ruby on Rails applications.

Because we want to be careful, YJIT is guarded behind a configure
option:

```shell
./configure --enable-yjit # Build YJIT in release mode
./configure --enable-yjit=dev # Build YJIT in dev/debug mode
```

By default, YJIT does not get compiled and cargo/rustc is not required.
If YJIT is built in dev mode, then `cargo` is used to fetch development
dependencies, but when building in release, `cargo` is not required,
only `rustc`. At the moment YJIT requires Rust 1.60.0 or newer.

The YJIT command-line options remain mostly unchanged, and more details
about the build process are documented in `doc/yjit/yjit.md`.

The CI tests have been updated and do not take any more resources than
before.

The development history of the Rust port is available at the following
commit for interested parties:
1fd9573d8b

Our hope is that Rust YJIT will be compiled and included as a part of
system packages and compiled binaries of the Ruby 3.2 release. We do not
anticipate any major problems as Rust is well supported on every
platform which YJIT supports, but to make sure that this process works
smoothly, we would like to reach out to those who take care of building
systems packages before the 3.2 release is shipped and resolve any
issues that may come up.

[issue]: https://bugs.ruby-lang.org/issues/18481

Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
Co-authored-by: Noah Gibbs <the.codefolio.guy@gmail.com>
Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2022-04-27 11:00:22 -04:00
Yuta Saito be1382b498 ruby.c: initialize extra optional extensions linked statically
Add a hook point to initialize extra extension libraries. The default
hook function is replaced when linking a strong `Init_extra_exts`
symbol. A builder can insert an object file that defines Init_extra_exts
by XLDFLAGS.
2022-01-19 11:19:06 +09:00
Peter Zhu ffda21b7ba [Feature #18491] Drop support for HP-UX
IA64 support was dropped in ticket #15894, so we can drop support for
HP-UX.
2022-01-18 09:52:15 -05:00
Nobuyoshi Nakada 2dff82bfca
`O_NONBLOCK` is not always a preprocessor constant on all platforms 2022-01-16 23:47:10 +09:00
Nobuyoshi Nakada c1bcfeec38
Transfer the responsibility for MJIT options to mjit.c 2022-01-15 18:57:33 +09:00
Nobuyoshi Nakada d853a7886e Define the default JIT feature bit 2022-01-15 18:55:47 +09:00
Nobuyoshi Nakada 26b4aa853f
Show JIT options only when supported 2022-01-12 17:51:14 +09:00
Kazuhiro NISHIYAMA b5310b8975
Fix compile errors
```
compiling ../ruby.c
../ruby.c:1547:17: error: implicit declaration of function 'setup_yjit_options' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                setup_yjit_options(s, &opt->yjit);
                ^
../ruby.c:1547:17: note: did you mean 'setup_mjit_options'?
../ruby.c:1122:1: note: 'setup_mjit_options' declared here
setup_mjit_options(const char *s, struct mjit_options *mjit_opt)
^
../ruby.c:1547:45: error: no member named 'yjit' in 'struct ruby_cmdline_options'; did you mean 'mjit'?
                setup_yjit_options(s, &opt->yjit);
                                            ^~~~
                                            mjit
../ruby.c:192:25: note: 'mjit' declared here
    struct mjit_options mjit;
                        ^
../ruby.c:1924:28: error: no member named 'yjit' in 'struct ruby_cmdline_options'; did you mean 'mjit'?
        rb_yjit_init(&opt->yjit);
                           ^~~~
                           mjit
../ruby.c:192:25: note: 'mjit' declared here
    struct mjit_options mjit;
                        ^
3 errors generated.
```
2022-01-11 17:33:01 +09:00
Nobuyoshi Nakada 3d675c72b9
Use `setup_yjit_options` only when supported 2022-01-11 17:26:21 +09:00
Nobuyoshi Nakada 1c9b5d452e
Reject command line option ending with `-` 2022-01-11 11:49:34 +09:00
Nobuyoshi Nakada 8b585f7460
Define YJIT options only when supported 2022-01-11 10:12:40 +09:00
Kazuhiro NISHIYAMA c764e368bd
Fix default --jit-max-cache in `ruby --help`
changed at 028f1887c2
2022-01-10 20:17:05 +09:00
Kazuhiro NISHIYAMA a7faca51ac
Add `=num` to yjit options
`--yjit-call-threshold` and `--yjit-max-versions` need an argument.
2022-01-09 12:39:34 +09:00
Peter Zhu 44379805b0 Fix crash on bootup when RGENGC_CHECK_MODE=2 with GC stress
We need to unshare the array loaded_features because the shared root
could be old gen (while loaded_features is young) which causes a WB
miss.
2022-01-04 14:46:20 -05:00
Takashi Kokubun 11b8aaa26a
Rename --jit to --mjit (#5248)
* Rename --jit to --mjit

[Feature #18349]

* Fix a few more --jit references

* Fix MJIT Actions

* More s/jit/mjit/ and re-introduce --disable-jit

* Update NEWS.md

* Fix test_bug_reporter_add
2021-12-13 16:08:01 -08:00
Yusuke Endoh a692a1597f ruby.c: Fix typo 2021-12-13 10:29:08 +09:00
Yusuke Endoh 8613c0c675 Introduce an option "--dump=insns_without_opt" for debugging purposes 2021-12-13 10:29:08 +09:00
Aaron Patterson 3b2b28d035
Revert "Force disable yjit on OpenBSD"
This reverts commit 119626da94.
2021-12-01 12:46:30 -08:00
Maxime Chevalier-Boisvert cdebf57ec6
Add --yjit-no-type-prop so we can test YJIT without type propagation (#5135)
* Add --yjit-no-type-prop so we can test YJIT without type propagation

* Fix typo in command line option

* Leave just two test workflows enable for YJIT
2021-11-18 10:44:31 -05:00
Peter Zhu a5b6598192 [Feature #18239] Implement VWA for strings
This commit adds support for embedded strings with variable capacity and
uses Variable Width Allocation to allocate strings.
2021-10-25 13:26:23 -04:00
Takashi Kokubun 6469038ae2
Fix TestRubyOptions#test_enable for -DMJIT_FORCE_ENABLE
--enable=all didn't work when cppflags=-DMJIT_FORCE_ENABLE was given.
2021-10-21 20:41:14 -07:00
Jeremy Evans 119626da94 Force disable yjit on OpenBSD
TestRubyOptions#test_enable was broken on OpenBSD after the yjit
merge. --yjit (and --enable-all, which enables --yjit) fails on
OpenBSD because yjit uses an insecure mmap call (both writable
and executable), in alloc_exec_mem, which OpenBSD does not allow.

This can probably be reverted if yjit switches to a more secure
mmap design (writable xor executable).  This would involve
initially calling mmap with PROT_READ | PROT_WRITE, and after writing
of executable code has finished, using mprotect to switch to
PROT_READ | PROT_EXEC. I believe Firefox uses this approach for
their Javascript engine since Firefox 46.
2021-10-21 08:26:02 -07:00
Alan Wu 40608d0b7b Fix indentation in ruby.c 2021-10-20 18:19:43 -04:00
Alan Wu 95e337f815 Warn when trying to use YJIT in --disable-jit-support builds 2021-10-20 18:19:43 -04:00
Alan Wu ff863f3818 Show --yjit in help message 2021-10-20 18:19:43 -04:00
Alan Wu 11096da6cc Improve YJIT command line option parsing
Previously, options such as "--yjit123" would enable YJIT. Additionally,
the error message for argument parsing mentioned "--jit-..." instead of
"--yjit-...".
2021-10-20 18:19:43 -04:00
Alan Wu 1f25bba7b7 YJIT_STATS instead of RUBY_DEBUG for --yjit-stats in help printout 2021-10-20 18:19:42 -04:00
Alan Wu d4fae3e390 Say YJIT is disabled by default in ruby --help 2021-10-20 18:19:42 -04:00
Alan Wu d355bf17ba Style fix in ruby.c 2021-10-20 18:19:42 -04:00
Noah Gibbs 21e58acef3 Don't enable YJIT by default. More tests on both Ubuntu and MacOS.
Add RUBY_YJIT_ENABLE env var and YJIT_FORCE_ENABLE compile-time constant.
Rename YJIT_STATS to RUBY_YJIT_STATS.
2021-10-20 18:19:42 -04:00
Noah Gibbs f021b35273 Reduce line length for YJIT option descriptions 2021-10-20 18:19:42 -04:00
Noah Gibbs fab469b678 Document YJIT options in --help 2021-10-20 18:19:42 -04:00
Aaron Patterson afc5db43ca is this right? 2021-10-20 18:19:40 -04:00
Aaron Patterson b78c50d800 Don't check MJIT if it's not enabled 2021-10-20 18:19:40 -04:00
Aaron Patterson 9d5beb6fde Disable YJIT by default if MJIT_FORCE_ENABLE is on
Compile time flag seems pretty forceful, so let MJIT turn on by default
if it is used.
2021-10-20 18:19:40 -04:00
Aaron Patterson ea453acf59 disable MJIT when --enable-all is set 2021-10-20 18:19:40 -04:00
Maxime Chevalier-Boisvert a1d42c37f4 Update ruby.c 2021-10-20 18:19:40 -04:00
Aaron Patterson 234ab816ba Exit if YJIT and MJIT are both enabled
YJIT and MJIT can't be running in the same process otherwise they'll
clobber each other.  We should show an error and exit if they're both
enabled.
2021-10-20 18:19:40 -04:00
Maxime Chevalier-Boisvert 7030cae969 Try running with more YJIT options in CI to surface more bugs 2021-10-20 18:19:36 -04:00
Maxime Chevalier-Boisvert b415ceb92e Increase default YJIT call threshold to 10. Add exec mem size arg. (#52) 2021-10-20 18:19:35 -04:00
Maxime Chevalier-Boisvert 96f4f918b0 Implement greedy versioning. Refactor versioning logic. (#10)
* Implement eager versioning. Refactor versioning logic.

* Add --version-limit and --greedy-versioning command-line args
2021-10-20 18:19:34 -04:00
Jose Narvaez 4e2eb7695e Yet Another Ruby JIT!
Renaming uJIT to YJIT. AKA s/ujit/yjit/g.
2021-10-20 18:19:31 -04:00
Maxime Chevalier-Boisvert 0710bec01e Implement --ujit-call-threshold 2021-10-20 18:19:30 -04:00
Maxime Chevalier-Boisvert a14015e9b5 Report unknown --ujit-* options 2021-10-20 18:19:28 -04:00
Alan Wu b7f93e81df Implement --ujit-stats and instructoin counting
VM and ujit instruction counting in debug builds.

shopify/ruby#19
2021-10-20 18:19:27 -04:00