Scan entire predicate in InstallVerifyAttr
This commit is contained in:
@@ -563,9 +563,9 @@ impl Machine {
|
|||||||
self.machine_st.cp = self.machine_st.attr_var_init.cp;
|
self.machine_st.cp = self.machine_st.attr_var_init.cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut p = self.machine_st.p;
|
let p = self.machine_st.p;
|
||||||
let mut arity = 0;
|
|
||||||
|
|
||||||
|
// Find the boundaries of the current predicate
|
||||||
self.indices.code_dir.sort_by(|_, a, _, b| a.cmp(b));
|
self.indices.code_dir.sort_by(|_, a, _, b| a.cmp(b));
|
||||||
|
|
||||||
let predicate_idx = self
|
let predicate_idx = self
|
||||||
@@ -574,38 +574,41 @@ impl Machine {
|
|||||||
.binary_search_by_key(&p, |_, x| x.get().p() as usize)
|
.binary_search_by_key(&p, |_, x| x.get().p() as usize)
|
||||||
.unwrap_or_else(|x| x - 1);
|
.unwrap_or_else(|x| x - 1);
|
||||||
|
|
||||||
let current_pred_limit = self
|
let current_pred_start = self
|
||||||
|
.indices
|
||||||
|
.code_dir
|
||||||
|
.get_index(predicate_idx)
|
||||||
|
.map(|x| x.1.p() as usize)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
debug_assert!(current_pred_start <= p);
|
||||||
|
|
||||||
|
let current_pred_end = self
|
||||||
.indices
|
.indices
|
||||||
.code_dir
|
.code_dir
|
||||||
.get_index(predicate_idx + 1)
|
.get_index(predicate_idx + 1)
|
||||||
.map(|x| x.1.p() as usize);
|
.map(|x| x.1.p() as usize)
|
||||||
|
.unwrap_or(self.code.len());
|
||||||
|
|
||||||
while self.code[p].is_head_instr() {
|
debug_assert!(current_pred_end >= p);
|
||||||
//println!("{}: {:?}", p, &self.code[p]);
|
debug_assert!(current_pred_end <= self.code.len());
|
||||||
//println!("{} {:?}", arity, self.code[p]);
|
|
||||||
for r in self.code[p].registers() {
|
|
||||||
//println!("reg {:?}", r);
|
|
||||||
if let RegType::Temp(t) = r {
|
|
||||||
arity = std::cmp::max(arity, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p += 1;
|
// Find point to insert the interrupt
|
||||||
}
|
let p_interrupt = p + self.code[p..current_pred_end]
|
||||||
|
.iter()
|
||||||
|
.position(|x| !x.is_head_instr())
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let p_interrupt = p;
|
// Scan registers of all instructions to find out how many to save
|
||||||
|
let arity = self.code[current_pred_start..current_pred_end]
|
||||||
while p < self.code.len()
|
.iter()
|
||||||
&& current_pred_limit.map(|x| p < x).unwrap_or(true)
|
.flat_map(Instruction::registers)
|
||||||
{
|
.flat_map(|r| match r {
|
||||||
for r in self.code[p].registers() {
|
RegType::Temp(t) => Some(t),
|
||||||
if let RegType::Temp(t) = r {
|
_ => None,
|
||||||
arity = std::cmp::max(arity, t);
|
})
|
||||||
}
|
.max()
|
||||||
}
|
.unwrap_or(0);
|
||||||
|
|
||||||
p += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
let instr = std::mem::replace(
|
let instr = std::mem::replace(
|
||||||
&mut self.code[p_interrupt],
|
&mut self.code[p_interrupt],
|
||||||
@@ -616,9 +619,6 @@ impl Machine {
|
|||||||
self.machine_st.attr_var_init.cp = p_interrupt;
|
self.machine_st.attr_var_init.cp = p_interrupt;
|
||||||
}
|
}
|
||||||
&Instruction::VerifyAttrInterrupt(arity) => {
|
&Instruction::VerifyAttrInterrupt(arity) => {
|
||||||
//println!("VerifyAttr arity: {arity}");
|
|
||||||
// let (_, arity) = self.code[VERIFY_ATTR_INTERRUPT_LOC].to_name_and_arity();
|
|
||||||
// let arity = std::cmp::max(arity, self.machine_st.num_of_args);
|
|
||||||
self.run_verify_attr_interrupt(arity);
|
self.run_verify_attr_interrupt(arity);
|
||||||
}
|
}
|
||||||
&Instruction::Add(ref a1, ref a2, t) => {
|
&Instruction::Add(ref a1, ref a2, t) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user