Skip to content

Commit

Permalink
Fix a bug in the x86 backend wrt large integer values, enable more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maximecb authored and k0kubun committed Aug 25, 2022
1 parent 7b574c7 commit 4568c82
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/yjit-new-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ jobs:
bootstraptest/test_objectspace.rb \
bootstraptest/test_string.rb \
bootstraptest/test_struct.rb \
bootstraptest/test_yjit_new_backend.rb
bootstraptest/test_yjit_new_backend.rb \
bootstraptest/test_yjit_rust_port.rb
#bootstraptest/test_proc.rb
#bootstraptest/test_yjit_rust_port.rb
#bootstraptest/test_yjit.rb

# Check that we can do a full build
#- run: make -j
23 changes: 20 additions & 3 deletions yjit/src/backend/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 4568c82

Please sign in to comment.