diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2022-11-03 08:42:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-03 11:42:28 -0400 |
commit | 68ef97d788cf8bff42d981bda41cd26128220740 (patch) | |
tree | a47646a42fbfc7e7bc6a8fa88b74940bbd2dfeb8 /yjit/src/asm | |
parent | 0468136a1b07d693cf60abd0c5ccd125fc361039 (diff) | |
download | ruby-68ef97d788cf8bff42d981bda41cd26128220740.tar.gz |
YJIT: Stop incrementing write_pos if cb.has_dropped_bytes (#6664)
Co-Authored-By: Alan Wu <alansi.xingwu@shopify.com>
Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
Diffstat (limited to 'yjit/src/asm')
-rw-r--r-- | yjit/src/asm/mod.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/yjit/src/asm/mod.rs b/yjit/src/asm/mod.rs index 6b2dd7da9a..1be4488006 100644 --- a/yjit/src/asm/mod.rs +++ b/yjit/src/asm/mod.rs @@ -418,12 +418,11 @@ impl CodeBlock { /// Write a single byte at the current position. pub fn write_byte(&mut self, byte: u8) { let write_ptr = self.get_write_ptr(); - if !self.has_capacity(1) || self.mem_block.borrow_mut().write_byte(write_ptr, byte).is_err() { + if self.has_capacity(1) && self.mem_block.borrow_mut().write_byte(write_ptr, byte).is_ok() { + self.write_pos += 1; + } else { self.dropped_bytes = true; } - - // Always advance write_pos since arm64 PadEntryExit needs this to stop the loop. - self.write_pos += 1; } /// Write multiple bytes starting from the current position. @@ -489,10 +488,11 @@ impl CodeBlock { self.label_refs.push(LabelRef { pos: self.write_pos, label_idx, num_bytes, encode }); // Move past however many bytes the instruction takes up - if !self.has_capacity(num_bytes) { + if self.has_capacity(num_bytes) { + self.write_pos += num_bytes; + } else { self.dropped_bytes = true; // retry emitting the Insn after next_page } - self.write_pos += num_bytes; } // Link internal label references |