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

ruby-changes:73254

From: Takashi <ko1@a...>
Date: Tue, 30 Aug 2022 01:05:10 +0900 (JST)
Subject: [ruby-changes:73254] dcb6fc16e5 (master): Port opt_mod to the new backend IR (https://github.com/Shopify/ruby/pull/363)

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

From dcb6fc16e54b83f9653bbab68ec1770b301952a0 Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Fri, 5 Aug 2022 08:21:52 -0700
Subject: Port opt_mod to the new backend IR
 (https://github.com/Shopify/ruby/pull/363)

---
 yjit/src/codegen.rs | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index ca5958723e..33524c160f 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -2971,16 +2971,15 @@ fn gen_opt_div( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L2971
     gen_opt_send_without_block(jit, ctx, asm, ocb)
 }
 
-/*
 fn gen_opt_mod(
     jit: &mut JITState,
     ctx: &mut Context,
-    cb: &mut CodeBlock,
+    asm: &mut Assembler,
     ocb: &mut OutlinedCb,
 ) -> CodegenStatus {
     // Defer compilation so we can specialize on a runtime `self`
     if !jit_at_current_insn(jit) {
-        defer_compilation(jit, ctx, cb, ocb);
+        defer_compilation(jit, ctx, asm, ocb);
         return EndBlock;
     }
 
@@ -2997,33 +2996,29 @@ fn gen_opt_mod( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L2996
         }
 
         // Check that both operands are fixnums
-        guard_two_fixnums(ctx, cb, side_exit);
+        guard_two_fixnums(ctx, asm, side_exit);
 
         // Get the operands and destination from the stack
         let arg1 = ctx.stack_pop(1);
         let arg0 = ctx.stack_pop(1);
 
-        mov(cb, C_ARG_REGS[0], arg0);
-        mov(cb, C_ARG_REGS[1], arg1);
-
         // Check for arg0 % 0
-        cmp(cb, C_ARG_REGS[1], imm_opnd(VALUE::fixnum_from_usize(0).as_i64()));
-        je_ptr(cb, side_exit);
+        asm.cmp(arg1, Opnd::Imm(VALUE::fixnum_from_usize(0).as_i64()));
+        asm.je(side_exit.into());
 
         // Call rb_fix_mod_fix(VALUE recv, VALUE obj)
-        call_ptr(cb, REG0, rb_fix_mod_fix as *const u8);
+        let ret = asm.ccall(rb_fix_mod_fix as *const u8, vec![arg0, arg1]);
 
         // Push the return value onto the stack
         let stack_ret = ctx.stack_push(Type::Unknown);
-        mov(cb, stack_ret, RAX);
+        asm.mov(stack_ret, ret);
 
         KeepCompiling
     } else {
         // Delegate to send, call the method on the recv
-        gen_opt_send_without_block(jit, ctx, cb, ocb)
+        gen_opt_send_without_block(jit, ctx, asm, ocb)
     }
 }
-*/
 
 fn gen_opt_ltlt(
     jit: &mut JITState,
@@ -5976,11 +5971,9 @@ fn get_gen_fn(opcode: VALUE) -> Option<InsnGenFn> { https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L5971
         YARVINSN_opt_le => Some(gen_opt_le),
         YARVINSN_opt_gt => Some(gen_opt_gt),
         YARVINSN_opt_ge => Some(gen_opt_ge),
-        /*
         YARVINSN_opt_mod => Some(gen_opt_mod),
-        YARVINSN_opt_str_freeze => Some(gen_opt_str_freeze),
-        YARVINSN_opt_str_uminus => Some(gen_opt_str_uminus),
-        */
+        //YARVINSN_opt_str_freeze => Some(gen_opt_str_freeze),
+        //YARVINSN_opt_str_uminus => Some(gen_opt_str_uminus),
         YARVINSN_splatarray => Some(gen_splatarray),
         YARVINSN_newrange => Some(gen_newrange),
         YARVINSN_putstring => Some(gen_putstring),
-- 
cgit v1.2.1


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

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