<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/yjit.h, branch v3_2_11</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>YJIT: Invalidate redefined methods only through cme (#6734)</title>
<updated>2022-11-15T20:57:43+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-11-15T20:57:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1125274c4e8aeffd8609ced41c05d26d45b9b5ad'/>
<id>1125274c4e8aeffd8609ced41c05d26d45b9b5ad</id>
<content type='text'>
Co-authored-by: Alan Wu &lt;alansi.xingwu@shopify.com&gt;

Co-authored-by: Alan Wu &lt;alansi.xingwu@shopify.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Co-authored-by: Alan Wu &lt;alansi.xingwu@shopify.com&gt;

Co-authored-by: Alan Wu &lt;alansi.xingwu@shopify.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>Reduce the number of branches in jit_exec (#6722)</title>
<updated>2022-11-14T04:35:35+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-11-14T04:35:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=3dd4e381fe3c7faf886145ad7ab2152c6b199d69'/>
<id>3dd4e381fe3c7faf886145ad7ab2152c6b199d69</id>
<content type='text'>
* Reduce the number of branches in jit_exec

* Address build failure in some configurations

* Refactor yjit.h</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Reduce the number of branches in jit_exec

* Address build failure in some configurations

* Refactor yjit.h</pre>
</div>
</content>
</entry>
<entry>
<title>New constant caching insn: opt_getconstant_path</title>
<updated>2022-09-01T22:20:49+00:00</updated>
<author>
<name>John Hawthorn</name>
<email>john@hawthorn.email</email>
</author>
<published>2022-08-10T17:35:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=679ef34586e7a43151865cb7f33a3253d815f7cf'/>
<id>679ef34586e7a43151865cb7f33a3253d815f7cf</id>
<content type='text'>
Previously YARV bytecode implemented constant caching by having a pair
of instructions, opt_getinlinecache and opt_setinlinecache, wrapping a
series of getconstant calls (with putobject providing supporting
arguments).

This commit replaces that pattern with a new instruction,
opt_getconstant_path, handling both getting/setting the inline cache and
fetching the constant on a cache miss.

This is implemented by storing the full constant path as a
null-terminated array of IDs inside of the IC structure. idNULL is used
to signal an absolute constant reference.

    $ ./miniruby --dump=insns -e '::Foo::Bar::Baz'
    == disasm: #&lt;ISeq:&lt;main&gt;@-e:1 (1,0)-(1,13)&gt; (catch: FALSE)
    0000 opt_getconstant_path                   &lt;ic:0 ::Foo::Bar::Baz&gt;      (   1)[Li]
    0002 leave

The motivation for this is that we had increasingly found the need to
disassemble the instructions between the opt_getinlinecache and
opt_setinlinecache in order to determine the constant we are fetching,
or otherwise store metadata.

This disassembly was done:
* In opt_setinlinecache, to register the IC against the constant names
  it is using for granular invalidation.
* In rb_iseq_free, to unregister the IC from the invalidation table.
* In YJIT to find the position of a opt_getinlinecache instruction to
  invalidate it when the cache is populated
* In YJIT to register the constant names being used for invalidation.

With this change we no longe need disassemly for these (in fact
rb_iseq_each is now unused), as the list of constant names being
referenced is held in the IC. This should also make it possible to make
more optimizations in the future.

This may also reduce the size of iseqs, as previously each segment
required 32 bytes (on 64-bit platforms) for each constant segment. This
implementation only stores one ID per-segment.

There should be no significant performance change between this and the
previous implementation. Previously opt_getinlinecache was a "leaf"
instruction, but it included a jump (almost always to a separate cache
line). Now opt_getconstant_path is a non-leaf (it may
raise/autoload/call const_missing) but it does not jump. These seem to
even out.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously YARV bytecode implemented constant caching by having a pair
of instructions, opt_getinlinecache and opt_setinlinecache, wrapping a
series of getconstant calls (with putobject providing supporting
arguments).

This commit replaces that pattern with a new instruction,
opt_getconstant_path, handling both getting/setting the inline cache and
fetching the constant on a cache miss.

This is implemented by storing the full constant path as a
null-terminated array of IDs inside of the IC structure. idNULL is used
to signal an absolute constant reference.

    $ ./miniruby --dump=insns -e '::Foo::Bar::Baz'
    == disasm: #&lt;ISeq:&lt;main&gt;@-e:1 (1,0)-(1,13)&gt; (catch: FALSE)
    0000 opt_getconstant_path                   &lt;ic:0 ::Foo::Bar::Baz&gt;      (   1)[Li]
    0002 leave

The motivation for this is that we had increasingly found the need to
disassemble the instructions between the opt_getinlinecache and
opt_setinlinecache in order to determine the constant we are fetching,
or otherwise store metadata.

This disassembly was done:
* In opt_setinlinecache, to register the IC against the constant names
  it is using for granular invalidation.
* In rb_iseq_free, to unregister the IC from the invalidation table.
* In YJIT to find the position of a opt_getinlinecache instruction to
  invalidate it when the cache is populated
* In YJIT to register the constant names being used for invalidation.

With this change we no longe need disassemly for these (in fact
rb_iseq_each is now unused), as the list of constant names being
referenced is held in the IC. This should also make it possible to make
more optimizations in the future.

This may also reduce the size of iseqs, as previously each segment
required 32 bytes (on 64-bit platforms) for each constant segment. This
implementation only stores one ID per-segment.

There should be no significant performance change between this and the
previous implementation. Previously opt_getinlinecache was a "leaf"
instruction, but it included a jump (almost always to a separate cache
line). Now opt_getconstant_path is a non-leaf (it may
raise/autoload/call const_missing) but it does not jump. These seem to
even out.
</pre>
</div>
</content>
</entry>
<entry>
<title>Allow aarch64 to build YJIT</title>
<updated>2022-08-29T15:47:11+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-08-16T19:51:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c38e9111478773a20656bfe5329cdab78dfb075b'/>
<id>c38e9111478773a20656bfe5329cdab78dfb075b</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Simplify around `USE_YJIT` macro (#6240)</title>
<updated>2022-08-15T17:05:12+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2022-08-15T17:05:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=ee864beb7c6730083da656b55f4a9eeaed78bfa8'/>
<id>ee864beb7c6730083da656b55f4a9eeaed78bfa8</id>
<content type='text'>
* Simplify around `USE_YJIT` macro

- Use `USE_YJIT` macro only instead of `YJIT_BUILD`.
- An intermediate macro `YJIT_SUPPORTED_P` is no longer used.

* Bail out if YJIT is enabled on unsupported platforms</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Simplify around `USE_YJIT` macro

- Use `USE_YJIT` macro only instead of `YJIT_BUILD`.
- An intermediate macro `YJIT_SUPPORTED_P` is no longer used.

* Bail out if YJIT is enabled on unsupported platforms</pre>
</div>
</content>
</entry>
<entry>
<title>YJIT: Undef YJIT_SUPPORTED_P for hygiene</title>
<updated>2022-06-26T12:36:10+00:00</updated>
<author>
<name>Alan Wu</name>
<email>alanwu@ruby-lang.org</email>
</author>
<published>2022-06-26T12:22:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=2085201176775c1c0b6fd0c4791dbdad6d68c37f'/>
<id>2085201176775c1c0b6fd0c4791dbdad6d68c37f</id>
<content type='text'>
YJIT_BUILD is more relevant outside of YJIT.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
YJIT_BUILD is more relevant outside of YJIT.
</pre>
</div>
</content>
</entry>
<entry>
<title>Rust YJIT</title>
<updated>2022-04-27T15:00:22+00:00</updated>
<author>
<name>Alan Wu</name>
<email>alanwu@ruby-lang.org</email>
</author>
<published>2022-04-19T18:40:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f90549cd38518231a6a74432fe1168c943a7cc18'/>
<id>f90549cd38518231a6a74432fe1168c943a7cc18</id>
<content type='text'>
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:
https://github.com/Shopify/ruby/commit/1fd9573d8b4b65219f1c2407f30a0a60e537f8be

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 &lt;maximechevalierb@gmail.com&gt;
Co-authored-by: Noah Gibbs &lt;the.codefolio.guy@gmail.com&gt;
Co-authored-by: Kevin Newton &lt;kddnewton@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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:
https://github.com/Shopify/ruby/commit/1fd9573d8b4b65219f1c2407f30a0a60e537f8be

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 &lt;maximechevalierb@gmail.com&gt;
Co-authored-by: Noah Gibbs &lt;the.codefolio.guy@gmail.com&gt;
Co-authored-by: Kevin Newton &lt;kddnewton@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>re-enabled YJIT on x64-mswin64</title>
<updated>2021-12-31T11:13:11+00:00</updated>
<author>
<name>NAKAMURA Usaku</name>
<email>usa@ruby-lang.org</email>
</author>
<published>2021-12-31T11:13:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a493732c8e4d038885ae40c71dd3fc5118f36809'/>
<id>a493732c8e4d038885ae40c71dd3fc5118f36809</id>
<content type='text'>
note that YJIT does not work correctly on the platform now.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
note that YJIT does not work correctly on the platform now.
</pre>
</div>
</content>
</entry>
<entry>
<title>Do not support non-x86_64 platforms</title>
<updated>2021-12-28T03:57:30+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2021-12-28T03:57:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=91b7be7708797d8d3057fb6f2223645b4b85be71'/>
<id>91b7be7708797d8d3057fb6f2223645b4b85be71</id>
<content type='text'>
This was probably not intended in 85a426dc8678f04a78ffd799943b690ce2984c49.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This was probably not intended in 85a426dc8678f04a78ffd799943b690ce2984c49.
</pre>
</div>
</content>
</entry>
<entry>
<title>Tiny mmap emulation for Windows</title>
<updated>2021-12-27T06:56:23+00:00</updated>
<author>
<name>U.Nakamura</name>
<email>usa@ruby-lang.org</email>
</author>
<published>2021-12-27T06:56:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=85a426dc8678f04a78ffd799943b690ce2984c49'/>
<id>85a426dc8678f04a78ffd799943b690ce2984c49</id>
<content type='text'>
- prerequisite of supporting YJIT with VC++.
- note that now can specfily `--yjit` on mswin64, but not enabled
  YJIT'ed code because of YJIT requires `OPT_DIRECT_THREADED_CODE`
  or `OPT_CALL_THREADED_CODE` in `rb_yjit_compile_iseq`.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- prerequisite of supporting YJIT with VC++.
- note that now can specfily `--yjit` on mswin64, but not enabled
  YJIT'ed code because of YJIT requires `OPT_DIRECT_THREADED_CODE`
  or `OPT_CALL_THREADED_CODE` in `rb_yjit_compile_iseq`.
</pre>
</div>
</content>
</entry>
</feed>
