<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/yjit/src/backend/arm64/mod.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) 188688a53e7708d25ab80e14d05e70ffcf792e13: [Backport #19385]</title>
<updated>2023-02-03T05:13:09+00:00</updated>
<author>
<name>NARUSE, Yui</name>
<email>naruse@airemix.jp</email>
</author>
<published>2023-02-03T05:13:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=535d863f34e6c36a2378683e7c2d3b7369e3d076'/>
<id>535d863f34e6c36a2378683e7c2d3b7369e3d076</id>
<content type='text'>
	[PATCH 1/4] YJIT: Move CodegenGlobals::freed_pages into an Rc

	This allows for supplying a freed_pages vec in Rust tests. We need it so we
	can test scenarios that occur after code GC.
	---
	 yjit/src/asm/mod.rs | 48 +++++++++++++++++++++++++++++++++------------
	 yjit/src/codegen.rs | 16 ++++-----------
	 2 files changed, 39 insertions(+), 25 deletions(-)

	Subject: [PATCH 2/4] YJIT: other_cb is None in tests

	Since the other cb is in CodegenGlobals, and we want Rust tests to be
	self-contained.
	---
	 yjit/src/asm/mod.rs | 1 +
	 1 file changed, 1 insertion(+)

	Subject: [PATCH 3/4] YJIT: ARM64: Move functions out of arm64_emit()

	---
	 yjit/src/backend/arm64/mod.rs | 180 +++++++++++++++++-----------------
	 1 file changed, 90 insertions(+), 90 deletions(-)

	Subject: [PATCH 4/4] YJIT: ARM64: Fix long jumps to labels

	Previously, with Code GC, YJIT panicked while trying to emit a B.cond
	instruction with an offset that is not encodable in 19 bits. This only
	happens when the code in an assembler instance straddles two pages.

	To fix this, when we detect that a jump to a label can land on a
	different page, we switch to a fresh new page and regenerate all the
	code in the assembler there. We still assume that no one assembler has
	so much code that it wouldn't fit inside a fresh new page.

	[Bug #19385]
	---
	 yjit/src/backend/arm64/mod.rs | 65 ++++++++++++++++++++++++++++++++---
	 1 file changed, 60 insertions(+), 5 deletions(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[PATCH 1/4] YJIT: Move CodegenGlobals::freed_pages into an Rc

	This allows for supplying a freed_pages vec in Rust tests. We need it so we
	can test scenarios that occur after code GC.
	---
	 yjit/src/asm/mod.rs | 48 +++++++++++++++++++++++++++++++++------------
	 yjit/src/codegen.rs | 16 ++++-----------
	 2 files changed, 39 insertions(+), 25 deletions(-)

	Subject: [PATCH 2/4] YJIT: other_cb is None in tests

	Since the other cb is in CodegenGlobals, and we want Rust tests to be
	self-contained.
	---
	 yjit/src/asm/mod.rs | 1 +
	 1 file changed, 1 insertion(+)

	Subject: [PATCH 3/4] YJIT: ARM64: Move functions out of arm64_emit()

	---
	 yjit/src/backend/arm64/mod.rs | 180 +++++++++++++++++-----------------
	 1 file changed, 90 insertions(+), 90 deletions(-)

	Subject: [PATCH 4/4] YJIT: ARM64: Fix long jumps to labels

	Previously, with Code GC, YJIT panicked while trying to emit a B.cond
	instruction with an offset that is not encodable in 19 bits. This only
	happens when the code in an assembler instance straddles two pages.

	To fix this, when we detect that a jump to a label can land on a
	different page, we switch to a fresh new page and regenerate all the
	code in the assembler there. We still assume that no one assembler has
	so much code that it wouldn't fit inside a fresh new page.

	[Bug #19385]
	---
	 yjit/src/backend/arm64/mod.rs | 65 ++++++++++++++++++++++++++++++++---
	 1 file changed, 60 insertions(+), 5 deletions(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>YJIT: fix 32 and 16 bit register store (#6840)</title>
<updated>2022-12-01T15:53:50+00:00</updated>
<author>
<name>Jemma Issroff</name>
<email>jemmaissroff@gmail.com</email>
</author>
<published>2022-12-01T15:53:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=06a0c580161db7084e8276fcd9fbb5d25bde4a03'/>
<id>06a0c580161db7084e8276fcd9fbb5d25bde4a03</id>
<content type='text'>
* Fix 32 and 16 bit register store in YJIT

Co-Authored-By: Takashi Kokubun &lt;takashikkbn@gmail.com&gt;

* Remove an unnecessary diff

* Reuse an rm_num_bits result

* Use u16::MAX instead

* Update the link

Co-authored-by: Alan Wu &lt;XrXr@users.noreply.github.com&gt;

* Just use sturh for 16 bits

Co-authored-by: Takashi Kokubun &lt;takashikkbn@gmail.com&gt;
Co-authored-by: Alan Wu &lt;XrXr@users.noreply.github.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Fix 32 and 16 bit register store in YJIT

Co-Authored-By: Takashi Kokubun &lt;takashikkbn@gmail.com&gt;

* Remove an unnecessary diff

* Reuse an rm_num_bits result

* Use u16::MAX instead

* Update the link

Co-authored-by: Alan Wu &lt;XrXr@users.noreply.github.com&gt;

* Just use sturh for 16 bits

Co-authored-by: Takashi Kokubun &lt;takashikkbn@gmail.com&gt;
Co-authored-by: Alan Wu &lt;XrXr@users.noreply.github.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>YJIT: Simplify Insn::CCall to obviate Target::FunPtr (#6793)</title>
<updated>2022-11-23T17:14:43+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-11-23T17:14:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a50aabde9cf3b58c63563427b2e7d22c60370cdd'/>
<id>a50aabde9cf3b58c63563427b2e7d22c60370cdd</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>YJIT: Skip padding jumps to side exits on Arm (#6790)</title>
<updated>2022-11-22T20:57:17+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-11-22T20:57:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=63f4a7a1ec3433cc985503e3ca342e4a9ebda257'/>
<id>63f4a7a1ec3433cc985503e3ca342e4a9ebda257</id>
<content type='text'>
YJIT: Skip padding jumps to side exits

Co-authored-by: Maxime Chevalier-Boisvert &lt;maxime.chevalierboisvert@shopify.com&gt;
Co-authored-by: Alan Wu &lt;alansi.xingwu@shopify.com&gt;

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: Skip padding jumps to side exits

Co-authored-by: Maxime Chevalier-Boisvert &lt;maxime.chevalierboisvert@shopify.com&gt;
Co-authored-by: Alan Wu &lt;alansi.xingwu@shopify.com&gt;

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>
<entry>
<title>32 bit comparison on shape id</title>
<updated>2022-11-18T20:04:10+00:00</updated>
<author>
<name>Aaron Patterson</name>
<email>tenderlove@ruby-lang.org</email>
</author>
<published>2022-11-15T19:46:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=9e067df76bda7384e8f3ddda2b348f3a742eb784'/>
<id>9e067df76bda7384e8f3ddda2b348f3a742eb784</id>
<content type='text'>
This commit changes the shape id comparisons to use a 32 bit comparison
rather than 64 bit.  That means we don't need to load the shape id to a
register on x86 machines.

Given the following program:

```ruby
class Foo
  def initialize
    @foo = 1
    @bar = 1
  end

  def read
    [@foo, @bar]
  end
end

foo = Foo.new
foo.read
foo.read
foo.read
foo.read
foo.read

puts RubyVM::YJIT.disasm(Foo.instance_method(:read))
```

The machine code we generated _before_ this change is like this:

```
== BLOCK 1/4, ISEQ RANGE [0,3), 65 bytes ======================
  # getinstancevariable
  0x559a18623023: mov rax, qword ptr [r13 + 0x18]
  # guard object is heap
  0x559a18623027: test al, 7
  0x559a1862302a: jne 0x559a1862502d
  0x559a18623030: cmp rax, 4
  0x559a18623034: jbe 0x559a1862502d
  # guard shape, embedded, and T_OBJECT
  0x559a1862303a: mov rcx, qword ptr [rax]
  0x559a1862303d: movabs r11, 0xffff00000000201f
  0x559a18623047: and rcx, r11
  0x559a1862304a: movabs r11, 0xb000000002001
  0x559a18623054: cmp rcx, r11
  0x559a18623057: jne 0x559a18625046
  0x559a1862305d: mov rax, qword ptr [rax + 0x18]
  0x559a18623061: mov qword ptr [rbx], rax

== BLOCK 2/4, ISEQ RANGE [3,6), 0 bytes =======================
== BLOCK 3/4, ISEQ RANGE [3,6), 47 bytes ======================
  # gen_direct_jmp: fallthrough
  # getinstancevariable
  # regenerate_branch
  # getinstancevariable
  # regenerate_branch
  0x559a18623064: mov rax, qword ptr [r13 + 0x18]
  # guard shape, embedded, and T_OBJECT
  0x559a18623068: mov rcx, qword ptr [rax]
  0x559a1862306b: movabs r11, 0xffff00000000201f
  0x559a18623075: and rcx, r11
  0x559a18623078: movabs r11, 0xb000000002001
  0x559a18623082: cmp rcx, r11
  0x559a18623085: jne 0x559a18625099
  0x559a1862308b: mov rax, qword ptr [rax + 0x20]
  0x559a1862308f: mov qword ptr [rbx + 8], rax
```

After this change, it's like this:

```
== BLOCK 1/4, ISEQ RANGE [0,3), 41 bytes ======================
  # getinstancevariable
  0x5560c986d023: mov rax, qword ptr [r13 + 0x18]
  # guard object is heap
  0x5560c986d027: test al, 7
  0x5560c986d02a: jne 0x5560c986f02d
  0x5560c986d030: cmp rax, 4
  0x5560c986d034: jbe 0x5560c986f02d
  # guard shape
  0x5560c986d03a: cmp word ptr [rax + 6], 0x19
  0x5560c986d03f: jne 0x5560c986f046
  0x5560c986d045: mov rax, qword ptr [rax + 0x10]
  0x5560c986d049: mov qword ptr [rbx], rax

== BLOCK 2/4, ISEQ RANGE [3,6), 0 bytes =======================
== BLOCK 3/4, ISEQ RANGE [3,6), 23 bytes ======================
  # gen_direct_jmp: fallthrough
  # getinstancevariable
  # regenerate_branch
  # getinstancevariable
  # regenerate_branch
  0x5560c986d04c: mov rax, qword ptr [r13 + 0x18]
  # guard shape
  0x5560c986d050: cmp word ptr [rax + 6], 0x19
  0x5560c986d055: jne 0x5560c986f099
  0x5560c986d05b: mov rax, qword ptr [rax + 0x18]
  0x5560c986d05f: mov qword ptr [rbx + 8], rax
```

The first ivar read is a bit more complex, but the second ivar read is
much simpler.  I think eventually we could teach the context about the
shape, then emit only one shape guard.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit changes the shape id comparisons to use a 32 bit comparison
rather than 64 bit.  That means we don't need to load the shape id to a
register on x86 machines.

Given the following program:

```ruby
class Foo
  def initialize
    @foo = 1
    @bar = 1
  end

  def read
    [@foo, @bar]
  end
end

foo = Foo.new
foo.read
foo.read
foo.read
foo.read
foo.read

puts RubyVM::YJIT.disasm(Foo.instance_method(:read))
```

The machine code we generated _before_ this change is like this:

```
== BLOCK 1/4, ISEQ RANGE [0,3), 65 bytes ======================
  # getinstancevariable
  0x559a18623023: mov rax, qword ptr [r13 + 0x18]
  # guard object is heap
  0x559a18623027: test al, 7
  0x559a1862302a: jne 0x559a1862502d
  0x559a18623030: cmp rax, 4
  0x559a18623034: jbe 0x559a1862502d
  # guard shape, embedded, and T_OBJECT
  0x559a1862303a: mov rcx, qword ptr [rax]
  0x559a1862303d: movabs r11, 0xffff00000000201f
  0x559a18623047: and rcx, r11
  0x559a1862304a: movabs r11, 0xb000000002001
  0x559a18623054: cmp rcx, r11
  0x559a18623057: jne 0x559a18625046
  0x559a1862305d: mov rax, qword ptr [rax + 0x18]
  0x559a18623061: mov qword ptr [rbx], rax

== BLOCK 2/4, ISEQ RANGE [3,6), 0 bytes =======================
== BLOCK 3/4, ISEQ RANGE [3,6), 47 bytes ======================
  # gen_direct_jmp: fallthrough
  # getinstancevariable
  # regenerate_branch
  # getinstancevariable
  # regenerate_branch
  0x559a18623064: mov rax, qword ptr [r13 + 0x18]
  # guard shape, embedded, and T_OBJECT
  0x559a18623068: mov rcx, qword ptr [rax]
  0x559a1862306b: movabs r11, 0xffff00000000201f
  0x559a18623075: and rcx, r11
  0x559a18623078: movabs r11, 0xb000000002001
  0x559a18623082: cmp rcx, r11
  0x559a18623085: jne 0x559a18625099
  0x559a1862308b: mov rax, qword ptr [rax + 0x20]
  0x559a1862308f: mov qword ptr [rbx + 8], rax
```

After this change, it's like this:

```
== BLOCK 1/4, ISEQ RANGE [0,3), 41 bytes ======================
  # getinstancevariable
  0x5560c986d023: mov rax, qword ptr [r13 + 0x18]
  # guard object is heap
  0x5560c986d027: test al, 7
  0x5560c986d02a: jne 0x5560c986f02d
  0x5560c986d030: cmp rax, 4
  0x5560c986d034: jbe 0x5560c986f02d
  # guard shape
  0x5560c986d03a: cmp word ptr [rax + 6], 0x19
  0x5560c986d03f: jne 0x5560c986f046
  0x5560c986d045: mov rax, qword ptr [rax + 0x10]
  0x5560c986d049: mov qword ptr [rbx], rax

== BLOCK 2/4, ISEQ RANGE [3,6), 0 bytes =======================
== BLOCK 3/4, ISEQ RANGE [3,6), 23 bytes ======================
  # gen_direct_jmp: fallthrough
  # getinstancevariable
  # regenerate_branch
  # getinstancevariable
  # regenerate_branch
  0x5560c986d04c: mov rax, qword ptr [r13 + 0x18]
  # guard shape
  0x5560c986d050: cmp word ptr [rax + 6], 0x19
  0x5560c986d055: jne 0x5560c986f099
  0x5560c986d05b: mov rax, qword ptr [rax + 0x18]
  0x5560c986d05f: mov qword ptr [rbx + 8], rax
```

The first ivar read is a bit more complex, but the second ivar read is
much simpler.  I think eventually we could teach the context about the
shape, then emit only one shape guard.
</pre>
</div>
</content>
</entry>
<entry>
<title>YJIT: Stop incrementing write_pos if cb.has_dropped_bytes (#6664)</title>
<updated>2022-11-03T15:42:28+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-11-03T15:42:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=68ef97d788cf8bff42d981bda41cd26128220740'/>
<id>68ef97d788cf8bff42d981bda41cd26128220740</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>YJIT: Support invokeblock (#6640)</title>
<updated>2022-11-02T16:30:48+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-11-02T16:30:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=81e84e0a4d348309d5d38311d283d049ffeeb7a2'/>
<id>81e84e0a4d348309d5d38311d283d049ffeeb7a2</id>
<content type='text'>
* YJIT: Support invokeblock

* Update yjit/src/backend/arm64/mod.rs

* Update yjit/src/codegen.rs

Co-authored-by: Maxime Chevalier-Boisvert &lt;maximechevalierb@gmail.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* YJIT: Support invokeblock

* Update yjit/src/backend/arm64/mod.rs

* Update yjit/src/codegen.rs

Co-authored-by: Maxime Chevalier-Boisvert &lt;maximechevalierb@gmail.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>YJIT: Invalidate i-cache for the other cb on next_page (#6631)</title>
<updated>2022-10-26T15:29:12+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-10-26T15:29:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=fa0adbad92fc1216ba0d1757fe40f0453e3a6574'/>
<id>fa0adbad92fc1216ba0d1757fe40f0453e3a6574</id>
<content type='text'>
* YJIT: Invalidate i-cache for the other cb on next_page

* YJIT: Invalidate only what's written by jmp_ptr

* YJIT: Move the code to the arm64 backend</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* YJIT: Invalidate i-cache for the other cb on next_page

* YJIT: Invalidate only what's written by jmp_ptr

* YJIT: Move the code to the arm64 backend</pre>
</div>
</content>
</entry>
<entry>
<title>YJIT: fold the "asm_comments" feature into "disasm" (#6591)</title>
<updated>2022-10-19T18:03:07+00:00</updated>
<author>
<name>Alan Wu</name>
<email>XrXr@users.noreply.github.com</email>
</author>
<published>2022-10-19T18:03:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=5ca23caa2057fc4760fbefab6087371b11c4bc6c'/>
<id>5ca23caa2057fc4760fbefab6087371b11c4bc6c</id>
<content type='text'>
Previously, enabling only "disasm" didn't actually build. Since these
two features are closely related and we don't really use one without the
other, let's simplify and merge the two features together.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously, enabling only "disasm" didn't actually build. Since these
two features are closely related and we don't really use one without the
other, let's simplify and merge the two features together.</pre>
</div>
</content>
</entry>
<entry>
<title>YJIT: Interleave inline and outlined code blocks (#6460)</title>
<updated>2022-10-17T17:45:59+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-10-17T17:45:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=64c52c428285e7930aed62740cc9c54ee483178e'/>
<id>64c52c428285e7930aed62740cc9c54ee483178e</id>
<content type='text'>
Co-authored-by: Alan Wu &lt;alansi.xingwu@shopify.com&gt;
Co-authored-by: Maxime Chevalier-Boisvert &lt;maxime.chevalierboisvert@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: Maxime Chevalier-Boisvert &lt;maxime.chevalierboisvert@shopify.com&gt;</pre>
</div>
</content>
</entry>
</feed>
