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

ruby-changes:73240

From: Takashi <ko1@a...>
Date: Tue, 30 Aug 2022 01:03:29 +0900 (JST)
Subject: [ruby-changes:73240] a674b8d8a1 (master): Port class variable instructions (https://github.com/Shopify/ruby/pull/346)

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

From a674b8d8a13c9dbffb92dbcab7ff297a8b99591b Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Mon, 1 Aug 2022 10:34:15 -0700
Subject: Port class variable instructions
 (https://github.com/Shopify/ruby/pull/346)

---
 yjit/src/codegen.rs | 50 ++++++++++++++++++++++++++++----------------------
 1 file changed, 28 insertions(+), 22 deletions(-)

diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index 940ffed3df..73d76759a6 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -5525,26 +5525,29 @@ fn gen_getspecial( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L5525
         KeepCompiling
     }
 }
+*/
 
 fn gen_getclassvariable(
     jit: &mut JITState,
     ctx: &mut Context,
-    cb: &mut CodeBlock,
+    asm: &mut Assembler,
     _ocb: &mut OutlinedCb,
 ) -> CodegenStatus {
     // rb_vm_getclassvariable can raise exceptions.
-    jit_prepare_routine_call(jit, ctx, cb, REG0);
-
-    let cfp_iseq_opnd = mem_opnd(64, REG_CFP, RUBY_OFFSET_CFP_ISEQ);
-    mov(cb, C_ARG_REGS[0], cfp_iseq_opnd);
-    mov(cb, C_ARG_REGS[1], REG_CFP);
-    mov(cb, C_ARG_REGS[2], uimm_opnd(jit_get_arg(jit, 0).as_u64()));
-    mov(cb, C_ARG_REGS[3], uimm_opnd(jit_get_arg(jit, 1).as_u64()));
+    jit_prepare_routine_call(jit, ctx, asm);
 
-    call_ptr(cb, REG0, rb_vm_getclassvariable as *const u8);
+    let val_opnd = asm.ccall(
+        rb_vm_getclassvariable as *const u8,
+        vec![
+            Opnd::mem(64, CFP, RUBY_OFFSET_CFP_ISEQ),
+            CFP,
+            Opnd::UImm(jit_get_arg(jit, 0).as_u64()),
+            Opnd::UImm(jit_get_arg(jit, 1).as_u64()),
+        ],
+    );
 
-    let stack_top = ctx.stack_push(Type::Unknown);
-    mov(cb, stack_top, RAX);
+    let top = ctx.stack_push(Type::Unknown);
+    asm.mov(top, val_opnd);
 
     KeepCompiling
 }
@@ -5552,24 +5555,27 @@ fn gen_getclassvariable( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L5555
 fn gen_setclassvariable(
     jit: &mut JITState,
     ctx: &mut Context,
-    cb: &mut CodeBlock,
+    asm: &mut Assembler,
     _ocb: &mut OutlinedCb,
 ) -> CodegenStatus {
     // rb_vm_setclassvariable can raise exceptions.
-    jit_prepare_routine_call(jit, ctx, cb, REG0);
-
-    let cfp_iseq_opnd = mem_opnd(64, REG_CFP, RUBY_OFFSET_CFP_ISEQ);
-    mov(cb, C_ARG_REGS[0], cfp_iseq_opnd);
-    mov(cb, C_ARG_REGS[1], REG_CFP);
-    mov(cb, C_ARG_REGS[2], uimm_opnd(jit_get_arg(jit, 0).as_u64()));
-    mov(cb, C_ARG_REGS[3], ctx.stack_pop(1));
-    mov(cb, C_ARG_REGS[4], uimm_opnd(jit_get_arg(jit, 1).as_u64()));
+    jit_prepare_routine_call(jit, ctx, asm);
 
-    call_ptr(cb, REG0, rb_vm_setclassvariable as *const u8);
+    asm.ccall(
+        rb_vm_setclassvariable as *const u8,
+        vec![
+            Opnd::mem(64, CFP, RUBY_OFFSET_CFP_ISEQ),
+            CFP,
+            Opnd::UImm(jit_get_arg(jit, 0).as_u64()),
+            ctx.stack_pop(1),
+            Opnd::UImm(jit_get_arg(jit, 1).as_u64()),
+        ],
+    );
 
     KeepCompiling
 }
 
+/*
 fn gen_opt_getinlinecache(
     jit: &mut JITState,
     ctx: &mut Context,
@@ -6035,9 +6041,9 @@ fn get_gen_fn(opcode: VALUE) -> Option<InsnGenFn> { https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L6041
         YARVINSN_intern => Some(gen_intern),
         YARVINSN_toregexp => Some(gen_toregexp),
         YARVINSN_getspecial => Some(gen_getspecial),
+        */
         YARVINSN_getclassvariable => Some(gen_getclassvariable),
         YARVINSN_setclassvariable => Some(gen_setclassvariable),
-        */
 
         // Unimplemented opcode, YJIT won't generate code for this yet
         _ => None,
-- 
cgit v1.2.1


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

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