summaryrefslogtreecommitdiff
path: root/yjit/src
diff options
context:
space:
mode:
authorMaxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>2022-06-20 15:50:42 -0400
committerTakashi Kokubun <takashikkbn@gmail.com>2022-08-29 08:46:58 -0700
commit24db233fc70799642aad09be9170da61332ff010 (patch)
tree2ac837600a1505b471f5168ffbc3b991ef33e4c1 /yjit/src
parent8bb7421d8e222fdae6b51049993efc46cf494f15 (diff)
Add jo insn and test for jo
Diffstat (limited to 'yjit/src')
-rw-r--r--yjit/src/backend/ir.rs2
-rw-r--r--yjit/src/backend/tests.rs19
-rw-r--r--yjit/src/backend/x86_64/mod.rs28
-rw-r--r--yjit/src/codegen.rs1
4 files changed, 47 insertions, 3 deletions
diff --git a/yjit/src/backend/ir.rs b/yjit/src/backend/ir.rs
index 437cc24286..bacbbd541d 100644
--- a/yjit/src/backend/ir.rs
+++ b/yjit/src/backend/ir.rs
@@ -91,6 +91,7 @@ pub enum Op
Je,
Jz,
Jnz,
+ Jo,
// Push and pop registers to/from the C stack
CPush,
@@ -772,6 +773,7 @@ def_push_jcc!(je, Op::Je);
def_push_jcc!(jbe, Op::Jbe);
def_push_jcc!(jz, Op::Jz);
def_push_jcc!(jnz, Op::Jnz);
+def_push_jcc!(jo, Op::Jo);
def_push_2_opnd!(add, Op::Add);
def_push_2_opnd!(sub, Op::Sub);
def_push_2_opnd!(and, Op::And);
diff --git a/yjit/src/backend/tests.rs b/yjit/src/backend/tests.rs
index 747e7eb2b5..a8ae1bc97a 100644
--- a/yjit/src/backend/tests.rs
+++ b/yjit/src/backend/tests.rs
@@ -239,3 +239,22 @@ fn test_jcc_ptr()
asm.compile_with_num_regs(&mut cb, 1);
}
+
+#[test]
+fn test_jo()
+{
+ let (mut asm, mut cb) = setup_asm();
+
+ let side_exit = Target::CodePtr((5 as *mut u8).into());
+
+ let arg1 = Opnd::mem(64, SP, 0);
+ let arg0 = Opnd::mem(64, SP, 8);
+
+ let arg0_untag = asm.sub(arg0, Opnd::Imm(1));
+ let out_val = asm.add(arg0_untag, arg1);
+ asm.jo(side_exit);
+
+ asm.mov(Opnd::mem(64, SP, 0), out_val);
+
+ asm.compile_with_num_regs(&mut cb, 1);
+}
diff --git a/yjit/src/backend/x86_64/mod.rs b/yjit/src/backend/x86_64/mod.rs
index 894ae279bd..93e3e3f458 100644
--- a/yjit/src/backend/x86_64/mod.rs
+++ b/yjit/src/backend/x86_64/mod.rs
@@ -140,6 +140,10 @@ impl Assembler
add(cb, insn.opnds[0].into(), insn.opnds[1].into())
},
+ Op::Sub => {
+ sub(cb, insn.opnds[0].into(), insn.opnds[1].into())
+ },
+
Op::And => {
and(cb, insn.opnds[0].into(), insn.opnds[1].into())
},
@@ -210,9 +214,21 @@ impl Assembler
}
}
- Op::Je => je_label(cb, insn.target.unwrap().unwrap_label_idx()),
+ Op::Je => {
+ match insn.target.unwrap() {
+ Target::CodePtr(code_ptr) => je_ptr(cb, code_ptr),
+ Target::Label(label_idx) => je_label(cb, label_idx),
+ _ => unreachable!()
+ }
+ }
- Op::Jz => jz_label(cb, insn.target.unwrap().unwrap_label_idx()),
+ Op::Jz => {
+ match insn.target.unwrap() {
+ Target::CodePtr(code_ptr) => jz_ptr(cb, code_ptr),
+ Target::Label(label_idx) => jz_label(cb, label_idx),
+ _ => unreachable!()
+ }
+ }
Op::Jnz => {
match insn.target.unwrap() {
@@ -222,6 +238,14 @@ impl Assembler
}
}
+ Op::Jo => {
+ match insn.target.unwrap() {
+ Target::CodePtr(code_ptr) => jo_ptr(cb, code_ptr),
+ Target::Label(label_idx) => jo_label(cb, label_idx),
+ _ => unreachable!()
+ }
+ }
+
// Atomically increment a counter at a given memory location
Op::IncrCounter => {
assert!(matches!(insn.opnds[0], Opnd::Mem(_)));
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index 879323dfa1..b97bb01b1b 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -1095,7 +1095,6 @@ fn gen_adjuststack(
) -> CodegenStatus {
let nval: VALUE = jit_get_arg(jit, 0);
let VALUE(n) = nval;
-
ctx.stack_pop(n);
KeepCompiling
}