summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>2022-06-07 15:22:06 -0400
committerTakashi Kokubun <takashikkbn@gmail.com>2022-08-29 08:46:54 -0700
commite22134277b81124ba2ce4cf3e08ad0983c0432c9 (patch)
tree9558bf049019f282b6ef929d1c1666a6dce1c80a
parent3133540be79a511c79c3876df40ad25c912ecc79 (diff)
Remove x86_64 dependency in core.rs
-rw-r--r--yjit/src/backend/x86_64/mod.rs3
-rw-r--r--yjit/src/codegen.rs4
-rw-r--r--yjit/src/core.rs41
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
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 {
// 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(
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 @@
-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 {
}
/// 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 {
// 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 {
// 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 {
}
/// 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(
// 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(
} else {
Some(stub_addr)
}
+ */
}
pub fn gen_branch(
@@ -1835,7 +1844,8 @@ fn gen_jump_branch(
}
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) {
// 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"