Skip to content

Commit

Permalink
fix arm
Browse files Browse the repository at this point in the history
  • Loading branch information
XrXr committed Nov 10, 2023
1 parent fc63d6e commit 52b69d8
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions yjit/src/backend/arm64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,9 @@ impl Assembler
// List of GC offsets
let mut gc_offsets: Vec<u32> = Vec::new();

// Buffered list of PosMarker callbacks to fire if codegen is successful
let mut pos_markers: Vec<(usize, CodePtr)> = vec![];

// For each instruction
let start_write_pos = cb.get_write_pos();
let mut insn_idx: usize = 0;
Expand All @@ -838,8 +841,8 @@ impl Assembler
cb.write_label(target.unwrap_label_idx());
},
// Report back the current position in the generated code
Insn::PosMarker(pos_marker) => {
pos_marker(cb.get_write_ptr());
Insn::PosMarker(..) => {
pos_markers.push((insn_idx, cb.get_write_ptr()))
}
Insn::BakeString(text) => {
for byte in text.as_bytes() {
Expand Down Expand Up @@ -1205,7 +1208,21 @@ impl Assembler
}
}

Ok(gc_offsets)
// Error out if we couldn't write out everything
if cb.has_dropped_bytes() {
Err(EmitError::OutOfMemory)
} else {
// No bytes dropped, so the pos markers point to valid code
for (insn_idx, pos) in pos_markers {
if let Insn::PosMarker(callback) = self.insns.get(insn_idx).unwrap() {
callback(pos);
} else {
panic!("non-PosMarker in pos_markers insn_idx={insn_idx} {self:?}");
}
}

Ok(gc_offsets)
}
}

/// Optimize and compile the stored instructions
Expand Down

0 comments on commit 52b69d8

Please sign in to comment.