diff options
author | Kevin Newton <kddnewton@gmail.com> | 2022-07-22 16:06:37 -0400 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2022-08-29 08:47:04 -0700 |
commit | 13e5b56a5d8f36815fb9aa3834d82a54b69e087a (patch) | |
tree | d9409deddcc4d426525d8d4103619bce44bbba23 /yjit/src/asm | |
parent | f593b2c6db622de6f973e4e847e959855c341a25 (diff) | |
download | ruby-13e5b56a5d8f36815fb9aa3834d82a54b69e087a.tar.gz |
Fixes (https://github.com/Shopify/ruby/pull/340)
* Fix conditional jumps to label
* Bitmask immediates cannot be u64::MAX
Diffstat (limited to 'yjit/src/asm')
-rw-r--r-- | yjit/src/asm/arm64/arg/bitmask_imm.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/yjit/src/asm/arm64/arg/bitmask_imm.rs b/yjit/src/asm/arm64/arg/bitmask_imm.rs index 220a7d697e..b3a821fe94 100644 --- a/yjit/src/asm/arm64/arg/bitmask_imm.rs +++ b/yjit/src/asm/arm64/arg/bitmask_imm.rs @@ -43,7 +43,7 @@ impl TryFrom<u64> for BitmaskImmediate { fn try_from(value: u64) -> Result<Self, Self::Error> { // 0 is not encodable as a bitmask immediate. Immediately return here so // that we don't have any issues with underflow. - if value == 0 { + if value == 0 || value == u64::MAX { return Err(()); } @@ -137,7 +137,7 @@ impl From<BitmaskImmediate> for u32 { 0 | (((bitmask.n as u32) & 1) << 12) | ((bitmask.immr as u32) << 6) - | bitmask.imms as u32 + | (bitmask.imms as u32) } } @@ -260,4 +260,10 @@ mod tests { let bitmask = BitmaskImmediate::try_from(0xfffffffffffffffe); assert!(matches!(bitmask, Ok(BitmaskImmediate { n: 1, immr: 0b111111, imms: 0b111110 }))); } + + #[test] + fn test_size_64_invalid() { + let bitmask = BitmaskImmediate::try_from(u64::MAX); + assert!(matches!(bitmask, Err(()))); + } } |