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

ruby-changes:73123

From: Maxime <ko1@a...>
Date: Tue, 30 Aug 2022 00:53:36 +0900 (JST)
Subject: [ruby-changes:73123] e22134277b (master): Remove x86_64 dependency in core.rs

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

From e22134277b81124ba2ce4cf3e08ad0983c0432c9 Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Tue, 7 Jun 2022 15:22:06 -0400
Subject: Remove x86_64 dependency in core.rs

---
 yjit/src/backend/x86_64/mod.rs |  3 ++-
 yjit/src/codegen.rs            |  4 ++--
 yjit/src/core.rs               | 41 +++++++++++++++++++++++++++--------------
 3 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/yjit/src/backend/x86_64/mod.rs b/yjit/src/backend/x86_64/mod.rs
index 4aa04b29aa..66f6beefc9 100644
--- a/yjit/src/backend/x86_64/mod.rs
+++ b/yjit/src/backend/x86_64/mod.rs
@@ -111,10 +111,11 @@ impl Assembler https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/x86_64/mod.rs#L111
 
                 Op::Store => mov(cb, insn.opnds[0].into(), insn.opnds[1].into()),
 
+                // This assumes only load instructions can contain references to GC'd Value operands
                 Op::Load => {
                     mov(cb, insn.out.into(), insn.opnds[0].into());
 
-                    // If the value being loaded is a heapp object
+                    // If the value being loaded is a heap object
                     if let Opnd::Value(val) = insn.opnds[0] {
                         if !val.special_const_p() {
                             // The pointer immediate is encoded as the last part of the mov written out
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index 3491391aa0..99436d5f06 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -426,7 +426,7 @@ fn gen_exit(exit_pc: *mut VALUE, ctx: &Context, cb: &mut CodeBlock) -> CodePtr { https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L426
     // Write the adjusted SP back into the CFP
     if ctx.get_sp_offset() != 0 {
         let stack_pointer = ctx.sp_opnd(0);
-        lea(cb, REG_SP, stack_pointer);
+        lea(cb, REG_SP, stack_pointer.into());
         mov(cb, mem_opnd(64, REG_CFP, RUBY_OFFSET_CFP_SP), REG_SP);
     }
 
@@ -791,7 +791,7 @@ pub fn gen_single_block( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L791
             gen_counter_incr!(cb, exec_instruction);
 
             // Add a comment for the name of the YARV instruction
-            add_comment(cb, &insn_name(opcode));
+            asm.comment(&insn_name(opcode));
 
             // If requested, dump instructions for debugging
             if get_option!(dump_insns) {
diff --git a/yjit/src/core.rs b/yjit/src/core.rs
index 68cc5e799f..b36e5d2ac0 100644
--- a/yjit/src/core.rs
+++ b/yjit/src/core.rs
@@ -1,5 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/yjit/src/core.rs#L1
-use crate::asm::x86_64::*;
+//use crate::asm::x86_64::*;
 use crate::asm::*;
+use crate::backend::ir::*;
 use crate::codegen::*;
 use crate::virtualmem::CodePtr;
 use crate::cruby::*;
@@ -970,15 +971,15 @@ impl Context { https://github.com/ruby/ruby/blob/trunk/yjit/src/core.rs#L971
     }
 
     /// Get an operand for the adjusted stack pointer address
-    pub fn sp_opnd(&self, offset_bytes: isize) -> X86Opnd {
+    pub fn sp_opnd(&self, offset_bytes: isize) -> Opnd {
         let offset = ((self.sp_offset as isize) * (SIZEOF_VALUE as isize)) + offset_bytes;
         let offset = offset as i32;
-        return mem_opnd(64, REG_SP, offset);
+        return Opnd::mem(64, SP, offset);
     }
 
     /// Push one new value on the temp stack with an explicit mapping
     /// Return a pointer to the new stack top
-    pub fn stack_push_mapping(&mut self, (mapping, temp_type): (TempMapping, Type)) -> X86Opnd {
+    pub fn stack_push_mapping(&mut self, (mapping, temp_type): (TempMapping, Type)) -> Opnd {
         // If type propagation is disabled, store no types
         if get_option!(no_type_prop) {
             return self.stack_push_mapping((mapping, Type::Unknown));
@@ -1001,22 +1002,22 @@ impl Context { https://github.com/ruby/ruby/blob/trunk/yjit/src/core.rs#L1002
 
         // SP points just above the topmost value
         let offset = ((self.sp_offset as i32) - 1) * (SIZEOF_VALUE as i32);
-        return mem_opnd(64, REG_SP, offset);
+        return Opnd::mem(64, SP, offset);
     }
 
     /// Push one new value on the temp stack
     /// Return a pointer to the new stack top
-    pub fn stack_push(&mut self, val_type: Type) -> X86Opnd {
+    pub fn stack_push(&mut self, val_type: Type) -> Opnd {
         return self.stack_push_mapping((MapToStack, val_type));
     }
 
     /// Push the self value on the stack
-    pub fn stack_push_self(&mut self) -> X86Opnd {
+    pub fn stack_push_self(&mut self) -> Opnd {
         return self.stack_push_mapping((MapToSelf, Type::Unknown));
     }
 
     /// Push a local variable on the stack
-    pub fn stack_push_local(&mut self, local_idx: usize) -> X86Opnd {
+    pub fn stack_push_local(&mut self, local_idx: usize) -> Opnd {
         if local_idx >= MAX_LOCAL_TYPES {
             return self.stack_push(Type::Unknown);
         }
@@ -1026,12 +1027,12 @@ impl Context { https://github.com/ruby/ruby/blob/trunk/yjit/src/core.rs#L1027
 
     // Pop N values off the stack
     // Return a pointer to the stack top before the pop operation
-    pub fn stack_pop(&mut self, n: usize) -> X86Opnd {
+    pub fn stack_pop(&mut self, n: usize) -> Opnd {
         assert!(n <= self.stack_size.into());
 
         // SP points just above the topmost value
         let offset = ((self.sp_offset as i32) - 1) * (SIZEOF_VALUE as i32);
-        let top = mem_opnd(64, REG_SP, offset);
+        let top = Opnd::mem(64, SP, offset);
 
         // Clear the types of the popped values
         for i in 0..n {
@@ -1050,10 +1051,10 @@ impl Context { https://github.com/ruby/ruby/blob/trunk/yjit/src/core.rs#L1051
     }
 
     /// Get an operand pointing to a slot on the temp stack
-    pub fn stack_opnd(&self, idx: i32) -> X86Opnd {
+    pub fn stack_opnd(&self, idx: i32) -> Opnd {
         // SP points just above the topmost value
         let offset = ((self.sp_offset as i32) - 1 - idx) * (SIZEOF_VALUE as i32);
-        let opnd = mem_opnd(64, REG_SP, offset);
+        let opnd = Opnd::mem(64, SP, offset);
         return opnd;
     }
 
@@ -1766,6 +1767,13 @@ fn get_branch_target( https://github.com/ruby/ruby/blob/trunk/yjit/src/core.rs#L1767
     // This means the branch stub owns its own reference to the branch
     let branch_ptr: *const RefCell<Branch> = BranchRef::into_raw(branchref.clone());
 
+
+
+
+
+    todo!("stub codegen with new assembler");
+
+    /*
     // Call branch_stub_hit(branch_idx, target_idx, ec)
     mov(ocb, C_ARG_REGS[2], REG_EC);
     mov(ocb, C_ARG_REGS[1], uimm_opnd(target_idx as u64));
@@ -1781,6 +1789,7 @@ fn get_branch_target( https://github.com/ruby/ruby/blob/trunk/yjit/src/core.rs#L1789
     } else {
         Some(stub_addr)
     }
+    */
 }
 
 pub fn gen_branch(
@@ -1835,7 +1844,8 @@ fn gen_jump_branch( https://github.com/ruby/ruby/blob/trunk/yjit/src/core.rs#L1844
     }
 
     if shape == BranchShape::Default {
-        jmp_ptr(cb, target0);
+        //jmp_ptr(cb, target0);
+        todo!("jmp_ptr with new assembler");
     }
 }
 
@@ -2017,7 +2027,10 @@ pub fn invalidate_block_version(blockref: &BlockRef) { https://github.com/ruby/ruby/blob/trunk/yjit/src/core.rs#L2027
             // Patch in a jump to block.entry_exit.
             let cur_pos = cb.get_write_ptr();
             cb.set_write_ptr(block_start);
-            jmp_ptr(cb, block_entry_exit);
+
+            //jmp_ptr(cb, block_entry_exit);
+            todo!("jmp_ptr with new assembler");
+
             assert!(
                 cb.get_write_ptr() < block_end,
                 "invalidation wrote past end of block"
-- 
cgit v1.2.1


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

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