diff options
author | Alan Wu <XrXr@users.noreply.github.com> | 2023-03-28 19:00:18 -0400 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2023-03-29 14:53:49 -0400 |
commit | a1a4d77472475fc9ee4c16cce7b79f6f492c91c3 (patch) | |
tree | 5ef15aaa30c34d700642184fd57e2195b989a212 /yjit/src | |
parent | cdededf24dff06842fe8401af93cf6d8c304de13 (diff) | |
download | ruby-a1a4d77472475fc9ee4c16cce7b79f6f492c91c3.tar.gz |
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.
Diffstat (limited to 'yjit/src')
-rw-r--r-- | yjit/src/asm/mod.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/yjit/src/asm/mod.rs b/yjit/src/asm/mod.rs index 346ada7719..e0d4fb3cc0 100644 --- a/yjit/src/asm/mod.rs +++ b/yjit/src/asm/mod.rs @@ -154,8 +154,9 @@ impl CodeBlock { } // Move the other CodeBlock to the same page if it's on the furthest page - #[cfg(not(test))] - self.other_cb().unwrap().set_page(next_page_idx.unwrap(), &jmp_ptr); + if cfg!(not(test)) { + self.other_cb().unwrap().set_page(next_page_idx.unwrap(), &jmp_ptr); + } return !self.dropped_bytes; } @@ -584,6 +585,8 @@ impl CodeBlock { /// Code GC. Free code pages that are not on stack and reuse them. pub fn code_gc(&mut self, ocb: &mut OutlinedCb) { + assert!(self.inline(), "must use on inline code block"); + // The previous code GC failed to free any pages. Give up. if self.freed_pages.as_ref() == &Some(vec![]) { return; @@ -641,7 +644,7 @@ impl CodeBlock { // Track which pages are free. let new_freed_pages = Rc::new(Some(freed_pages)); let old_freed_pages = mem::replace(&mut self.freed_pages, Rc::clone(&new_freed_pages)); - self.other_cb().unwrap().freed_pages = new_freed_pages; + ocb.unwrap().freed_pages = new_freed_pages; assert_eq!(1, Rc::strong_count(&old_freed_pages)); // will deallocate CodegenGlobals::incr_code_gc_count(); |