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

ruby-changes:68965

From: John <ko1@a...>
Date: Thu, 21 Oct 2021 08:19:29 +0900 (JST)
Subject: [ruby-changes:68965] ed636b59ed (master): Add duparray to YJIT codegen

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

From ed636b59edf18199c9a3477bfb7b514c7756778a Mon Sep 17 00:00:00 2001
From: John Hawthorn <john@h...>
Date: Mon, 7 Jun 2021 09:35:11 -0700
Subject: Add duparray to YJIT codegen

---
 yjit_codegen.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/yjit_codegen.c b/yjit_codegen.c
index 26a718ef32..d5291fc660 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -623,6 +623,28 @@ gen_newarray(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L623
     return YJIT_KEEP_COMPILING;
 }
 
+// dup array
+static codegen_status_t
+gen_duparray(jitstate_t* jit, ctx_t* ctx)
+{
+    VALUE ary = jit_get_arg(jit, 0);
+
+    // Save the PC and SP because we are allocating
+    jit_save_pc(jit, REG0);
+    jit_save_sp(jit, ctx);
+
+    // call rb_ary_resurrect(VALUE ary);
+    yjit_save_regs(cb);
+    jit_mov_gc_ptr(jit, cb, C_ARG_REGS[0], ary);
+    call_ptr(cb, REG0, (void *)rb_ary_resurrect);
+    yjit_load_regs(cb);
+
+    x86opnd_t stack_ret = ctx_stack_push(ctx, TYPE_ARRAY);
+    mov(cb, stack_ret, RAX);
+
+    return YJIT_KEEP_COMPILING;
+}
+
 // new hash initialized from top N values
 static codegen_status_t
 gen_newhash(jitstate_t* jit, ctx_t* ctx)
@@ -3033,6 +3055,7 @@ yjit_init_codegen(void) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L3055
     yjit_reg_op(BIN(pop), gen_pop);
     yjit_reg_op(BIN(adjuststack), gen_adjuststack);
     yjit_reg_op(BIN(newarray), gen_newarray);
+    yjit_reg_op(BIN(duparray), gen_duparray);
     yjit_reg_op(BIN(newhash), gen_newhash);
     yjit_reg_op(BIN(concatstrings), gen_concatstrings);
     yjit_reg_op(BIN(putnil), gen_putnil);
-- 
cgit v1.2.1


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

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