<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/yjit/src/codegen.rs, 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) dd80d9b089e35729d585bae2f8866c845c48f3b7: [Backport #20997]</title>
<updated>2025-01-25T05:51:31+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2025-01-25T05:51:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=7c0c2df9b497dbf9c1376a995eebe6d43a00e21b'/>
<id>7c0c2df9b497dbf9c1376a995eebe6d43a00e21b</id>
<content type='text'>
	YJIT: Filter `&amp;` calls from specialized C method codegen

	Evident with the crash reported in [Bug #20997], the C replacement
	codegen functions aren't authored to handle block arguments (nor
	should they because the extra code from the complexity defeats
	optimization). Filter sites with VM_CALL_ARGS_BLOCKARG.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	YJIT: Filter `&amp;` calls from specialized C method codegen

	Evident with the crash reported in [Bug #20997], the C replacement
	codegen functions aren't authored to handle block arguments (nor
	should they because the extra code from the complexity defeats
	optimization). Filter sites with VM_CALL_ARGS_BLOCKARG.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fixup be09d77b966c7bcc77957927f16cefe66b365495.</title>
<updated>2023-07-17T08:30:42+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2023-07-17T08:30:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=aef53162249ce090568e24a70e6d26b85bf399d6'/>
<id>aef53162249ce090568e24a70e6d26b85bf399d6</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 31e67a476f2262e01a0829e8ab5e6d8a97e0724e,0b95cbcbde8875effdbcbb676cb0a7f751a1d4c1: [Backport #19601]</title>
<updated>2023-07-17T08:21:51+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2023-07-17T08:21:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=5fbd72764e020c6b165604e9cdcc932a1c5d2a93'/>
<id>5fbd72764e020c6b165604e9cdcc932a1c5d2a93</id>
<content type='text'>
	YJIT: Fix false object collection when setting ivar

	Previously, setinstancevariable could generate code that calls
	`rb_ensure_iv_list_size()` without first updating `cfp-&gt;sp`. This means
	in the event that a GC start from within said routine the top few
	objects would not be marked, causing them to be falsly collected.

	Call `jit_prepare_routine_call()` first.

	[Bug #19601]
	---
	 bootstraptest/test_yjit.rb | 20 ++++++++++++++++++++
	 yjit/src/codegen.rs        |  5 +++++
	 2 files changed, 25 insertions(+)

	YJIT: Remove duplicate `asm.spill_temps()`

	`jit_prepare_routine_call()` calls it, and there is another call above on line 2302.

	Co-authored-by: Takashi Kokubun &lt;takashikkbn@gmail.com&gt;
	---
	 yjit/src/codegen.rs | 1 -
	 1 file changed, 1 deletion(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	YJIT: Fix false object collection when setting ivar

	Previously, setinstancevariable could generate code that calls
	`rb_ensure_iv_list_size()` without first updating `cfp-&gt;sp`. This means
	in the event that a GC start from within said routine the top few
	objects would not be marked, causing them to be falsly collected.

	Call `jit_prepare_routine_call()` first.

	[Bug #19601]
	---
	 bootstraptest/test_yjit.rb | 20 ++++++++++++++++++++
	 yjit/src/codegen.rs        |  5 +++++
	 2 files changed, 25 insertions(+)

	YJIT: Remove duplicate `asm.spill_temps()`

	`jit_prepare_routine_call()` calls it, and there is another call above on line 2302.

	Co-authored-by: Takashi Kokubun &lt;takashikkbn@gmail.com&gt;
	---
	 yjit/src/codegen.rs | 1 -
	 1 file changed, 1 deletion(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>Fixup the latest commits.</title>
<updated>2023-07-17T05:09:11+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2023-07-17T05:09:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=0c5d539421e50351ed26fbf9cac852d58425776a'/>
<id>0c5d539421e50351ed26fbf9cac852d58425776a</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 0ce2bdc76dd17aa3d42a352a6244c87a51e7606d: [Backport #19595]</title>
<updated>2023-07-17T04:59:25+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2023-07-17T04:59:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=8852b4b2deea20f488208dc4730ef149f67d7594'/>
<id>8852b4b2deea20f488208dc4730ef149f67d7594</id>
<content type='text'>
	YJIT: Fix missing argc check in known cfuncs

	Previously we were missing a compile-time check that the known cfuncs
	receive the correct number of arguments.

	We noticied this because in particular when using ARGS_SPLAT, which also
	wasn't checked, YJIT would crash on code which was otherwise correct
	(didn't raise exceptions in the VM).

	This still supports vararg (argc == -1) cfuncs. I added an additional
	assertion that when we use the specialized codegen for one of these
	known functions that the argc are popped off the stack correctly, which
	should help ensure they're implemented correctly (previously the crash
	was usually observed on a future `leave` insn).

	[Bug #19595]
	---
	 bootstraptest/test_yjit.rb | 32 ++++++++++++++++++++++++++++++++
	 yjit/src/codegen.rs        |  4 +++-
	 2 files changed, 35 insertions(+), 1 deletion(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	YJIT: Fix missing argc check in known cfuncs

	Previously we were missing a compile-time check that the known cfuncs
	receive the correct number of arguments.

	We noticied this because in particular when using ARGS_SPLAT, which also
	wasn't checked, YJIT would crash on code which was otherwise correct
	(didn't raise exceptions in the VM).

	This still supports vararg (argc == -1) cfuncs. I added an additional
	assertion that when we use the specialized codegen for one of these
	known functions that the argc are popped off the stack correctly, which
	should help ensure they're implemented correctly (previously the crash
	was usually observed on a future `leave` insn).

	[Bug #19595]
	---
	 bootstraptest/test_yjit.rb | 32 ++++++++++++++++++++++++++++++++
	 yjit/src/codegen.rs        |  4 +++-
	 2 files changed, 35 insertions(+), 1 deletion(-)
</pre>
</div>
</content>
</entry>
<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>ruby_3_2 backport for #8006 (#8008)</title>
<updated>2023-07-04T15:07:18+00:00</updated>
<author>
<name>Alan Wu</name>
<email>XrXr@users.noreply.github.com</email>
</author>
<published>2023-07-04T15:07:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=2f603bc4d750384d57513679ca9db2b4e2e3ec34'/>
<id>2f603bc4d750384d57513679ca9db2b4e2e3ec34</id>
<content type='text'>
YJIT: Fix autosplat miscomp for blocks with optionals

When passing an array as the sole argument to `yield`, and the yieldee
takes more than 1 optional parameter, the array is expanded similar
to `*array` splat calls. This is called "autosplat" in
`setup_parameters_complex()`.

Previously, YJIT did not detect this autosplat condition. It passed the
array without expanding it, deviating from interpreter behavior.
Detect this conditon and refuse to compile it.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
YJIT: Fix autosplat miscomp for blocks with optionals

When passing an array as the sole argument to `yield`, and the yieldee
takes more than 1 optional parameter, the array is expanded similar
to `*array` splat calls. This is called "autosplat" in
`setup_parameters_complex()`.

Previously, YJIT did not detect this autosplat condition. It passed the
array without expanding it, deviating from interpreter behavior.
Detect this conditon and refuse to compile it.</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>
</feed>
