Revert "wip: test interpret_with_guard"

This reverts commit fcb1ba51da.
This commit is contained in:
Matthew LeVan 2024-02-15 14:32:37 -05:00
parent 8bcbf6adca
commit 77ec530c7c
3 changed files with 504 additions and 499 deletions

View File

@ -1,5 +1,5 @@
use crate::interpreter::{interpret, Context, Error, Mote, Result};
use crate::noun::{Noun, D};
use crate::interpreter::{Error, Mote, Result};
use crate::noun::D;
use ares_guard::*;
use assert_no_alloc::permit_alloc;
use std::convert::TryFrom;
@ -98,10 +98,3 @@ pub fn call_with_guard<F: FnMut() -> Result>(
}
}
}
pub fn interpret_with_guard(context: &mut Context, eve: Noun, lyf: Noun) -> Result {
let stack_pp = context.stack.get_stack_pointer_pointer() as *const *const u64;
let alloc_pp = context.stack.get_alloc_pointer_pointer() as *const *const u64;
call_with_guard(stack_pp, alloc_pp, &mut || interpret(context, eve, lyf))
}

View File

@ -1,6 +1,7 @@
use crate::assert_acyclic;
use crate::assert_no_forwarding_pointers;
use crate::assert_no_junior_pointers;
use crate::guard::call_with_guard;
use crate::hamt::Hamt;
use crate::jets::cold;
use crate::jets::cold::Cold;
@ -401,7 +402,10 @@ pub fn interpret(context: &mut Context, mut subject: Noun, formula: Noun) -> Res
//
// (See https://docs.rs/assert_no_alloc/latest/assert_no_alloc/#advanced-use)
let nock = assert_no_alloc(|| {
ensure_alloc_counters(|| unsafe {
ensure_alloc_counters(|| {
let stack_pp = context.stack.get_stack_pointer_pointer() as *const *const u64;
let alloc_pp = context.stack.get_alloc_pointer_pointer() as *const *const u64;
let work_f = &mut || unsafe {
push_formula(&mut context.stack, formula, true)?;
loop {
@ -827,9 +831,9 @@ pub fn interpret(context: &mut Context, mut subject: Noun, formula: Noun) -> Res
},
NockWork::Work11S(mut sint) => match sint.todo {
Todo11S::ComputeResult => {
if let Some(ret) =
hint::match_pre_nock(context, subject, sint.tag, None, sint.body)
{
if let Some(ret) = hint::match_pre_nock(
context, subject, sint.tag, None, sint.body,
) {
match ret {
Ok(found) => {
res = found;
@ -903,12 +907,17 @@ pub fn interpret(context: &mut Context, mut subject: Noun, formula: Noun) -> Res
break Err(Error::ScryCrashed(D(0)));
}
}
Right(cell) => match cell.tail().as_either_atom_cell() {
Right(cell) => {
match cell.tail().as_either_atom_cell() {
Left(_) => {
let stack = &mut context.stack;
let hunk = T(
stack,
&[D(tas!(b"hunk")), scry.reff, scry.path],
&[
D(tas!(b"hunk")),
scry.reff,
scry.path,
],
);
mean_push(stack, hunk);
break Err(Error::ScryCrashed(D(0)));
@ -918,7 +927,8 @@ pub fn interpret(context: &mut Context, mut subject: Noun, formula: Noun) -> Res
context.scry_stack = scry_stack;
context.stack.pop::<NockWork>();
}
},
}
}
},
Err(error) => match error {
Error::Deterministic(_, trace)
@ -941,6 +951,9 @@ pub fn interpret(context: &mut Context, mut subject: Noun, formula: Noun) -> Res
},
};
}
};
call_with_guard(stack_pp, alloc_pp, work_f)
})
});

View File

@ -1,5 +1,4 @@
use crate::hamt::Hamt;
use crate::guard::interpret_with_guard;
use crate::interpreter;
use crate::interpreter::{inc, interpret, Error, Mote};
use crate::jets::cold::Cold;
@ -144,7 +143,7 @@ impl Context {
snapshot: Option<Snapshot>,
constant_hot_state: &[HotEntry],
) -> Self {
let mut stack = NockStack::new(128 << 10 << 10, 0);
let mut stack = NockStack::new(2048 << 10 << 10, 0);
let newt = Newt::new();
let cache = Hamt::<Noun>::new(&mut stack);
@ -403,7 +402,7 @@ fn slam(context: &mut Context, axis: u64, ovo: Noun) -> Result<Noun, Error> {
let fol = T(stack, &[D(8), pul, D(9), D(2), D(10), sam, D(0), D(2)]);
let sub = T(stack, &[arvo, ovo]);
interpret_with_guard(&mut context.nock_context, sub, fol)
interpret(&mut context.nock_context, sub, fol)
}
fn peek(context: &mut Context, ovo: Noun) -> Noun {