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

ruby-changes:73160

From: Maxime <ko1@a...>
Date: Tue, 30 Aug 2022 00:57:23 +0900 (JST)
Subject: [ruby-changes:73160] 4c0a440b18 (master): Port over duphash and newarray

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

From 4c0a440b1828fd1cc1dba24ae1d0a384e98859aa Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Tue, 21 Jun 2022 11:30:08 -0400
Subject: Port over duphash and newarray

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

diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index 291851c02e..c99fef5b0c 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -513,7 +513,7 @@ fn gen_full_cfunc_return(ocb: &mut OutlinedCb) -> CodePtr { https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L513
     let code_ptr = ocb.get_write_ptr();
     let mut asm = Assembler::new();
 
-    // This chunk of code expect REG_EC to be filled properly and
+    // This chunk of code expects REG_EC to be filled properly and
     // RAX to contain the return value of the C method.
 
     // Call full_cfunc_return()
@@ -759,14 +759,16 @@ pub fn gen_single_block( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L759
 
         // If previous instruction requested to record the boundary
         if jit.record_boundary_patch_point {
-            todo!("record_boundary_patch_point");
 
-            /*
+            // FIXME: is this sound with the new assembler?
+
             // Generate an exit to this instruction and record it
-            let exit_pos = gen_exit(jit.pc, &ctx, ocb.unwrap());
+            let exit_pos = gen_outlined_exit(jit.pc, &ctx, ocb);
             record_global_inval_patch(cb, exit_pos);
             jit.record_boundary_patch_point = false;
-            */
+
+
+
         }
 
         // In debug mode, verify our existing assumption
@@ -1146,36 +1148,40 @@ fn gen_opt_plus( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L1148
 }
 */
 
-/*
 // new array initialized from top N values
 fn gen_newarray(
     jit: &mut JITState,
     ctx: &mut Context,
-    cb: &mut CodeBlock,
+    asm: &mut Assembler,
     _ocb: &mut OutlinedCb,
 ) -> CodegenStatus {
     let n = jit_get_arg(jit, 0).as_u32();
 
     // Save the PC and SP because we are allocating
-    jit_prepare_routine_call(jit, ctx, cb, REG0);
+    jit_prepare_routine_call(jit, ctx, asm);
 
     let offset_magnitude = SIZEOF_VALUE as u32 * n;
-    let values_ptr = ctx.sp_opnd(-(offset_magnitude as isize));
+    let values_opnd = ctx.sp_opnd(-(offset_magnitude as isize));
+    let values_ptr = asm.lea(values_opnd);
 
     // call rb_ec_ary_new_from_values(struct rb_execution_context_struct *ec, long n, const VALUE *elts);
-    mov(cb, C_ARG_REGS[0], REG_EC);
-    mov(cb, C_ARG_REGS[1], imm_opnd(n.into()));
-    lea(cb, C_ARG_REGS[2], values_ptr);
-    call_ptr(cb, REG0, rb_ec_ary_new_from_values as *const u8);
+    let new_ary = asm.ccall(
+        rb_ec_ary_new_from_values as *const u8,
+        vec![
+            EC,
+            Opnd::UImm(n.into()),
+            values_ptr
+        ]
+    );
 
     ctx.stack_pop(n.as_usize());
     let stack_ret = ctx.stack_push(Type::Array);
-    mov(cb, stack_ret, RAX);
+    asm.mov(stack_ret, new_ary);
 
     KeepCompiling
 }
 
-
+/*
 // dup array
 fn gen_duparray(
     jit: &mut JITState,
@@ -1197,46 +1203,30 @@ fn gen_duparray( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L1203
 
     KeepCompiling
 }
-
-
-
-
-/*
-let mut asm = Assembler::new();
-
-//asm.ccall(rb_ary_resurrect as *const u8, vec![ary]);
-
-asm.compile(cb);
 */
 
-
-
-
-
-
-
 // dup hash
 fn gen_duphash(
     jit: &mut JITState,
     ctx: &mut Context,
-    cb: &mut CodeBlock,
+    asm: &mut Assembler,
     _ocb: &mut OutlinedCb,
 ) -> CodegenStatus {
     let hash = 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_hash_resurrect(VALUE hash);
-    jit_mov_gc_ptr(jit, cb, C_ARG_REGS[0], hash);
-    call_ptr(cb, REG0, rb_hash_resurrect as *const u8);
+    let hash = asm.ccall(rb_hash_resurrect as *const u8, vec![hash.into()]);
 
     let stack_ret = ctx.stack_push(Type::Hash);
-    mov(cb, stack_ret, RAX);
+    asm.mov(stack_ret, hash);
 
     KeepCompiling
 }
 
+/*
 // call to_a on the array on the stack
 fn gen_splatarray(
     jit: &mut JITState,
@@ -5982,8 +5972,10 @@ fn get_gen_fn(opcode: VALUE) -> Option<InsnGenFn> { https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L5972
         YARVINSN_opt_and => Some(gen_opt_and),
         YARVINSN_opt_or => Some(gen_opt_or),
         YARVINSN_newhash => Some(gen_newhash),
+        */
         YARVINSN_duphash => Some(gen_duphash),
         YARVINSN_newarray => Some(gen_newarray),
+        /*
         YARVINSN_duparray => Some(gen_duparray),
         YARVINSN_checktype => Some(gen_checktype),
         YARVINSN_opt_lt => Some(gen_opt_lt),
-- 
cgit v1.2.1


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

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