diff options
author | Alan Wu <[email protected]> | 2022-10-14 17:20:41 -0400 |
---|---|---|
committer | Alan Wu <[email protected]> | 2022-10-17 12:11:17 -0400 |
commit | ad3d210beab9d162b96e2601aa3ad896785b831b (patch) | |
tree | 8e092e9a2a39824b3400cf4f3b55755d42d99833 | |
parent | 637144b83432781e7e070ca74445b172f8af109e (diff) |
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.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6551
-rw-r--r-- | yjit/src/codegen.rs | 1 | ||||
-rw-r--r-- | yjit/src/core.rs | 8 |
2 files changed, 4 insertions, 5 deletions
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs index 88b51674cf..5f6d97834a 100644 --- a/yjit/src/codegen.rs +++ b/yjit/src/codegen.rs @@ -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(()); } diff --git a/yjit/src/core.rs b/yjit/src/core.rs index 1805a2bb13..3cecf31a85 100644 --- a/yjit/src/core.rs +++ b/yjit/src/core.rs @@ -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); |