YJIT: Fix BorrowMutError on BOP invalidation (#7212)
This commit is contained in:
parent
eac5ae22e2
commit
e11067ebbf
Notes:
git
2023-01-31 20:27:16 +00:00
Merged-By: maximecb <maximecb@ruby-lang.org>
@ -1074,6 +1074,24 @@ class TestYJIT < Test::Unit::TestCase
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_invalidate_cyclic_branch
|
||||||
|
assert_compiles(<<~'RUBY', result: 2)
|
||||||
|
def foo
|
||||||
|
i = 0
|
||||||
|
while i < 2
|
||||||
|
i += 1
|
||||||
|
end
|
||||||
|
i
|
||||||
|
end
|
||||||
|
|
||||||
|
foo
|
||||||
|
class Integer
|
||||||
|
def +(x) = self - -x
|
||||||
|
end
|
||||||
|
foo
|
||||||
|
RUBY
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def code_gc_helpers
|
def code_gc_helpers
|
||||||
|
@ -439,7 +439,7 @@ pub type CmePtr = *const rb_callable_method_entry_t;
|
|||||||
/// Basic block version
|
/// Basic block version
|
||||||
/// Represents a portion of an iseq compiled with a given context
|
/// Represents a portion of an iseq compiled with a given context
|
||||||
/// Note: care must be taken to minimize the size of block_t objects
|
/// Note: care must be taken to minimize the size of block_t objects
|
||||||
#[derive(Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Block {
|
pub struct Block {
|
||||||
// Bytecode sequence (iseq, idx) this is a version of
|
// Bytecode sequence (iseq, idx) this is a version of
|
||||||
blockid: BlockId,
|
blockid: BlockId,
|
||||||
@ -2318,6 +2318,8 @@ pub fn invalidate_block_version(blockref: &BlockRef) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For each incoming branch
|
// For each incoming branch
|
||||||
|
mem::drop(block); // end borrow: regenerate_branch might mut borrow this
|
||||||
|
let block = blockref.borrow().clone();
|
||||||
for branchref in &block.incoming {
|
for branchref in &block.incoming {
|
||||||
let mut branch = branchref.borrow_mut();
|
let mut branch = branchref.borrow_mut();
|
||||||
let target_idx = if branch.get_target_address(0) == block_start {
|
let target_idx = if branch.get_target_address(0) == block_start {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user