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

ruby-changes:73293

From: Zack <ko1@a...>
Date: Tue, 30 Aug 2022 01:08:03 +0900 (JST)
Subject: [ruby-changes:73293] cb15886e61 (master): Port opt_getinlinecache to the new backend (https://github.com/Shopify/ruby/pull/399)

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

From cb15886e612e17685e606f8b4f04301026f18b46 Mon Sep 17 00:00:00 2001
From: Zack Deveau <zack.ref@g...>
Date: Thu, 11 Aug 2022 12:49:35 -0400
Subject: Port opt_getinlinecache to the new backend
 (https://github.com/Shopify/ruby/pull/399)

---
 yjit/src/codegen.rs | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index 047fb89cfb..def3d38cbf 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -5475,11 +5475,10 @@ fn gen_setclassvariable( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L5475
     KeepCompiling
 }
 
-/*
 fn gen_opt_getinlinecache(
     jit: &mut JITState,
     ctx: &mut Context,
-    cb: &mut CodeBlock,
+    asm: &mut Assembler,
     ocb: &mut OutlinedCb,
 ) -> CodegenStatus {
     let jump_offset = jit_get_arg(jit, 0);
@@ -5498,25 +5497,35 @@ fn gen_opt_getinlinecache( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L5497
     // to invalidate this block from yjit_constant_ic_update().
     jit_ensure_block_entry_exit(jit, ocb);
 
+    let inline_cache = Opnd::const_ptr(ic as *const u8);
     if !unsafe { (*ice).ic_cref }.is_null() {
         // Cache is keyed on a certain lexical scope. Use the interpreter's cache.
         let side_exit = get_side_exit(jit, ocb, ctx);
 
         // Call function to verify the cache. It doesn't allocate or call methods.
-        mov(cb, C_ARG_REGS[0], const_ptr_opnd(ic as *const u8));
-        mov(cb, C_ARG_REGS[1], mem_opnd(64, REG_CFP, RUBY_OFFSET_CFP_EP));
-        call_ptr(cb, REG0, rb_vm_ic_hit_p as *const u8);
+        let ret_val = asm.ccall(
+            rb_vm_ic_hit_p as *const u8,
+            vec![inline_cache, Opnd::mem(64, CFP, RUBY_OFFSET_CFP_EP)]
+        );
 
         // Check the result. _Bool is one byte in SysV.
-        test(cb, AL, AL);
-        jz_ptr(cb, counted_exit!(ocb, side_exit, opt_getinlinecache_miss));
+        asm.test(ret_val, ret_val);
+        asm.jz(counted_exit!(ocb, side_exit, opt_getinlinecache_miss).into());
+
+        let inline_cache_entry = Opnd::mem(
+            64,
+            inline_cache,
+            RUBY_OFFSET_IC_ENTRY
+        );
+        let inline_cache_entry_val = Opnd::mem(
+            64,
+            inline_cache_entry,
+            RUBY_OFFSET_ICE_VALUE
+        );
 
         // Push ic->entry->value
-        mov(cb, REG0, const_ptr_opnd(ic as *mut u8));
-        mov(cb, REG0, mem_opnd(64, REG0, RUBY_OFFSET_IC_ENTRY));
         let stack_top = ctx.stack_push(Type::Unknown);
-        mov(cb, REG0, mem_opnd(64, REG0, RUBY_OFFSET_ICE_VALUE));
-        mov(cb, stack_top, REG0);
+        asm.mov(stack_top, inline_cache_entry_val);
     } else {
         // Optimize for single ractor mode.
         // FIXME: This leaks when st_insert raises NoMemoryError
@@ -5528,7 +5537,7 @@ fn gen_opt_getinlinecache( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L5537
         // constants referenced within the current block.
         assume_stable_constant_names(jit, ocb);
 
-        jit_putobject(jit, ctx, cb, unsafe { (*ice).value });
+        jit_putobject(jit, ctx, asm, unsafe { (*ice).value });
     }
 
     // Jump over the code for filling the cache
@@ -5540,11 +5549,11 @@ fn gen_opt_getinlinecache( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L5549
             iseq: jit.iseq,
             idx: jump_idx,
         },
-        cb,
+        asm,
     );
     EndBlock
 }
-*/
+
 
 // Push the explicit block parameter onto the temporary stack. Part of the
 // interpreter's scheme for avoiding Proc allocations when delegating
@@ -5873,7 +5882,7 @@ fn get_gen_fn(opcode: VALUE) -> Option<InsnGenFn> { https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L5882
         YARVINSN_opt_size => Some(gen_opt_size),
         YARVINSN_opt_length => Some(gen_opt_length),
         YARVINSN_opt_regexpmatch2 => Some(gen_opt_regexpmatch2),
-        //YARVINSN_opt_getinlinecache => Some(gen_opt_getinlinecache),
+        YARVINSN_opt_getinlinecache => Some(gen_opt_getinlinecache),
         YARVINSN_invokebuiltin => Some(gen_invokebuiltin),
         YARVINSN_opt_invokebuiltin_delegate => Some(gen_opt_invokebuiltin_delegate),
         YARVINSN_opt_invokebuiltin_delegate_leave => Some(gen_opt_invokebuiltin_delegate),
-- 
cgit v1.2.1


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

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