[前][次][番号順一覧][スレッド一覧]

ruby-changes:73227

From: Alan <ko1@a...>
Date: Tue, 30 Aug 2022 01:03:17 +0900 (JST)
Subject: [ruby-changes:73227] 8617bac950 (master): Fix IncrCounter on ARM

https://git.ruby-lang.org/ruby.git/commit/?id=8617bac950

From 8617bac950fbee712e621f79bf96ca30fa9aa2ec Mon Sep 17 00:00:00 2001
From: Alan Wu <XrXr@u...>
Date: Fri, 22 Jul 2022 18:02:24 -0400
Subject: Fix IncrCounter on ARM

The order of operands to LDADDAL were flipped and the destination
pointer was dereferenced instead of passed as an address.
---
 yjit/src/backend/arm64/mod.rs | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/yjit/src/backend/arm64/mod.rs b/yjit/src/backend/arm64/mod.rs
index c6cd1b882c..12cd267245 100644
--- a/yjit/src/backend/arm64/mod.rs
+++ b/yjit/src/backend/arm64/mod.rs
@@ -238,17 +238,17 @@ impl Assembler https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/arm64/mod.rs#L238
                     asm.push_insn(op, new_opnds, target, text, pos_marker);
                 },
                 Op::IncrCounter => {
-                    // Every operand to the IncrCounter instruction need to be a
-                    // register once it gets there. So here we're going to load
-                    // anything that isn't a register first.
-                    let new_opnds: Vec<Opnd> = opnds.into_iter().map(|opnd| {
-                        match opnd {
-                            Opnd::Mem(_) | Opnd::Imm(_) | Opnd::UImm(_) => asm.load(opnd),
-                            _ => opnd,
-                        }
-                    }).collect();
+                    // We'll use LDADD later which only works with registers
+                    // ... Load pointer into register
+                    let counter_addr = asm.lea(opnds[0]);
+
+                    // Load immediates into a register
+                    let addend = match opnds[1] {
+                        opnd @ Opnd::Imm(_) | opnd @ Opnd::UImm(_) => asm.load(opnd),
+                        opnd => opnd,
+                    };
 
-                    asm.incr_counter(new_opnds[0], new_opnds[1]);
+                    asm.incr_counter(counter_addr, addend);
                 },
                 Op::JmpOpnd => {
                     if let Opnd::Mem(_) = opnds[0] {
@@ -769,7 +769,7 @@ impl Assembler https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/arm64/mod.rs#L769
                     emit_conditional_jump::<{Condition::VS}>(cb, insn.target.unwrap());
                 },
                 Op::IncrCounter => {
-                    ldaddal(cb, insn.opnds[0].into(), insn.opnds[0].into(), insn.opnds[1].into());
+                    ldaddal(cb, insn.opnds[1].into(), insn.opnds[1].into(), insn.opnds[0].into());
                 },
                 Op::Breakpoint => {
                     brk(cb, A64Opnd::None);
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]