Skip to content

Commit 52b69d8

Browse files
committed
fix arm
1 parent fc63d6e commit 52b69d8

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

yjit/src/backend/arm64/mod.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,9 @@ impl Assembler
819819
// List of GC offsets
820820
let mut gc_offsets: Vec<u32> = Vec::new();
821821

822+
// Buffered list of PosMarker callbacks to fire if codegen is successful
823+
let mut pos_markers: Vec<(usize, CodePtr)> = vec![];
824+
822825
// For each instruction
823826
let start_write_pos = cb.get_write_pos();
824827
let mut insn_idx: usize = 0;
@@ -838,8 +841,8 @@ impl Assembler
838841
cb.write_label(target.unwrap_label_idx());
839842
},
840843
// Report back the current position in the generated code
841-
Insn::PosMarker(pos_marker) => {
842-
pos_marker(cb.get_write_ptr());
844+
Insn::PosMarker(..) => {
845+
pos_markers.push((insn_idx, cb.get_write_ptr()))
843846
}
844847
Insn::BakeString(text) => {
845848
for byte in text.as_bytes() {
@@ -1205,7 +1208,21 @@ impl Assembler
12051208
}
12061209
}
12071210

1208-
Ok(gc_offsets)
1211+
// Error out if we couldn't write out everything
1212+
if cb.has_dropped_bytes() {
1213+
Err(EmitError::OutOfMemory)
1214+
} else {
1215+
// No bytes dropped, so the pos markers point to valid code
1216+
for (insn_idx, pos) in pos_markers {
1217+
if let Insn::PosMarker(callback) = self.insns.get(insn_idx).unwrap() {
1218+
callback(pos);
1219+
} else {
1220+
panic!("non-PosMarker in pos_markers insn_idx={insn_idx} {self:?}");
1221+
}
1222+
}
1223+
1224+
Ok(gc_offsets)
1225+
}
12091226
}
12101227

12111228
/// Optimize and compile the stored instructions

0 commit comments

Comments
 (0)