YJIT: Improve the failure message on enlarging a branch (#6769)

This commit is contained in:
Takashi Kokubun 2022-11-18 17:27:07 -08:00 committed by GitHub
parent 082cfcfd06
commit 6dcb7b9216
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
Notes: git 2022-11-19 01:27:28 +00:00
Merged-By: k0kubun <takashikkbn@gmail.com>

View File

@ -1851,8 +1851,8 @@ fn branch_stub_hit_body(branch_ptr: *const c_void, target_idx: u32, ec: EcPtr) -
let new_branch_size = branch.code_size();
assert!(
new_branch_size <= branch_size_on_entry,
"branch stubs should never enlarge branches: (old_size: {}, new_size: {})",
branch_size_on_entry, new_branch_size,
"branch stubs should never enlarge branches (start_addr: {:?}, old_size: {}, new_size: {})",
branch.start_addr.unwrap().raw_ptr(), branch_size_on_entry, new_branch_size,
);
// Return a pointer to the compiled block version
@ -2258,14 +2258,17 @@ pub fn invalidate_block_version(blockref: &BlockRef) {
}
// Rewrite the branch with the new jump target address
let branch_end_addr = branch.end_addr;
let old_branch_size = branch.code_size();
regenerate_branch(cb, &mut branch);
if target_next && branch.end_addr > block.end_addr {
panic!("yjit invalidate rewrote branch past end of invalidated block: {:?} (code_size: {})", branch, block.code_size());
}
if !target_next && branch.end_addr > branch_end_addr {
panic!("invalidated branch grew in size: {:?}", branch);
if !target_next && branch.code_size() > old_branch_size {
panic!(
"invalidated branch grew in size (start_addr: {:?}, old_size: {}, new_size: {})",
branch.start_addr.unwrap().raw_ptr(), old_branch_size, branch.code_size()
);
}
}