mirror of
https://github.com/urbit/ares.git
synced 2024-11-22 15:08:54 +03:00
[ares] assert no allocation during interpret
This commit is contained in:
parent
ff603d01f6
commit
b6b2ee3fb3
7
rust/ares/Cargo.lock
generated
7
rust/ares/Cargo.lock
generated
@ -13,6 +13,7 @@ name = "ares"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ares_macros",
|
||||
"assert_no_alloc",
|
||||
"bitvec",
|
||||
"criterion",
|
||||
"either",
|
||||
@ -33,6 +34,12 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "assert_no_alloc"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55ca83137a482d61d916ceb1eba52a684f98004f18e0cafea230fe5579c178a3"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
|
@ -18,6 +18,7 @@ num-traits = "0.2"
|
||||
num-derive = "0.3"
|
||||
criterion = "0.4"
|
||||
ibig = "0.3.6"
|
||||
assert_no_alloc = "1.1.2"
|
||||
|
||||
[[bin]]
|
||||
name = "cue_pill"
|
||||
|
@ -5,6 +5,7 @@ use crate::mem::NockStack;
|
||||
use crate::newt::Newt;
|
||||
use crate::noun::{Atom, Cell, DirectAtom, IndirectAtom, Noun};
|
||||
use ares_macros::tas;
|
||||
use assert_no_alloc::assert_no_alloc;
|
||||
use bitvec::prelude::{BitSlice, Lsb0};
|
||||
use either::Either::*;
|
||||
use num_traits::cast::{FromPrimitive, ToPrimitive};
|
||||
@ -80,7 +81,7 @@ pub fn interpret(
|
||||
*(stack.local_noun_pointer(0)) = work_to_noun(Done);
|
||||
}
|
||||
push_formula(stack, formula);
|
||||
loop {
|
||||
assert_no_alloc(|| loop {
|
||||
match unsafe { noun_to_work(*(stack.local_noun_pointer(0))) } {
|
||||
Done => {
|
||||
stack.pop(&mut res);
|
||||
@ -350,7 +351,7 @@ pub fn interpret(
|
||||
stack.pop(&mut res);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
res
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ use ares::mem::NockStack;
|
||||
use ares::noun::IndirectAtom;
|
||||
use ares::serf::serf;
|
||||
use ares::serialization::{cue, jam};
|
||||
use assert_no_alloc::AllocDisabler;
|
||||
use memmap::Mmap;
|
||||
use memmap::MmapMut;
|
||||
use std::env;
|
||||
@ -13,6 +14,10 @@ use std::mem;
|
||||
use std::ptr::copy_nonoverlapping;
|
||||
use std::ptr::write_bytes;
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
#[global_allocator]
|
||||
static A: AllocDisabler = AllocDisabler;
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
let filename = env::args().nth(1).expect("Must provide input filename");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user