ruby-changes:73155
From: Maxime <ko1@a...>
Date: Tue, 30 Aug 2022 00:57:22 +0900 (JST)
Subject: [ruby-changes:73155] 24db233fc7 (master): Add jo insn and test for jo
https://git.ruby-lang.org/ruby.git/commit/?id=24db233fc7 From 24db233fc70799642aad09be9170da61332ff010 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...> Date: Mon, 20 Jun 2022 15:50:42 -0400 Subject: Add jo insn and test for jo --- yjit/src/backend/ir.rs | 2 ++ yjit/src/backend/tests.rs | 19 +++++++++++++++++++ yjit/src/backend/x86_64/mod.rs | 28 ++++++++++++++++++++++++++-- yjit/src/codegen.rs | 1 - 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 https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/ir.rs#L91 Je, Jz, Jnz, + Jo, // Push and pop registers to/from the C stack CPush, @@ -772,6 +773,7 @@ def_push_jcc!(je, Op::Je); https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/ir.rs#L773 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() https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/tests.rs#L239 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 https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/x86_64/mod.rs#L140 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 https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/x86_64/mod.rs#L214 } } - 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 https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/x86_64/mod.rs#L238 } } + 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( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L1095 ) -> CodegenStatus { let nval: VALUE = jit_get_arg(jit, 0); let VALUE(n) = nval; - ctx.stack_pop(n); KeepCompiling } -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/