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

917 Коммитов

Автор SHA1 Сообщение Дата
Noah Gibbs (and/or Benchmark CI) ba88787087 Use bindgen to import CRuby constants for YARV instruction bytecodes 2022-05-26 13:06:47 -04:00
Jemma Issroff 80ad0e751f Remove unnecessary module flag, add module assertions to other module flags 2022-05-23 11:04:34 -07:00
Noah Gibbs 50bad7159a
Special-case jit_guard_known_class for strings. This can remove (#5920)
runtime guard-checks for String#to_s, making some blocks too
short to invalidate later. Add NOPs in those cases to reserve space.
2022-05-20 19:39:37 -04:00
Takashi Kokubun b8a268e293
YJIT: Add opt_succ (#5919) 2022-05-19 11:52:52 -04:00
Aaron Patterson ebaf56c013 YJIT: Implement getblockparam
This implements the getblockparam instruction.

There are two cases we need to handle depending on whether or not
VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM is set in the environment flag.

When the modified flag is unset, we need to call rb_vm_bh_to_procval to
get a proc from our passed block, save the proc in the environment, and
set the modified flag.

In the case that the modified flag is set we are able to just use the
existing proc in the environment.

One quirk of this is that we need to call jit_prepare_routine_call early
and ensure we update PC and SP regardless of the branch taken, so that
we have a consistent SP offset at the start of the next instruction.

We considered using a chain guard to generate these two paths
separately, but decided against it because it's very common to see both
and the modified case is basically a subset of the instructions in the
unmodified case.

This includes tests for both getblockparam and getblockparamproxy which
was previously missing a test.
2022-05-12 14:34:18 -07:00
Aaron Patterson f07a0e79a2
YJIT: Fix getting the EP with registers other than RAX (#5882)
Before this commit we were accidentally clobbering RAX.  Additionally,
since this function had RAX hardcoded then the function may not have
worked with registers other than RAX.

Co-authored-by: John Hawthorn <john@hawthorn.email>
2022-05-12 12:08:35 -07:00
Noah Gibbs e88ada4699
Ruby shovel operator (<<) speedup. (#5896)
For string concat, see if compile-time encoding of strings matches.
If so, use simple buffer string concat at runtime. Otherwise, use
encoding-checking string concat.
2022-05-11 11:20:21 -04:00
Maxime Chevalier-Boisvert 35e111fd3e
Fix bug identified by @noahgibbs. (#5876)
Turned out to be a one-character fix :)
2022-05-02 16:30:05 -04:00
Koichi ITO 8587bacc25
YJIT: Remove redundant `extern crate` (#5869)
Follow up https://github.com/ruby/ruby/commit/0514d81

Rust YJIT requires Rust 1.60.0 or later. So, `extern crate` looks unnecessary
because it can use the following Rust 2018 edition feature:
https://doc.rust-lang.org/stable/edition-guide/rust-2018/path-changes.html#no-more-extern-crate

It passes the following tests.

```console
% cd yjit
% cargo test --features asm_comments,disasm
(snip)

test result: ok. 56 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
```
2022-05-02 10:05:01 -04:00
Alan Wu 5c843a1a6e
YJIT: Enable default rustc lints (warnings) (#5864)
`rustc` performs in depth dead code analysis and issues warning
even for things like unused struct fields and unconstructed enum
variants. This was annoying for us during the port but hopefully
they are less of an issue now.

This patch enables all the unused warnings we disabled and address
all the warnings we previously ignored. Generally, the approach I've
taken is to use `cfg!` instead of using the `cfg` attribute and
to delete code where it makes sense. I've put `#[allow(unused)]`
on things we intentionally keep around for printf style debugging
and on items that are too annoying to keep warning-free in all
build configs.
2022-04-29 18:20:23 -04:00
Alan Wu fead7107ab YJIT: Adopt Clippy suggestions we like
This adopts most suggestions that rust-clippy is confident enough to
auto apply. The manual changes mostly fix manual if-lets and take
opportunities to use the `Default` trait on standard collections.

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
2022-04-29 15:03:45 -04:00
Dmitry Dygalo f8e4488e5e
YJIT: Do not create `CodeBlock.asm_comments` if the `asm_comments` feature is disabled (#5863) 2022-04-29 10:07:48 -04:00
Maxime Chevalier-Boisvert 0eb237d99c
YJIT: replace BLOCKID_NULL with Option<BlockId>, more idiomatic (#5858)
* YJIT: replace BLOCKID_NULL with Option<BlockId>, more idiomatic

* Update yjit/src/core.rs

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

* Update yjit/src/core.rs

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

Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2022-04-28 17:12:24 -04:00
Kazuhiro NISHIYAMA 7c141f996b
Fix typos [ci skip] 2022-04-28 17:51:05 +09:00
Alan Wu 0514d81715 YJIT: Remove unnecessary `extern crate` declaration
Thanks to suggestion from bjorn3 on GitHub.

Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2022-04-27 11:00:22 -04:00
Alan Wu 932bfd0beb YJIT: Make add_comment() more concise
Thanks to suggestions from Stranger6667 on GitHub.

Co-authored-by: Dmitry Dygalo <dmitry@dygalo.dev>
2022-04-27 11:00:22 -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