Skip to content

Commit a1a4d77

Browse files
committed
YJIT: code_gc(): Assert self is inline to avoid other_cb()
The derived `&mut` from `other_cb()` overlapped with the parameter `ocb`. Use `cfg!()` instead of `#[cfg...]` to avoid unused warnings.
1 parent cdededf commit a1a4d77

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

yjit/src/asm/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ impl CodeBlock {
154154
}
155155

156156
// Move the other CodeBlock to the same page if it's on the furthest page
157-
#[cfg(not(test))]
158-
self.other_cb().unwrap().set_page(next_page_idx.unwrap(), &jmp_ptr);
157+
if cfg!(not(test)) {
158+
self.other_cb().unwrap().set_page(next_page_idx.unwrap(), &jmp_ptr);
159+
}
159160

160161
return !self.dropped_bytes;
161162
}
@@ -584,6 +585,8 @@ impl CodeBlock {
584585

585586
/// Code GC. Free code pages that are not on stack and reuse them.
586587
pub fn code_gc(&mut self, ocb: &mut OutlinedCb) {
588+
assert!(self.inline(), "must use on inline code block");
589+
587590
// The previous code GC failed to free any pages. Give up.
588591
if self.freed_pages.as_ref() == &Some(vec![]) {
589592
return;
@@ -641,7 +644,7 @@ impl CodeBlock {
641644
// Track which pages are free.
642645
let new_freed_pages = Rc::new(Some(freed_pages));
643646
let old_freed_pages = mem::replace(&mut self.freed_pages, Rc::clone(&new_freed_pages));
644-
self.other_cb().unwrap().freed_pages = new_freed_pages;
647+
ocb.unwrap().freed_pages = new_freed_pages;
645648
assert_eq!(1, Rc::strong_count(&old_freed_pages)); // will deallocate
646649

647650
CodegenGlobals::incr_code_gc_count();

0 commit comments

Comments
 (0)