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

ruby-changes:73215

From: Noah <ko1@a...>
Date: Tue, 30 Aug 2022 01:03:00 +0900 (JST)
Subject: [ruby-changes:73215] b1ed4d9b94 (master): Port and test duparray and splatarray (https://github.com/Shopify/ruby/pull/337)

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

From b1ed4d9b947e650dda7bfb9578652d4edb2608b4 Mon Sep 17 00:00:00 2001
From: Noah Gibbs <the.codefolio.guy@g...>
Date: Fri, 22 Jul 2022 17:08:35 +0100
Subject: Port and test duparray and splatarray
 (https://github.com/Shopify/ruby/pull/337)

* Port duparray opcode

* Port and test splatarray
---
 yjit/src/codegen.rs | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index 9f39c77bb6..fa0394eed5 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -1181,29 +1181,29 @@ fn gen_newarray( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L1181
     KeepCompiling
 }
 
-/*
 // dup array
 fn gen_duparray(
     jit: &mut JITState,
     ctx: &mut Context,
-    cb: &mut CodeBlock,
+    asm: &mut Assembler,
     _ocb: &mut OutlinedCb,
 ) -> CodegenStatus {
     let ary = jit_get_arg(jit, 0);
 
     // Save the PC and SP because we are allocating
-    jit_prepare_routine_call(jit, ctx, cb, REG0);
+    jit_prepare_routine_call(jit, ctx, asm);
 
     // call rb_ary_resurrect(VALUE ary);
-    jit_mov_gc_ptr(jit, cb, C_ARG_REGS[0], ary);
-    call_ptr(cb, REG0, rb_ary_resurrect as *const u8);
+    let new_ary = asm.ccall(
+        rb_ary_resurrect as *const u8,
+        vec![ary.into()],
+    );
 
     let stack_ret = ctx.stack_push(Type::Array);
-    mov(cb, stack_ret, RAX);
+    asm.mov(stack_ret, new_ary);
 
     KeepCompiling
 }
-*/
 
 // dup hash
 fn gen_duphash(
@@ -1226,34 +1226,30 @@ fn gen_duphash( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L1226
     KeepCompiling
 }
 
-/*
 // call to_a on the array on the stack
 fn gen_splatarray(
     jit: &mut JITState,
     ctx: &mut Context,
-    cb: &mut CodeBlock,
+    asm: &mut Assembler,
     _ocb: &mut OutlinedCb,
 ) -> CodegenStatus {
     let flag = jit_get_arg(jit, 0);
 
     // Save the PC and SP because the callee may allocate
     // Note that this modifies REG_SP, which is why we do it first
-    jit_prepare_routine_call(jit, ctx, cb, REG0);
+    jit_prepare_routine_call(jit, ctx, asm);
 
     // Get the operands from the stack
     let ary_opnd = ctx.stack_pop(1);
 
     // Call rb_vm_splat_array(flag, ary)
-    jit_mov_gc_ptr(jit, cb, C_ARG_REGS[0], flag);
-    mov(cb, C_ARG_REGS[1], ary_opnd);
-    call_ptr(cb, REG1, rb_vm_splat_array as *const u8);
+    let ary = asm.ccall(rb_vm_splat_array as *const u8, vec![flag.into(), ary_opnd]);
 
     let stack_ret = ctx.stack_push(Type::Array);
-    mov(cb, stack_ret, RAX);
+    asm.mov(stack_ret, ary);
 
     KeepCompiling
 }
-*/
 
 // new range initialized from top 2 values
 fn gen_newrange(
@@ -5988,7 +5984,7 @@ fn get_gen_fn(opcode: VALUE) -> Option<InsnGenFn> { https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L5984
         YARVINSN_newhash => Some(gen_newhash),
         YARVINSN_duphash => Some(gen_duphash),
         YARVINSN_newarray => Some(gen_newarray),
-        //YARVINSN_duparray => Some(gen_duparray),
+        YARVINSN_duparray => Some(gen_duparray),
         //YARVINSN_checktype => Some(gen_checktype),
         YARVINSN_opt_lt => Some(gen_opt_lt),
         /*
@@ -5998,8 +5994,8 @@ fn get_gen_fn(opcode: VALUE) -> Option<InsnGenFn> { https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L5994
         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_splatarray => Some(gen_splatarray),
         */
+        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/

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