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

ruby-changes:73233

From: Zack <ko1@a...>
Date: Tue, 30 Aug 2022 01:03:28 +0900 (JST)
Subject: [ruby-changes:73233] dea4238544 (master): Port gen_concatstring to new backend IR (https://github.com/Shopify/ruby/pull/350)

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

From dea42385440c7abc332d8fda04dbec0f33364baa Mon Sep 17 00:00:00 2001
From: Zack Deveau <zack.ref@g...>
Date: Tue, 2 Aug 2022 13:09:51 -0400
Subject: Port gen_concatstring to new backend IR
 (https://github.com/Shopify/ruby/pull/350)

* Port gen_concatstring to new backend IR

* Update yjit/src/codegen.rs

Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@g...>
---
 bootstraptest/test_yjit.rb |  8 ++++++++
 yjit/src/codegen.rs        | 19 ++++++++++---------
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index b8374746f7..2409306106 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -3103,3 +3103,11 @@ assert_equal '/true/', %q{ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_yjit.rb#L3103
     end
     foo().inspect
 }
+
+# concatstrings
+assert_equal '9001', %q{
+    def foo()
+      "#{9001}"
+    end
+    foo()
+}
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index 36cdd55573..d75484a5df 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -2278,32 +2278,33 @@ fn gen_checktype( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L2278
     }
 }
 
-/*
+
 fn gen_concatstrings(
     jit: &mut JITState,
     ctx: &mut Context,
-    cb: &mut CodeBlock,
+    asm: &mut Assembler,
     _ocb: &mut OutlinedCb,
 ) -> CodegenStatus {
     let n = 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);
 
     let values_ptr = ctx.sp_opnd(-((SIZEOF_VALUE as isize) * n.as_isize()));
 
     // call rb_str_concat_literals(long n, const VALUE *strings);
-    mov(cb, C_ARG_REGS[0], imm_opnd(n.into()));
-    lea(cb, C_ARG_REGS[1], values_ptr);
-    call_ptr(cb, REG0, rb_str_concat_literals as *const u8);
+    let return_value = asm.ccall(
+        rb_str_concat_literals as *const u8,
+        vec![Opnd::UImm(n.into()), values_ptr]
+    );
 
     ctx.stack_pop(n.as_usize());
     let stack_ret = ctx.stack_push(Type::CString);
-    mov(cb, stack_ret, RAX);
+    asm.mov(stack_ret, return_value);
 
     KeepCompiling
 }
-*/
+
 
 fn guard_two_fixnums(ctx: &mut Context, asm: &mut Assembler, side_exit: CodePtr) {
     // Get the stack operand types
@@ -6015,8 +6016,8 @@ fn get_gen_fn(opcode: VALUE) -> Option<InsnGenFn> { https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L6016
         //YARVINSN_expandarray => Some(gen_expandarray),
         YARVINSN_defined => Some(gen_defined),
         YARVINSN_checkkeyword => Some(gen_checkkeyword),
-        /*
         YARVINSN_concatstrings => Some(gen_concatstrings),
+        /*
         YARVINSN_getinstancevariable => Some(gen_getinstancevariable),
         YARVINSN_setinstancevariable => Some(gen_setinstancevariable),
 
-- 
cgit v1.2.1


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

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