correct inference counting over index backtracking, built-ins (#1977, #1987)

This commit is contained in:
Mark
2023-09-04 17:15:05 -06:00
parent 2ccc238119
commit 5585e83fd6
8 changed files with 153 additions and 102 deletions

View File

@@ -3190,6 +3190,9 @@ impl Machine {
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
);
}
&IndexedChoiceInstruction::DefaultRetry(l) => {
self.retry(l);
}
&IndexedChoiceInstruction::Trust(l) => {
self.trust(l);
@@ -3198,6 +3201,9 @@ impl Machine {
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
);
}
&IndexedChoiceInstruction::DefaultTrust(l) => {
self.trust(l);
}
}
}
IndexingLine::DynamicIndexedChoice(_) => {
@@ -5192,11 +5198,6 @@ impl Machine {
if self.machine_st.fail {
self.machine_st.backtrack();
} else {
try_or_throw!(
self.machine_st,
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
);
}
}
&Instruction::ExecuteFastCallN(arity) => {
@@ -5208,11 +5209,6 @@ impl Machine {
if self.machine_st.fail {
self.machine_st.backtrack();
} else {
try_or_throw!(
self.machine_st,
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
);
}
}
&Instruction::CallGetClauseP => {

View File

@@ -753,14 +753,16 @@ impl Machine {
match &indexing_lines[self.machine_st.oip as usize] {
IndexingLine::IndexedChoice(indexed_choice) => {
match &indexed_choice[(self.machine_st.iip + inner_offset) as usize] {
&IndexedChoiceInstruction::Retry(o) => {
&IndexedChoiceInstruction::Retry(o) |
&IndexedChoiceInstruction::DefaultRetry(o) => {
if self.next_clause_applicable(self.machine_st.p + o) {
return Some(inner_offset);
}
inner_offset += 1;
}
&IndexedChoiceInstruction::Trust(o) => {
&IndexedChoiceInstruction::Trust(o) |
&IndexedChoiceInstruction::DefaultTrust(o) => {
return if self.next_clause_applicable(self.machine_st.p + o) {
Some(inner_offset)
} else {
@@ -1268,4 +1270,4 @@ impl Machine {
}
}
}
}
}

View File

@@ -1205,11 +1205,13 @@ impl Machine {
match &indexed_choice[p] {
&IndexedChoiceInstruction::Try(offset) |
&IndexedChoiceInstruction::Retry(offset) => {
&IndexedChoiceInstruction::Retry(offset) |
&IndexedChoiceInstruction::DefaultRetry(offset) => {
let clause_clause_loc = skeleton.core.clause_clause_locs[p];
(clause_clause_loc, bp + offset)
}
&IndexedChoiceInstruction::Trust(_) => {
&IndexedChoiceInstruction::Trust(_) |
&IndexedChoiceInstruction::DefaultTrust(_) => {
unreachable!()
}
}