diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2023-01-30 11:16:33 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-30 11:16:33 -0800 |
commit | 2e0f3b5546854c98174d4210c0e06c78c8294f98 (patch) | |
tree | 3f17dcab5b759e5a45b10415a2ce368ff1dcaa20 /yjit/src | |
parent | bc0dc9d40e20cd3d0a1dd0b3fae061aae34d5a33 (diff) | |
download | ruby-2e0f3b5546854c98174d4210c0e06c78c8294f98.tar.gz |
YJIT: Fix BorrowMutError on GC.compact (#7176)
YJIT: Fix BorrowMutError
Diffstat (limited to 'yjit/src')
-rw-r--r-- | yjit/src/core.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/yjit/src/core.rs b/yjit/src/core.rs index cd6144919d..d10654f125 100644 --- a/yjit/src/core.rs +++ b/yjit/src/core.rs @@ -756,16 +756,6 @@ pub extern "C" fn rb_yjit_iseq_update_references(payload: *mut c_void) { *cme_dep = unsafe { rb_gc_location((*cme_dep).into()) }.as_cme(); } - // Update outgoing branch entries - mem::drop(block); // end mut borrow: target.get_blockid() might borrow it - let block = version.borrow(); - for branch in &block.outgoing { - let mut branch = branch.borrow_mut(); - for target in branch.targets.iter_mut().flatten() { - target.set_iseq(unsafe { rb_gc_location(target.get_blockid().iseq.into()) }.as_iseq()); - } - } - // Walk over references to objects in generated code. for offset in &block.gc_obj_offsets { let offset_to_value = offset.as_usize(); @@ -787,6 +777,16 @@ pub extern "C" fn rb_yjit_iseq_update_references(payload: *mut c_void) { } } } + + // Update outgoing branch entries + let outgoing_branches = block.outgoing.clone(); // clone to use after borrow + mem::drop(block); // end mut borrow: target.set_iseq and target.get_blockid() might (mut) borrow it + for branch in &outgoing_branches { + let mut branch = branch.borrow_mut(); + for target in branch.targets.iter_mut().flatten() { + target.set_iseq(unsafe { rb_gc_location(target.get_blockid().iseq.into()) }.as_iseq()); + } + } } } |