diff options
author | Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> | 2022-07-25 15:22:25 -0400 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2022-08-29 08:47:04 -0700 |
commit | 2d9b98f9bc918b1161d308c5d202fcb3be01de07 (patch) | |
tree | b03d81135353a629d29ef3e8ef2fa7e281090d62 /yjit | |
parent | c9a947e5d81088907f774ddfbcd274a88ba7d8ff (diff) | |
download | ruby-2d9b98f9bc918b1161d308c5d202fcb3be01de07.tar.gz |
Fix a bug in the x86 backend wrt large integer values, enable more tests
Diffstat (limited to 'yjit')
-rw-r--r-- | yjit/src/backend/x86_64/mod.rs | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/yjit/src/backend/x86_64/mod.rs b/yjit/src/backend/x86_64/mod.rs index 5bae5c7f29..c1bcdca3e7 100644 --- a/yjit/src/backend/x86_64/mod.rs +++ b/yjit/src/backend/x86_64/mod.rs @@ -2,7 +2,7 @@ #![allow(unused_variables)] #![allow(unused_imports)] -use crate::asm::{uimm_num_bits, CodeBlock}; +use crate::asm::*; use crate::asm::x86_64::*; use crate::codegen::{JITState}; use crate::cruby::*; @@ -119,7 +119,15 @@ impl Assembler (asm.load(opnds[0]), asm.load(opnds[1])) }, (Opnd::Mem(_), Opnd::UImm(value)) => { - if uimm_num_bits(value) > 32 { + // 32-bit values will be sign-extended + if imm_num_bits(value as i64) > 32 { + (asm.load(opnds[0]), asm.load(opnds[1])) + } else { + (asm.load(opnds[0]), opnds[1]) + } + }, + (Opnd::Mem(_), Opnd::Imm(value)) => { + if imm_num_bits(value) > 32 { (asm.load(opnds[0]), asm.load(opnds[1])) } else { (asm.load(opnds[0]), opnds[1]) @@ -161,7 +169,16 @@ impl Assembler asm.mov(opnds[0], opnd1); }, (Opnd::Mem(_), Opnd::UImm(value)) => { - if uimm_num_bits(value) > 32 { + // 32-bit values will be sign-extended + if imm_num_bits(value as i64) > 32 { + let opnd1 = asm.load(opnds[1]); + asm.mov(opnds[0], opnd1); + } else { + asm.mov(opnds[0], opnds[1]); + } + }, + (Opnd::Mem(_), Opnd::Imm(value)) => { + if imm_num_bits(value) > 32 { let opnd1 = asm.load(opnds[1]); asm.mov(opnds[0], opnd1); } else { |