<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/test/ruby/test_yjit.rb, 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>merge revision(s) 33edcc112081f96856d52e73253d73c97a5c4a3c,b4e438d8aabaf4bba2b27f374c787543fae07c58: [Backport #19483]</title>
<updated>2023-07-16T02:25:45+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2023-07-16T02:25:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=293a00e622da077cd6fad2e4055eb15b081fc2a6'/>
<id>293a00e622da077cd6fad2e4055eb15b081fc2a6</id>
<content type='text'>
	YJIT: Protect strings from GC on String#&lt;&lt; (#7466)

	Fix https://github.com/Shopify/yjit/issues/310

	[Bug #19483]

	Co-authored-by: Maxime Chevalier-Boisvert &lt;maxime.chevalierboisvert@shopify.com&gt;
	Co-authored-by: Jimmy Miller &lt;jimmy.miller@shopify.com&gt;
	---
	 yjit/src/codegen.rs | 3 +++
	 1 file changed, 3 insertions(+)

	YJIT: Save PC on rb_str_concat (#7586)

	[Bug #19483]

	Co-authored-by: Alan Wu &lt;alansi.xingwu@shopify.com&gt;
	---
	 test/ruby/test_yjit.rb | 19 +++++++++++++++++++
	 yjit/src/codegen.rs    |  6 ++++--
	 2 files changed, 23 insertions(+), 2 deletions(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	YJIT: Protect strings from GC on String#&lt;&lt; (#7466)

	Fix https://github.com/Shopify/yjit/issues/310

	[Bug #19483]

	Co-authored-by: Maxime Chevalier-Boisvert &lt;maxime.chevalierboisvert@shopify.com&gt;
	Co-authored-by: Jimmy Miller &lt;jimmy.miller@shopify.com&gt;
	---
	 yjit/src/codegen.rs | 3 +++
	 1 file changed, 3 insertions(+)

	YJIT: Save PC on rb_str_concat (#7586)

	[Bug #19483]

	Co-authored-by: Alan Wu &lt;alansi.xingwu@shopify.com&gt;
	---
	 test/ruby/test_yjit.rb | 19 +++++++++++++++++++
	 yjit/src/codegen.rs    |  6 ++++--
	 2 files changed, 23 insertions(+), 2 deletions(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 132934b82baad97107fe754d60f9a68a1db7ecda: [Backport #19463]</title>
<updated>2023-07-16T02:25:45+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2023-07-16T02:22:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=0ba10fd8508b1a2bf7488649ee90622de9bef04a'/>
<id>0ba10fd8508b1a2bf7488649ee90622de9bef04a</id>
<content type='text'>
	YJIT: Generate Block::entry_exit with block entry PC

	Previously, when Block::entry_exit is requested from any instruction
	that is not the first one in the block, we generated the exit with an
	incorrect PC. We should always be using the PC for the entry of the
	block for Block::entry_exit.

	It was a simple typo. The bug was [introduced][1] while we were
	refactoring to use the current backend. Later, we had a chance to spot
	this issue while [preparing][2] to enable unused variable warnings, but
	didn't spot the issue.

	Fixes [Bug #19463]

	[1]: 27fcab995e6dde19deb91dc6e291bdb72100af68
	[2]: 31461c7e0eab4963ccc8649ea8ebf27979132c0c
	---
	 test/ruby/test_yjit.rb | 41 +++++++++++++++++++++++++++++++++++++++++
	 yjit/src/codegen.rs    |  4 ++--
	 2 files changed, 43 insertions(+), 2 deletions(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	YJIT: Generate Block::entry_exit with block entry PC

	Previously, when Block::entry_exit is requested from any instruction
	that is not the first one in the block, we generated the exit with an
	incorrect PC. We should always be using the PC for the entry of the
	block for Block::entry_exit.

	It was a simple typo. The bug was [introduced][1] while we were
	refactoring to use the current backend. Later, we had a chance to spot
	this issue while [preparing][2] to enable unused variable warnings, but
	didn't spot the issue.

	Fixes [Bug #19463]

	[1]: 27fcab995e6dde19deb91dc6e291bdb72100af68
	[2]: 31461c7e0eab4963ccc8649ea8ebf27979132c0c
	---
	 test/ruby/test_yjit.rb | 41 +++++++++++++++++++++++++++++++++++++++++
	 yjit/src/codegen.rs    |  4 ++--
	 2 files changed, 43 insertions(+), 2 deletions(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 0eb634ae73cb327ede833b72492f912792a4a9d5: [Backport #19464]</title>
<updated>2023-03-15T07:36:32+00:00</updated>
<author>
<name>NARUSE, Yui</name>
<email>naruse@airemix.jp</email>
</author>
<published>2023-03-15T07:36:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b73a07359758a9034996752e981e09ddaffe8d87'/>
<id>b73a07359758a9034996752e981e09ddaffe8d87</id>
<content type='text'>
	YJIT: Detect and reject `send(:alias_for_send, :foo)`

	Previously, YJIT failed to put the stack into the correct shape when
	`BasicObject#send` calls an alias method for the send method itself.
	This can manifest as strange `NoMethodError`s in the final non-send
	receiver, as [seen][1] with the kt-paperclip gem. I also found a case
	where it makes YJIT fail the stack size assertion while compiling
	`leave`.

	YJIT's `BasicObject#__send__` implementation already rejects sends to
	`send`, but didn't detect sends to aliases of `send`. Adjust the
	detection and reject these cases.

	Fixes [Bug #19464]

	[1]: https://github.com/Shopify/yjit/issues/306
	---
	 test/ruby/test_yjit.rb | 20 ++++++++++++++++++++
	 yjit/src/codegen.rs    | 25 ++++++++++---------------
	 2 files changed, 30 insertions(+), 15 deletions(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	YJIT: Detect and reject `send(:alias_for_send, :foo)`

	Previously, YJIT failed to put the stack into the correct shape when
	`BasicObject#send` calls an alias method for the send method itself.
	This can manifest as strange `NoMethodError`s in the final non-send
	receiver, as [seen][1] with the kt-paperclip gem. I also found a case
	where it makes YJIT fail the stack size assertion while compiling
	`leave`.

	YJIT's `BasicObject#__send__` implementation already rejects sends to
	`send`, but didn't detect sends to aliases of `send`. Adjust the
	detection and reject these cases.

	Fixes [Bug #19464]

	[1]: https://github.com/Shopify/yjit/issues/306
	---
	 test/ruby/test_yjit.rb | 20 ++++++++++++++++++++
	 yjit/src/codegen.rs    | 25 ++++++++++---------------
	 2 files changed, 30 insertions(+), 15 deletions(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) c178926fbe879045fa711444a1fd9e906af23e3b,a4b7ec12298c78392797e5ba7704076550e4f100: [Backport #19444]</title>
<updated>2023-03-07T10:48:32+00:00</updated>
<author>
<name>NARUSE, Yui</name>
<email>naruse@airemix.jp</email>
</author>
<published>2023-03-07T10:48:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4d75035e1762a23d38c5192b30bb47f40b752bee'/>
<id>4d75035e1762a23d38c5192b30bb47f40b752bee</id>
<content type='text'>
	YJIT: jit_prepare_routine_call() for String#+@ missing

	We saw SEGVs due to this when running with StackProf, which needs a
	correct PC for RUBY_INTERNAL_EVENT_NEWOBJ, the same event used for
	ObjectSpace allocation tracing.

	[Bug #19444]
	---
	 test/ruby/test_yjit.rb | 27 +++++++++++++++++++++++++++
	 yjit/src/codegen.rs    |  5 ++++-
	 2 files changed, 31 insertions(+), 1 deletion(-)

	YJIT: Fix false assumption that String#+@ =&gt; ::String

	Could return a subclass.

	[Bug #19444]
	---
	 test/ruby/test_yjit.rb | 17 +++++++++++++++++
	 yjit/src/codegen.rs    | 10 +++++++---
	 2 files changed, 24 insertions(+), 3 deletions(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	YJIT: jit_prepare_routine_call() for String#+@ missing

	We saw SEGVs due to this when running with StackProf, which needs a
	correct PC for RUBY_INTERNAL_EVENT_NEWOBJ, the same event used for
	ObjectSpace allocation tracing.

	[Bug #19444]
	---
	 test/ruby/test_yjit.rb | 27 +++++++++++++++++++++++++++
	 yjit/src/codegen.rs    |  5 ++++-
	 2 files changed, 31 insertions(+), 1 deletion(-)

	YJIT: Fix false assumption that String#+@ =&gt; ::String

	Could return a subclass.

	[Bug #19444]
	---
	 test/ruby/test_yjit.rb | 17 +++++++++++++++++
	 yjit/src/codegen.rs    | 10 +++++++---
	 2 files changed, 24 insertions(+), 3 deletions(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) b78f871d838c168789648738e5c67b071beb8a19,ecd0cdaf820af789f355f1a18c31d6adfe8aad94: [Backport #19400]</title>
<updated>2023-03-04T06:39:47+00:00</updated>
<author>
<name>NARUSE, Yui</name>
<email>naruse@airemix.jp</email>
</author>
<published>2023-03-04T06:39:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f93c7b9f58966fd04496bfeb2538fb1ff41f788e'/>
<id>f93c7b9f58966fd04496bfeb2538fb1ff41f788e</id>
<content type='text'>
	YJIT: Use the system page size when the code page size is too small
	 (#7267)

	Previously on ARM64 Linux systems that use 64 KiB pages
	(`CONFIG_ARM64_64K_PAGES=y`), YJIT was panicking on boot due to a failed
	assertion.

	The assertion was making sure that code GC can free the last code page
	that YJIT manages without freeing unrelated memory. YJIT prefers picking
	16 KiB as the granularity at which to free code memory, but when the
	system can only free at 64 KiB granularity, that is not possible.

	The fix is to use the system page size as the code page size when the
	system page size is 64 KiB. Continue to use 16 KiB as the code page size
	on common systems that use 16/4 KiB pages.

	Add asserts to code_gc() and free_page() about code GC's assumptions.

	Fixes [Bug #19400]
	---
	 yjit/src/asm/mod.rs    | 78 ++++++++++++++++++++++++++++++++------------------
	 yjit/src/codegen.rs    |  2 --
	 yjit/src/virtualmem.rs | 13 +++++++++
	 3 files changed, 63 insertions(+), 30 deletions(-)

	YJIT: Fix assertion for partially mapped last pages (#7337)

	Follows up [Bug #19400]
	---
	 test/ruby/test_yjit.rb | 19 +++++++++++++++++++
	 yjit/src/asm/mod.rs    |  2 +-
	 yjit/src/virtualmem.rs | 18 +++++++++++++-----
	 3 files changed, 33 insertions(+), 6 deletions(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	YJIT: Use the system page size when the code page size is too small
	 (#7267)

	Previously on ARM64 Linux systems that use 64 KiB pages
	(`CONFIG_ARM64_64K_PAGES=y`), YJIT was panicking on boot due to a failed
	assertion.

	The assertion was making sure that code GC can free the last code page
	that YJIT manages without freeing unrelated memory. YJIT prefers picking
	16 KiB as the granularity at which to free code memory, but when the
	system can only free at 64 KiB granularity, that is not possible.

	The fix is to use the system page size as the code page size when the
	system page size is 64 KiB. Continue to use 16 KiB as the code page size
	on common systems that use 16/4 KiB pages.

	Add asserts to code_gc() and free_page() about code GC's assumptions.

	Fixes [Bug #19400]
	---
	 yjit/src/asm/mod.rs    | 78 ++++++++++++++++++++++++++++++++------------------
	 yjit/src/codegen.rs    |  2 --
	 yjit/src/virtualmem.rs | 13 +++++++++
	 3 files changed, 63 insertions(+), 30 deletions(-)

	YJIT: Fix assertion for partially mapped last pages (#7337)

	Follows up [Bug #19400]
	---
	 test/ruby/test_yjit.rb | 19 +++++++++++++++++++
	 yjit/src/asm/mod.rs    |  2 +-
	 yjit/src/virtualmem.rs | 18 +++++++++++++-----
	 3 files changed, 33 insertions(+), 6 deletions(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) aeddc19340c7116d48fac3080553fbb823857d16: [Backport #19316]</title>
<updated>2023-01-18T09:56:51+00:00</updated>
<author>
<name>NARUSE, Yui</name>
<email>naruse@airemix.jp</email>
</author>
<published>2023-01-18T09:56:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1fb5eb5740d4c4f1fc34a4a50bc0482eac27b545'/>
<id>1fb5eb5740d4c4f1fc34a4a50bc0482eac27b545</id>
<content type='text'>
	YJIT: Save PC and SP before calling leaf builtins (#7090)

	Previously, we did not update `cfp-&gt;sp` before calling the C function of
	ISEQs marked with `Primitive.attr! "inline"` (leaf builtins). This
	caused the GC to miss temporary values on the stack in case the function
	allocates and triggers a GC run. Right now, there is only a few leaf
	builtins in numeric.rb on Integer methods such as `Integer#~`. Since
	these methods only allocate when operating on big numbers, we missed
	this issue.

	Fix by saving PC and SP before calling the functions -- our usual
	protocol for calling C functions that may allocate on the GC heap.

	[Bug #19316]
	---
	 test/ruby/test_yjit.rb | 16 ++++++++++++++++
	 yjit/src/codegen.rs    |  4 ++++
	 2 files changed, 20 insertions(+)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	YJIT: Save PC and SP before calling leaf builtins (#7090)

	Previously, we did not update `cfp-&gt;sp` before calling the C function of
	ISEQs marked with `Primitive.attr! "inline"` (leaf builtins). This
	caused the GC to miss temporary values on the stack in case the function
	allocates and triggers a GC run. Right now, there is only a few leaf
	builtins in numeric.rb on Integer methods such as `Integer#~`. Since
	these methods only allocate when operating on big numbers, we missed
	this issue.

	Fix by saving PC and SP before calling the functions -- our usual
	protocol for calling C functions that may allocate on the GC heap.

	[Bug #19316]
	---
	 test/ruby/test_yjit.rb | 16 ++++++++++++++++
	 yjit/src/codegen.rs    |  4 ++++
	 2 files changed, 20 insertions(+)
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 43ff0c2c488c80aaf83b486d45bcd4a92ebe3848: [Backport #19299]</title>
<updated>2023-01-18T08:18:44+00:00</updated>
<author>
<name>NARUSE, Yui</name>
<email>naruse@airemix.jp</email>
</author>
<published>2023-01-18T08:18:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=97c32b49e2fe4de8b57ce05146e63b2aa64c7a44'/>
<id>97c32b49e2fe4de8b57ce05146e63b2aa64c7a44</id>
<content type='text'>
	YJIT: Fix `yield` into block with &gt;=30 locals on ARM

	It's a register spill issue. Fix by moving the Qnil fill snippet to
	after registers are released.

	[Bug #19299]
	---
	 test/ruby/test_yjit.rb | 14 ++++++++++++++
	 yjit/src/codegen.rs    | 29 ++++++++++++++---------------
	 2 files changed, 28 insertions(+), 15 deletions(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	YJIT: Fix `yield` into block with &gt;=30 locals on ARM

	It's a register spill issue. Fix by moving the Qnil fill snippet to
	after registers are released.

	[Bug #19299]
	---
	 test/ruby/test_yjit.rb | 14 ++++++++++++++
	 yjit/src/codegen.rs    | 29 ++++++++++++++---------------
	 2 files changed, 28 insertions(+), 15 deletions(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>YJIT: Fix `obj.send(:call)`</title>
<updated>2022-12-15T23:10:28+00:00</updated>
<author>
<name>Alan Wu</name>
<email>XrXr@users.noreply.github.com</email>
</author>
<published>2022-12-15T23:10:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=14158f1f8c50069f076f99e08405c5006ca65df9'/>
<id>14158f1f8c50069f076f99e08405c5006ca65df9</id>
<content type='text'>
All the method call types need to handle argument shifting in case they're
called by `.send`, and we weren't handling that in `OPTIMIZED_METHOD_TYPE_CALL`.

Lack of shifting caused the stack size assertion in gen_leave() to fail.

Discovered by Rails CI: https://buildkite.com/rails/rails/builds/91705#018516c4-f8f8-469e-bc2d-ddeb25ca8317/1920-2067
Diagnosed with help from `@eileencodes` and `@k0kubun`.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
All the method call types need to handle argument shifting in case they're
called by `.send`, and we weren't handling that in `OPTIMIZED_METHOD_TYPE_CALL`.

Lack of shifting caused the stack size assertion in gen_leave() to fail.

Discovered by Rails CI: https://buildkite.com/rails/rails/builds/91705#018516c4-f8f8-469e-bc2d-ddeb25ca8317/1920-2067
Diagnosed with help from `@eileencodes` and `@k0kubun`.</pre>
</div>
</content>
</entry>
<entry>
<title>YJIT: implement `getconstant` YARV instruction (#6884)</title>
<updated>2022-12-09T22:12:15+00:00</updated>
<author>
<name>Maxime Chevalier-Boisvert</name>
<email>maxime.chevalierboisvert@shopify.com</email>
</author>
<published>2022-12-09T22:12:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=daa893db412c6ae814d0291b4ac6fc62a466d394'/>
<id>daa893db412c6ae814d0291b4ac6fc62a466d394</id>
<content type='text'>
* YJIT: implement getconstant YARV instruction

* Constant id is not a pointer

* Stack operands must be read after jit_prepare_routine_call

Co-authored-by: Takashi Kokubun &lt;takashikkbn@gmail.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* YJIT: implement getconstant YARV instruction

* Constant id is not a pointer

* Stack operands must be read after jit_prepare_routine_call

Co-authored-by: Takashi Kokubun &lt;takashikkbn@gmail.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>YJIT: Reorder branches for Fixnum opt_case_dispatch (#6841)</title>
<updated>2022-12-01T15:59:56+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-12-01T15:59:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=2c939458cab06b4fda09b55a57b8bac30efe6b17'/>
<id>2c939458cab06b4fda09b55a57b8bac30efe6b17</id>
<content type='text'>
* YJIT: Reorder branches for Fixnum opt_case_dispatch

Co-authored-by: Maxime Chevalier-Boisvert &lt;maxime.chevalierboisvert@shopify.com&gt;
Co-authored-by: Alan Wu &lt;alansi.xingwu@shopify.com&gt;

* YJIT: Don't support too large values

Co-authored-by: Maxime Chevalier-Boisvert &lt;maxime.chevalierboisvert@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>
* YJIT: Reorder branches for Fixnum opt_case_dispatch

Co-authored-by: Maxime Chevalier-Boisvert &lt;maxime.chevalierboisvert@shopify.com&gt;
Co-authored-by: Alan Wu &lt;alansi.xingwu@shopify.com&gt;

* YJIT: Don't support too large values

Co-authored-by: Maxime Chevalier-Boisvert &lt;maxime.chevalierboisvert@shopify.com&gt;
Co-authored-by: Alan Wu &lt;alansi.xingwu@shopify.com&gt;</pre>
</div>
</content>
</entry>
</feed>
