YJIT: call free_block to cleanup block when out of memory

The commented out instance of free_block() is left over from the port.
The addition in gen_single_block() was a place we missed. The new block
is allocated in the same function and could have invariants associated
with it even though there is no space to hold all the code.
This commit is contained in:
Alan Wu 2022-10-14 17:20:41 -04:00
parent 637144b834
commit ad3d210bea
Notes: git 2022-10-17 16:11:39 +00:00
2 changed files with 4 additions and 5 deletions

View File

@ -877,6 +877,7 @@ pub fn gen_single_block(
// If code for the block doesn't fit, fail
if cb.has_dropped_bytes() || ocb.unwrap().has_dropped_bytes() {
free_block(&blockref);
return Err(());
}

View File

@ -1438,11 +1438,9 @@ fn gen_block_series_body(
if result.is_err() {
// Remove previously compiled block
// versions from the version map
mem::drop(last_branch); // end borrow
for blockref in &batch {
// FIXME: should be deallocating resources here too
// e.g. invariants, etc.
//free_block(blockref)
free_block(blockref);
remove_block_version(blockref);
}
@ -2010,7 +2008,7 @@ pub fn defer_compilation(
}
// Remove all references to a block then free it.
fn free_block(blockref: &BlockRef) {
pub fn free_block(blockref: &BlockRef) {
use crate::invariants::*;
block_assumptions_free(blockref);