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

ruby-changes:73178

From: Maxime <ko1@a...>
Date: Tue, 30 Aug 2022 00:58:00 +0900 (JST)
Subject: [ruby-changes:73178] 580f26959e (master): Get started on branchunless port

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

From 580f26959eb31d523ac21d640e21ddbe70779512 Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Thu, 7 Jul 2022 12:35:18 -0400
Subject: Get started on branchunless port

---
 yjit/src/backend/ir.rs |  6 ++++++
 yjit/src/codegen.rs    | 29 +++++++++++++++++++++--------
 2 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/yjit/src/backend/ir.rs b/yjit/src/backend/ir.rs
index bdefe1c6bc..2d68936db1 100644
--- a/yjit/src/backend/ir.rs
+++ b/yjit/src/backend/ir.rs
@@ -251,6 +251,12 @@ impl From<u64> for Opnd { https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/ir.rs#L251
     }
 }
 
+impl From<i64> for Opnd {
+    fn from(value: i64) -> Self {
+        Opnd::Imm(value.try_into().unwrap())
+    }
+}
+
 impl From<i32> for Opnd {
     fn from(value: i32) -> Self {
         Opnd::Imm(value.try_into().unwrap())
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index 6c8fd950a6..06c7756c7a 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -3256,19 +3256,20 @@ fn gen_branchif( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L3256
 
     EndBlock
 }
+*/
 
 fn gen_branchunless_branch(
-    cb: &mut CodeBlock,
+    asm: &mut Assembler,
     target0: CodePtr,
     target1: Option<CodePtr>,
     shape: BranchShape,
 ) {
     match shape {
-        BranchShape::Next0 => jnz_ptr(cb, target1.unwrap()),
-        BranchShape::Next1 => jz_ptr(cb, target0),
+        BranchShape::Next0 => asm.jnz(target1.unwrap().into()),
+        BranchShape::Next1 => asm.jz(target0.into()),
         BranchShape::Default => {
-            jz_ptr(cb, target0);
-            jmp_ptr(cb, target1.unwrap());
+            asm.jz(target0.into());
+            asm.jmp(target1.unwrap().into());
         }
     }
 }
@@ -3276,7 +3277,7 @@ fn gen_branchunless_branch( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L3277
 fn gen_branchunless(
     jit: &mut JITState,
     ctx: &mut Context,
-    cb: &mut CodeBlock,
+    asm: &mut Assembler,
     ocb: &mut OutlinedCb,
 ) -> CodegenStatus {
     let jump_offset = jit_get_arg(jit, 0).as_i32();
@@ -3284,14 +3285,15 @@ fn gen_branchunless( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L3285
     // Check for interrupts, but only on backward branches that may create loops
     if jump_offset < 0 {
         let side_exit = get_side_exit(jit, ocb, ctx);
-        gen_check_ints(cb, side_exit);
+        gen_check_ints(asm, side_exit);
     }
 
     // Test if any bit (outside of the Qnil bit) is on
     // RUBY_Qfalse  /* ...0000 0000 */
     // RUBY_Qnil    /* ...0000 1000 */
     let val_opnd = ctx.stack_pop(1);
-    test(cb, val_opnd, imm_opnd(!Qnil.as_i64()));
+    let not_qnil = !Qnil.as_i64();
+    asm.test(val_opnd, not_qnil.into());
 
     // Get the branch target instruction offsets
     let next_idx = jit_next_insn_idx(jit) as i32;
@@ -3305,6 +3307,13 @@ fn gen_branchunless( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L3307
         idx: jump_idx.try_into().unwrap(),
     };
 
+
+
+
+    // TODO: port gen_branch logic
+    todo!("complete branchunless implementation");
+
+    /*
     // Generate the branch instructions
     gen_branch(
         jit,
@@ -3319,8 +3328,12 @@ fn gen_branchunless( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L3328
     );
 
     EndBlock
+    */
+
+
 }
 
+/*
 fn gen_branchnil_branch(
     cb: &mut CodeBlock,
     target0: CodePtr,
-- 
cgit v1.2.1


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

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