зеркало из https://github.com/github/ruby.git
YJIT: Add and use Branch::assert_layout()
This assert would've caught a bug I wrote while developing ruby/ruby#7443 so I figured it would be good to commit it as it could be helpful in the future.
This commit is contained in:
Родитель
5d0a1ffafa
Коммит
2a26a5e677
|
@ -642,6 +642,16 @@ impl Branch {
|
|||
}
|
||||
count
|
||||
}
|
||||
|
||||
fn assert_layout(&self) {
|
||||
let shape = self.gen_fn.get_shape();
|
||||
assert!(
|
||||
!(shape == BranchShape::Default && 0 == self.code_size()),
|
||||
"zero-size branches are incorrect when code for neither targets are adjacent"
|
||||
// One needs to issue some instruction to steer to the branch target
|
||||
// when falling through isn't an option.
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for Branch {
|
||||
|
@ -737,6 +747,8 @@ impl PendingBranch {
|
|||
}
|
||||
}
|
||||
|
||||
branch.assert_layout();
|
||||
|
||||
branchref
|
||||
}
|
||||
}
|
||||
|
@ -2248,6 +2260,8 @@ fn regenerate_branch(cb: &mut CodeBlock, branch: &Branch) {
|
|||
// The branch sits at the end of cb and consumed some memory.
|
||||
// Keep cb.write_pos.
|
||||
}
|
||||
|
||||
branch.assert_layout();
|
||||
}
|
||||
|
||||
pub type PendingBranchRef = Rc<PendingBranch>;
|
||||
|
|
Загрузка…
Ссылка в новой задаче