mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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>
This commit is contained in:
parent
0468136a1b
commit
68ef97d788
Notes:
git
2022-11-03 15:42:48 +00:00
Merged-By: maximecb <maximecb@ruby-lang.org>
2 changed files with 7 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -1028,7 +1028,7 @@ impl Assembler
|
|||
}
|
||||
Insn::LiveReg { .. } => (), // just a reg alloc signal, no code
|
||||
Insn::PadInvalPatch => {
|
||||
while (cb.get_write_pos().saturating_sub(std::cmp::max(start_write_pos, cb.page_start_pos()))) < JMP_PTR_BYTES {
|
||||
while (cb.get_write_pos().saturating_sub(std::cmp::max(start_write_pos, cb.page_start_pos()))) < JMP_PTR_BYTES && !cb.has_dropped_bytes() {
|
||||
nop(cb);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue