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

ruby-changes:73114

From: Maxime <ko1@a...>
Date: Tue, 30 Aug 2022 00:51:38 +0900 (JST)
Subject: [ruby-changes:73114] 0032b02045 (master): Add gen_dupn

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

From 0032b02045af081df30f35b508b6b790e44fcdc2 Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Tue, 24 May 2022 12:03:21 -0400
Subject: Add gen_dupn

---
 yjit/src/backend/ir.rs |  4 ++++
 yjit/src/codegen.rs    | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/yjit/src/backend/ir.rs b/yjit/src/backend/ir.rs
index 22350ec506..932ba9f0be 100644
--- a/yjit/src/backend/ir.rs
+++ b/yjit/src/backend/ir.rs
@@ -631,6 +631,10 @@ def_push_2_opnd_no_out!(test, Op::Test); https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/ir.rs#L631
 // They are just wrappers to convert from X86Opnd into the IR Opnd type
 impl Context
 {
+    pub fn ir_stack_opnd(&mut self, idx: i32) -> Opnd {
+        self.stack_opnd(idx).into()
+    }
+
     pub fn ir_stack_pop(&mut self, n: usize) -> Opnd {
         self.stack_pop(n).into()
     }
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index 1799036e46..834b75192a 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -932,6 +932,7 @@ fn gen_dup( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L932
 
 
 
+/*
 // duplicate stack top n elements
 fn gen_dupn(
     jit: &mut JITState,
@@ -963,6 +964,53 @@ fn gen_dupn( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L964
 
     KeepCompiling
 }
+*/
+
+
+// duplicate stack top n elements
+fn gen_dupn(
+    jit: &mut JITState,
+    ctx: &mut Context,
+    cb: &mut CodeBlock,
+    _ocb: &mut OutlinedCb,
+) -> CodegenStatus {
+
+    let mut asm = Assembler::new();
+
+    let nval: VALUE = jit_get_arg(jit, 0);
+    let VALUE(n) = nval;
+
+    // In practice, seems to be only used for n==2
+    if n != 2 {
+        return CantCompile;
+    }
+
+    let opnd1: Opnd = ctx.ir_stack_opnd(1);
+    let opnd0: Opnd = ctx.ir_stack_opnd(0);
+
+    let mapping1 = ctx.get_opnd_mapping(StackOpnd(1));
+    let mapping0 = ctx.get_opnd_mapping(StackOpnd(0));
+
+    let dst1: Opnd = ctx.ir_stack_push_mapping(mapping1);
+    asm.mov(dst1, opnd1);
+
+    let dst0: Opnd = ctx.ir_stack_push_mapping(mapping0);
+    asm.mov(dst0, opnd0);
+
+    asm.compile(cb);
+
+    KeepCompiling
+}
+
+
+
+
+
+
+
+
+
+
 
 // Swap top 2 stack entries
 fn gen_swap(
-- 
cgit v1.2.1


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

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