revise InstallVerifyAttrs to remove need for predicate scanning (#3175)

This commit is contained in:
Mark Thom
2025-11-25 23:17:22 -08:00
parent f2e044e5b8
commit 4bd16b8a2e
5 changed files with 2227 additions and 1885 deletions

View File

@@ -41,13 +41,13 @@ impl MachineState {
pub(super) fn push_attr_var_binding(&mut self, h: usize, addr: HeapCellValue) {
if self.attr_var_init.bindings.is_empty() {
// save self.p and self.cp and ensure that the next
// instruction is InstallVerifyAttrInterrupt.
// instruction is RunVerifyAttrInterrupt.
self.attr_var_init.p = self.p;
self.attr_var_init.cp = self.cp;
self.p = INSTALL_VERIFY_ATTR_INTERRUPT - 1;
self.cp = INSTALL_VERIFY_ATTR_INTERRUPT;
self.p = VERIFY_ATTR_INTERRUPT_LOC - 1;
self.cp = VERIFY_ATTR_INTERRUPT_LOC;
}
debug_assert_eq!(self.heap[h].get_tag(), HeapCellValueTag::AttrVar);

File diff suppressed because it is too large Load Diff

View File

@@ -141,9 +141,8 @@ mod libraries {
}
pub static BREAK_FROM_DISPATCH_LOOP_LOC: usize = 0;
pub static INSTALL_VERIFY_ATTR_INTERRUPT: usize = 1;
pub static VERIFY_ATTR_INTERRUPT_LOC: usize = 2;
pub static LIB_QUERY_SUCCESS: usize = 3;
pub static VERIFY_ATTR_INTERRUPT_LOC: usize = 1;
pub static LIB_QUERY_SUCCESS: usize = 2;
pub struct MachinePreludeView<'a> {
pub indices: &'a mut IndexStore,
@@ -414,12 +413,11 @@ impl Machine {
}
pub(crate) fn add_impls_to_indices(&mut self) {
let impls_offset = self.code.len() + 4;
let impls_offset = self.code.len() + 3;
self.code.extend(vec![
Instruction::BreakFromDispatchLoop,
Instruction::InstallVerifyAttr,
Instruction::VerifyAttrInterrupt(0),
Instruction::RunVerifyAttr,
Instruction::BreakFromDispatchLoop, // the location of LIB_QUERY_SUCCESS
Instruction::ExecuteTermGreaterThan,
Instruction::ExecuteTermLessThan,

View File

@@ -24,7 +24,7 @@ use crate::machine::machine_state::*;
use crate::machine::partial_string::*;
use crate::machine::stack::*;
use crate::machine::streams::*;
use crate::machine::{get_structure_index, Machine, VERIFY_ATTR_INTERRUPT_LOC};
use crate::machine::{get_structure_index, Machine};
use crate::parser::ast::*;
use crate::parser::char_reader::*;
use crate::parser::dashu::Integer;
@@ -6255,6 +6255,7 @@ impl Machine {
self.machine_st.heap[var.get_value() as usize] = value;
}
/*
#[inline(always)]
pub(super) fn restore_instr_at_verify_attr_interrupt(&mut self) {
match &self.code[VERIFY_ATTR_INTERRUPT_LOC] {
@@ -6269,10 +6270,11 @@ impl Machine {
}
}
}
*/
#[inline(always)]
pub(crate) fn reset_attr_var_state(&mut self, queue_len: usize) {
self.restore_instr_at_verify_attr_interrupt();
// self.restore_instr_at_verify_attr_interrupt();
self.machine_st.attr_var_init.reset(queue_len);
}
@@ -6303,7 +6305,7 @@ impl Machine {
#[inline(always)]
pub(crate) fn return_from_verify_attr(&mut self) {
self.restore_instr_at_verify_attr_interrupt();
// self.restore_instr_at_verify_attr_interrupt();
let e = self.machine_st.e;
let frame_len = self.machine_st.stack.index_and_frame(e).prelude.num_cells;