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

ruby-changes:73104

From: Maxime <ko1@a...>
Date: Tue, 30 Aug 2022 00:45:24 +0900 (JST)
Subject: [ruby-changes:73104] 5021f26b4b (master): Complete sketch for guard_object_is_heap

https://git.ruby-lang.org/ruby.git/commit/?id=5021f26b4b

From 5021f26b4ba270b2fc36a6fce7b4d54bb65b7062 Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Thu, 12 May 2022 14:31:17 -0400
Subject: Complete sketch for guard_object_is_heap

---
 yjit/src/ir.rs | 61 +++++++++++++++-------------------------------------------
 1 file changed, 15 insertions(+), 46 deletions(-)

diff --git a/yjit/src/ir.rs b/yjit/src/ir.rs
index f206d5c392..fde942212d 100644
--- a/yjit/src/ir.rs
+++ b/yjit/src/ir.rs
@@ -8,32 +8,6 @@ use crate::virtualmem::{CodePtr}; https://github.com/ruby/ruby/blob/trunk/yjit/src/ir.rs#L8
 use crate::asm::x86_64::{X86Opnd, X86Imm, X86UImm, X86Reg, X86Mem, RegType};
 use crate::core::{Context, Type, TempMapping};
 
-
-
-
-/*
-// Minimally, we might want to specify how many operands and branch targets an insn has
-// Branch targets are not interchangeable with other operand types. We distinguish
-// between branch and regular instructions.
-//
-// TODO: should mark instructions that produce no output operand
-//
-make_ops! {
-    (Comment, 1, 0),
-    ...
-
-    // Call is variadic, might need to be special-cased
-}
-*/
-
-
-
-
-
-
-
-
-
 /// Instruction opcodes
 #[derive(Copy, Clone, PartialEq, Eq, Debug)]
 pub enum Op
@@ -80,8 +54,12 @@ pub enum Op https://github.com/ruby/ruby/blob/trunk/yjit/src/ir.rs#L54
     // Bitwise AND test instruction
     Test,
 
-    // Jump if not zero
+    // Compare two operands
+    Cmp,
+
+    // Low-level conditional jump instructions
     Jnz,
+    Jbe,
 
     /*
     // The following are conditional jump instructions. They all accept as their
@@ -128,12 +106,6 @@ pub enum Op https://github.com/ruby/ruby/blob/trunk/yjit/src/ir.rs#L106
     // be returned from the generated function.
     RetVal,
 
-    // A low-level cmp instruction. It accepts two operands. The first it
-    // expects to be a register. The second can be anything. Most of the time
-    // this instruction shouldn't be used by the developer since other
-    // instructions break down to this one.
-    Cmp,
-
     // A conditional move instruction that should be preceeded at some point by
     // an OP_CMP instruction that would have set the requisite comparison flags.
     // Accepts 2 operands, both of which are expected to be of the EIR_REG type.
@@ -195,15 +167,6 @@ pub enum Op https://github.com/ruby/ruby/blob/trunk/yjit/src/ir.rs#L167
     */
 }
 
-
-
-
-
-
-
-
-
-
 // Register value used by IR operands
 #[derive(Copy, Clone, PartialEq, Eq, Debug)]
 pub struct Reg
@@ -418,6 +381,11 @@ impl Assembler https://github.com/ruby/ruby/blob/trunk/yjit/src/ir.rs#L381
     {
         self.push_insn(Op::Jnz, vec![], Some(target));
     }
+
+    fn jbe(&mut self, target: Target)
+    {
+        self.push_insn(Op::Jbe, vec![], Some(target));
+    }
 }
 
 macro_rules! def_push_2_opnd {
@@ -447,8 +415,9 @@ macro_rules! def_push_2_opnd_no_out { https://github.com/ruby/ruby/blob/trunk/yjit/src/ir.rs#L415
 def_push_2_opnd!(add, Op::Add);
 def_push_2_opnd!(sub, Op::Sub);
 def_push_2_opnd!(and, Op::And);
-def_push_2_opnd_no_out!(test, Op::Test);
 def_push_2_opnd_no_out!(mov, Op::Mov);
+def_push_2_opnd_no_out!(cmp, Op::Cmp);
+def_push_2_opnd_no_out!(test, Op::Test);
 
 // NOTE: these methods are temporary and will likely move
 // to context.rs later
@@ -496,12 +465,12 @@ mod tests { https://github.com/ruby/ruby/blob/trunk/yjit/src/ir.rs#L465
         asm.comment("guard object is heap");
 
         // Test that the object is not an immediate
-        asm.test(object_opnd, Opnd::UImm(RUBY_IMMEDIATE_MASK as u64));
+        asm.test(object_opnd.clone(), Opnd::UImm(RUBY_IMMEDIATE_MASK as u64));
         asm.jnz(Target::CodePtr(side_exit));
 
         // Test that the object is not false or nil
-        //cmp(cb, object_opnd, uimm_opnd(Qnil.into()));
-        //jbe_ptr(cb, side_exit);
+        asm.cmp(object_opnd.clone(), Opnd::UImm(Qnil.into()));
+        asm.jbe(Target::CodePtr(side_exit));
     }
 
     #[test]
-- 
cgit v1.2.1


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

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