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

ruby-changes:68903

From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:15:40 +0900 (JST)
Subject: [ruby-changes:68903] 5c2f74fc32 (master): Fix encoding of test x86 instruction

https://git.ruby-lang.org/ruby.git/commit/?id=5c2f74fc32

From 5c2f74fc32951fc038dca465985a4859c517ef47 Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Tue, 11 May 2021 16:33:28 -0400
Subject: Fix encoding of test x86 instruction

---
 yjit_asm.c       | 10 +++++++++-
 yjit_asm_tests.c |  2 ++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/yjit_asm.c b/yjit_asm.c
index c47e1fd274..76fc3bf8db 100644
--- a/yjit_asm.c
+++ b/yjit_asm.c
@@ -1664,7 +1664,15 @@ void test(codeblock_t* cb, x86opnd_t rm_opnd, x86opnd_t test_opnd) https://github.com/ruby/ruby/blob/trunk/yjit_asm.c#L1664
     else
     {
         assert (test_opnd.num_bits == rm_opnd.num_bits);
-        cb_write_rm(cb, false, rm_opnd.num_bits == 64, test_opnd, rm_opnd, 0xFF, 1, 0x85);
+
+        if (rm_opnd.num_bits == 8)
+        {
+            cb_write_rm(cb, false, false, test_opnd, rm_opnd, 0xFF, 1, 0x84);
+        }
+        else
+        {
+            cb_write_rm(cb, rm_opnd.num_bits == 16, rm_opnd.num_bits == 64, test_opnd, rm_opnd, 0xFF, 1, 0x85);
+        }
     }
 }
 
diff --git a/yjit_asm_tests.c b/yjit_asm_tests.c
index da58bdd3b5..7fc40d497b 100644
--- a/yjit_asm_tests.c
+++ b/yjit_asm_tests.c
@@ -323,6 +323,8 @@ void run_tests() https://github.com/ruby/ruby/blob/trunk/yjit_asm_tests.c#L323
     cb_set_pos(cb, 0); sub(cb, RAX, imm_opnd(2)); check_bytes(cb, "4883E802");
 
     // test
+    cb_set_pos(cb, 0); test(cb, AL, AL); check_bytes(cb, "84C0");
+    cb_set_pos(cb, 0); test(cb, AX, AX); check_bytes(cb, "6685C0");
     cb_set_pos(cb, 0); test(cb, CL, imm_opnd(8)); check_bytes(cb, "F6C108");
     cb_set_pos(cb, 0); test(cb, DL, imm_opnd(7)); check_bytes(cb, "F6C207");
     cb_set_pos(cb, 0); test(cb, RCX, imm_opnd(8)); check_bytes(cb, "F6C108");
-- 
cgit v1.2.1


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

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