mirror of
https://github.com/urbit/ares.git
synced 2024-11-23 00:25:49 +03:00
Merge branch 'status' into trace
This commit is contained in:
commit
54a9ec980f
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*.jam binary
|
||||
*.pill binary
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
||||
ships/
|
||||
*.backup
|
||||
urbit
|
||||
*.jam.out
|
||||
|
@ -171,11 +171,7 @@ impl<T: Copy> Copy for Stem<T> {}
|
||||
|
||||
impl<T: Copy> Clone for Stem<T> {
|
||||
fn clone(&self) -> Self {
|
||||
Stem {
|
||||
bitmap: self.bitmap,
|
||||
typemap: self.typemap,
|
||||
buffer: self.buffer,
|
||||
}
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
@ -231,10 +227,7 @@ impl<T: Copy> Copy for Leaf<T> {}
|
||||
|
||||
impl<T: Copy> Clone for Leaf<T> {
|
||||
fn clone(&self) -> Self {
|
||||
Leaf {
|
||||
len: self.len,
|
||||
buffer: self.buffer,
|
||||
}
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -99,7 +99,7 @@ pub fn get_jet_test_mode(_jet_name: Noun) -> bool {
|
||||
pub mod util {
|
||||
use super::*;
|
||||
use crate::noun::Error::NotRepresentable;
|
||||
use crate::noun::{Noun, Atom, DirectAtom, IndirectAtom, Cell, D};
|
||||
use crate::noun::{Atom, Cell, DirectAtom, IndirectAtom, Noun, D};
|
||||
use bitvec::prelude::{BitSlice, Lsb0};
|
||||
use ibig::UBig;
|
||||
use std::result;
|
||||
@ -249,12 +249,7 @@ pub mod util {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn rip(
|
||||
stack: &mut NockStack,
|
||||
bloq: usize,
|
||||
step: usize,
|
||||
atom: Atom
|
||||
) -> Result {
|
||||
pub fn rip(stack: &mut NockStack, bloq: usize, step: usize, atom: Atom) -> Result {
|
||||
let len = (met(bloq, atom) + step - 1) / step;
|
||||
let mut list = D(0);
|
||||
for i in (0..len).rev() {
|
||||
|
@ -110,6 +110,10 @@ pub fn jet_cut(
|
||||
let run = slot(arg, 13)?.as_direct()?.data() as usize;
|
||||
let atom = slot(arg, 7)?.as_atom()?;
|
||||
|
||||
if run == 0 {
|
||||
return Ok(D(0));
|
||||
}
|
||||
|
||||
let new_indirect = unsafe {
|
||||
let (mut new_indirect, new_slice) =
|
||||
IndirectAtom::new_raw_mut_bitslice(stack, bite_to_word(bloq, run)?);
|
||||
@ -519,6 +523,9 @@ mod tests {
|
||||
fn test_cut() {
|
||||
let s = &mut init_stack();
|
||||
let (_a0, a24, _a63, a96, a128) = atoms(s);
|
||||
let run = T(s, &[D(0), D(0)]);
|
||||
let sam = T(s, &[D(0), run, a24]);
|
||||
assert_jet(s, jet_cut, sam, D(0));
|
||||
let run = T(s, &[D(0), D(5)]);
|
||||
let sam = T(s, &[D(0), run, a24]);
|
||||
assert_jet(s, jet_cut, sam, D(0x3));
|
||||
|
@ -21,7 +21,7 @@ pub fn jet_mink(
|
||||
let v_subject = slot(arg, 4)?;
|
||||
let v_formula = slot(arg, 5)?;
|
||||
let _scry = slot(arg, 3)?;
|
||||
|
||||
|
||||
match interpret(stack, newt, v_subject, v_formula) {
|
||||
Ok(res) => Ok(T(stack, &[D(0), res])),
|
||||
Err(err) => match err {
|
||||
@ -32,11 +32,11 @@ pub fn jet_mink(
|
||||
}
|
||||
|
||||
pub mod util {
|
||||
use crate::jets::{JetErr, Result, jet_mink};
|
||||
use crate::jets::util::rip;
|
||||
use crate::jets::{jet_mink, JetErr, Result};
|
||||
use crate::mem::NockStack;
|
||||
use crate::newt::Newt;
|
||||
use crate::noun::{Noun, D, T, tape};
|
||||
use crate::noun::{tape, Noun, D, T};
|
||||
use ares_macros::tas;
|
||||
|
||||
const LEAF: Noun = D(tas!(b"leaf"));
|
||||
@ -48,7 +48,7 @@ pub mod util {
|
||||
stack: &mut NockStack,
|
||||
newt: &mut Option<&mut Newt>,
|
||||
tone: Noun,
|
||||
flop: bool
|
||||
flop: bool,
|
||||
) -> Result {
|
||||
let temp = tone.as_cell()?;
|
||||
let tag = temp.head().as_direct()?;
|
||||
@ -57,11 +57,11 @@ pub mod util {
|
||||
if tag.data() < 2 {
|
||||
return Ok(tone);
|
||||
} else if tag.data() > 2 {
|
||||
return Err(JetErr::Deterministic)
|
||||
return Err(JetErr::Deterministic);
|
||||
}
|
||||
|
||||
// XX: trim traces longer than 1024 frames
|
||||
|
||||
|
||||
if flop {
|
||||
let mut list = original_list;
|
||||
let mut res = D(0);
|
||||
@ -74,7 +74,7 @@ pub mod util {
|
||||
let trace = cell.head().as_cell()?;
|
||||
let tag = trace.head().as_direct()?;
|
||||
let dat = trace.tail();
|
||||
|
||||
|
||||
let tank: Noun = match tag.data() {
|
||||
tas!(b"mean") => {
|
||||
if let Ok(atom) = dat.as_atom() {
|
||||
@ -94,7 +94,7 @@ pub mod util {
|
||||
tone.tail()
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
tas!(b"spot") => {
|
||||
let subj = T(stack, &[D(0), dat, D(0)]);
|
||||
let tone = jet_mink(stack, newt, subj)?.as_cell()?;
|
||||
@ -117,31 +117,52 @@ pub mod util {
|
||||
// XX: numbers not +scow-ed
|
||||
let text = format!(
|
||||
"<[{} {}.{} {}]>",
|
||||
pstr.head().as_atom()?.as_either().either(|l| l.data().to_string(), |r| r.as_ubig(stack).to_string()),
|
||||
pstr.tail().as_atom()?.as_either().either(|l| l.data().to_string(), |r| r.as_ubig(stack).to_string()),
|
||||
pend.head().as_atom()?.as_either().either(|l| l.data().to_string(), |r| r.as_ubig(stack).to_string()),
|
||||
pend.tail().as_atom()?.as_either().either(|l| l.data().to_string(), |r| r.as_ubig(stack).to_string())
|
||||
pstr.head().as_atom()?.as_either().either(
|
||||
|l| l.data().to_string(),
|
||||
|r| r.as_ubig(stack).to_string()
|
||||
),
|
||||
pstr.tail().as_atom()?.as_either().either(
|
||||
|l| l.data().to_string(),
|
||||
|r| r.as_ubig(stack).to_string()
|
||||
),
|
||||
pend.head().as_atom()?.as_either().either(
|
||||
|l| l.data().to_string(),
|
||||
|r| r.as_ubig(stack).to_string()
|
||||
),
|
||||
pend.tail().as_atom()?.as_either().either(
|
||||
|l| l.data().to_string(),
|
||||
|r| r.as_ubig(stack).to_string()
|
||||
)
|
||||
);
|
||||
let tape = tape(stack, &text);
|
||||
let finn = T(stack, &[LEAF, tape]);
|
||||
|
||||
T(stack, &[ROSE, trel, smyt, finn])
|
||||
}
|
||||
},
|
||||
}
|
||||
_ => {
|
||||
let tape = rip(stack, 3, 1, tag.as_atom())?;
|
||||
T(stack, &[D(tas!(b"m")), D(tas!(b"o")), D(tas!(b"o")), D(tas!(b"k")), D(tas!(b".")), tape])
|
||||
}
|
||||
// XX: TODO
|
||||
// %hand
|
||||
// %hunk
|
||||
// %lose
|
||||
T(
|
||||
stack,
|
||||
&[
|
||||
D(tas!(b"m")),
|
||||
D(tas!(b"o")),
|
||||
D(tas!(b"o")),
|
||||
D(tas!(b"k")),
|
||||
D(tas!(b".")),
|
||||
tape,
|
||||
],
|
||||
)
|
||||
} // XX: TODO
|
||||
// %hand
|
||||
// %hunk
|
||||
// %lose
|
||||
};
|
||||
|
||||
|
||||
res = T(stack, &[tank, res]);
|
||||
list = cell.tail();
|
||||
}
|
||||
|
||||
|
||||
Ok(res)
|
||||
} else {
|
||||
// XX: need non-tail recursive helper to build +mook without +flop, because no helper in noun.rs to allocate Cell and set tail later (like u3i_defcons in Vere)
|
||||
@ -153,13 +174,13 @@ pub mod util {
|
||||
let lash = D(tas!(b"/"));
|
||||
let zero = D(0);
|
||||
let sep = T(stack, &[lash, zero]);
|
||||
|
||||
|
||||
let trel = T(stack, &[sep, sep, zero]);
|
||||
let tank = smyt_help(stack, path)?;
|
||||
|
||||
Ok(T(stack, &[ROSE, trel, tank]))
|
||||
}
|
||||
|
||||
|
||||
fn smyt_help(stack: &mut NockStack, path: Noun) -> Result {
|
||||
// XX: Need deferred Cell allocation, like u3i_defcons in Vere
|
||||
if unsafe { path.raw_equals(D(0)) } {
|
||||
|
@ -1,4 +1,3 @@
|
||||
#[macro_use]
|
||||
extern crate num_derive;
|
||||
#[macro_use]
|
||||
extern crate static_assertions;
|
||||
@ -36,9 +35,21 @@ macro_rules! gdb {
|
||||
};
|
||||
}
|
||||
|
||||
// #[cfg(debug_assertions)]
|
||||
// #[global_allocator]
|
||||
// static A: assert_no_alloc::AllocDisabler = assert_no_alloc::AllocDisabler;
|
||||
// Use the allocator from assert_no_alloc.
|
||||
//
|
||||
// DO NOT COMMENT THIS OUT
|
||||
//
|
||||
// if you need to allow allocations somewhere for debugging, wrap your debug code in
|
||||
// ```
|
||||
// permit_alloc( || {
|
||||
// your.code.goes.here()
|
||||
// })
|
||||
// ```
|
||||
//
|
||||
// (see https://docs.rs/assert_no_alloc/latest/assert_no_alloc/#advanced-use)
|
||||
#[cfg(debug_assertions)]
|
||||
#[global_allocator]
|
||||
static A: assert_no_alloc::AllocDisabler = assert_no_alloc::AllocDisabler;
|
||||
|
||||
pub(crate) use gdb;
|
||||
|
||||
@ -52,4 +63,17 @@ mod tests {
|
||||
assert_eq!(tas!(b"dec"), 0x636564);
|
||||
assert_eq!(tas!(b"prop"), 0x706f7270);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_jam() {
|
||||
use crate::mem::NockStack;
|
||||
use crate::noun::*;
|
||||
use crate::serialization::jam;
|
||||
let mut stack = NockStack::new(8 << 10 << 10, 0);
|
||||
let head = Atom::new(&mut stack, 0).as_noun();
|
||||
let tail = Atom::new(&mut stack, 1).as_noun();
|
||||
let cell = Cell::new(&mut stack, head, tail).as_noun();
|
||||
let res = jam(&mut stack, cell).as_direct().unwrap().data();
|
||||
assert_eq!(res, 201);
|
||||
}
|
||||
}
|
||||
|
@ -290,12 +290,13 @@ impl NockStack {
|
||||
let alloc = *self.prev_alloc_pointer_pointer();
|
||||
*(self.prev_alloc_pointer_pointer()) =
|
||||
(*(self.prev_alloc_pointer_pointer())).add(words + 2);
|
||||
alloc as *mut u64
|
||||
alloc
|
||||
}
|
||||
|
||||
unsafe fn indirect_alloc_in_previous_frame_east(&mut self, words: usize) -> *mut u64 {
|
||||
*(self.prev_alloc_pointer_pointer()) = *(self.prev_alloc_pointer_pointer()).sub(words + 2);
|
||||
*self.prev_alloc_pointer_pointer() as *mut u64
|
||||
*(self.prev_alloc_pointer_pointer()) =
|
||||
(*(self.prev_alloc_pointer_pointer())).sub(words + 2);
|
||||
*self.prev_alloc_pointer_pointer()
|
||||
}
|
||||
|
||||
/** Allocate space for an indirect atom in the previous stack frame. This call pre_copy()
|
||||
@ -528,9 +529,9 @@ impl NockStack {
|
||||
}
|
||||
|
||||
pub unsafe fn frame_pop(&mut self) {
|
||||
let prev_frame_ptr = *self.prev_frame_pointer_pointer() as *mut u64;
|
||||
let prev_stack_ptr = *self.prev_stack_pointer_pointer() as *mut u64;
|
||||
let prev_alloc_ptr = *self.prev_alloc_pointer_pointer() as *mut u64;
|
||||
let prev_frame_ptr = *self.prev_frame_pointer_pointer();
|
||||
let prev_stack_ptr = *self.prev_stack_pointer_pointer();
|
||||
let prev_alloc_ptr = *self.prev_alloc_pointer_pointer();
|
||||
|
||||
self.frame_pointer = prev_frame_ptr;
|
||||
self.stack_pointer = prev_stack_ptr;
|
||||
|
@ -120,6 +120,7 @@ pub fn mug_u32(stack: &mut NockStack, noun: Noun) -> u32 {
|
||||
return mug;
|
||||
}
|
||||
assert_acyclic!(noun);
|
||||
stack.frame_push(0);
|
||||
unsafe {
|
||||
*(stack.push()) = noun;
|
||||
}
|
||||
@ -167,6 +168,9 @@ pub fn mug_u32(stack: &mut NockStack, noun: Noun) -> u32 {
|
||||
}
|
||||
}
|
||||
}
|
||||
unsafe {
|
||||
stack.frame_pop();
|
||||
}
|
||||
get_mug(noun).expect("Noun should have a mug once it is mugged.")
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ impl Newt {
|
||||
Either::Left(direct) => unsafe {
|
||||
copy_nonoverlapping(
|
||||
&direct.data() as *const u64 as *const u8,
|
||||
buf.as_mut_ptr().add(5) as *mut u8,
|
||||
buf.as_mut_ptr().add(5),
|
||||
size,
|
||||
);
|
||||
},
|
||||
@ -99,7 +99,7 @@ impl Newt {
|
||||
// REVIEW: is this safe/the right way to do this?
|
||||
copy_nonoverlapping(
|
||||
indirect.data_pointer() as *const u8,
|
||||
buf.as_mut_ptr().add(5) as *mut u8,
|
||||
buf.as_mut_ptr().add(5),
|
||||
size,
|
||||
);
|
||||
},
|
||||
|
@ -383,11 +383,11 @@ impl IndirectAtom {
|
||||
|
||||
/** Pointer to data for indirect atom */
|
||||
pub fn data_pointer(&self) -> *const u64 {
|
||||
unsafe { self.to_raw_pointer().add(2) as *const u64 }
|
||||
unsafe { self.to_raw_pointer().add(2) }
|
||||
}
|
||||
|
||||
pub fn data_pointer_mut(&mut self) -> *mut u64 {
|
||||
unsafe { self.to_raw_pointer_mut().add(2) as *mut u64 }
|
||||
unsafe { self.to_raw_pointer_mut().add(2) }
|
||||
}
|
||||
|
||||
pub fn as_slice(&self) -> &[u64] {
|
||||
@ -803,11 +803,11 @@ impl Allocated {
|
||||
}
|
||||
|
||||
pub unsafe fn get_metadata(&self) -> u64 {
|
||||
*(self.to_raw_pointer() as *const u64)
|
||||
*(self.to_raw_pointer())
|
||||
}
|
||||
|
||||
pub unsafe fn set_metadata(self, metadata: u64) {
|
||||
*(self.const_to_raw_pointer_mut() as *mut u64) = metadata;
|
||||
*(self.const_to_raw_pointer_mut()) = metadata;
|
||||
}
|
||||
|
||||
pub fn as_either(&self) -> Either<IndirectAtom, Cell> {
|
||||
@ -1117,11 +1117,29 @@ pub trait Slots: private::RawSlots {
|
||||
*/
|
||||
fn slot(&self, axis: u64) -> Result<Noun> {
|
||||
if axis == 0 {
|
||||
Err(Error::NotRepresentable) // 0 is not allowed as an axis
|
||||
// 0 is not allowed as an axis
|
||||
Err(Error::NotRepresentable)
|
||||
} else {
|
||||
self.raw_slot(DirectAtom::new(axis).unwrap().as_bitslice())
|
||||
self.raw_slot(BitSlice::from_element(&axis))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve component Noun at axis given as Atom, or fail with descriptive error
|
||||
*/
|
||||
fn slot_atom(&self, atom: Atom) -> Result<Noun> {
|
||||
atom.as_either().either(
|
||||
|d| self.slot(d.data()),
|
||||
|i| {
|
||||
if unsafe { i.as_noun().raw_equals(D(0)) } {
|
||||
// 0 is not allowed as an axis
|
||||
Err(Error::NotRepresentable)
|
||||
} else {
|
||||
self.raw_slot(i.as_bitslice())
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,6 +169,7 @@ pub fn jam(stack: &mut NockStack, noun: Noun) -> Atom {
|
||||
atom,
|
||||
slice,
|
||||
};
|
||||
stack.frame_push(0);
|
||||
unsafe {
|
||||
*(stack.push::<Noun>()) = noun;
|
||||
};
|
||||
@ -218,7 +219,12 @@ pub fn jam(stack: &mut NockStack, noun: Noun) -> Atom {
|
||||
}
|
||||
}
|
||||
}
|
||||
unsafe { state.atom.normalize_as_atom() }
|
||||
unsafe {
|
||||
let mut result = state.atom.normalize_as_atom();
|
||||
stack.preserve(&mut result);
|
||||
stack.frame_pop();
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
fn jam_atom(traversal: &mut NockStack, state: &mut JamState, atom: Atom) {
|
||||
|
1
rust/ares/test_data/repeat5_10.jam
Normal file
1
rust/ares/test_data/repeat5_10.jam
Normal file
@ -0,0 +1 @@
|
||||
U,6<16>]И%vТ|cЕ7H<37>Ђ<>цИ29H<39>Ђ9<D082>h<EFBFBD>D;б<>
|
1
rust/ares/test_data/repeat5_100.jam
Normal file
1
rust/ares/test_data/repeat5_100.jam
Normal file
@ -0,0 +1 @@
|
||||
U,6<16>]И%vТ|cЕ7H<37>Ђ<>цИ29H<39>Ђ9<D082><39><EFBFBD>dШ Zи<5A>N$
|
1
rust/ares/test_data/repeat5_1000.jam
Normal file
1
rust/ares/test_data/repeat5_1000.jam
Normal file
@ -0,0 +1 @@
|
||||
U,6<16>]И%vТ|cЕ7H<37>Ђ<>цИ29H<39>Ђ9<05>~<7E>D;б<>
|
1
rust/ares/test_data/repeat5_1000_tc.jam
Normal file
1
rust/ares/test_data/repeat5_1000_tc.jam
Normal file
@ -0,0 +1 @@
|
||||
U,66Vƒ`qØ…[Bý„x‰$CÑ‚x˜ã÷ ZØŸC &É<>ÃhLA¡$CÑÂNt"
|
1
rust/ares/test_data/repeat5_100_tc.jam
Normal file
1
rust/ares/test_data/repeat5_100_tc.jam
Normal file
@ -0,0 +1 @@
|
||||
U,66V<36>`qŘ…[Bý„x‰$CŃ‚x<E2809A>ă÷ ZŘŸC &É<>ĂhLáä 2<>v˘
|
1
rust/ares/test_data/repeat5_10_tc.jam
Normal file
1
rust/ares/test_data/repeat5_10_tc.jam
Normal file
@ -0,0 +1 @@
|
||||
U,66Vƒ`qØ…[Bý„x‰$CÑ‚x˜ã÷ ZØŸC &É<>ÃhL!$CÑÂNt"
|
BIN
rust/ares/test_data/shax.jam
Normal file
BIN
rust/ares/test_data/shax.jam
Normal file
Binary file not shown.
@ -5,10 +5,10 @@
|
||||
"homepage": "",
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"rev": "b2795124606227326e336062f7d2240446c9ae2b",
|
||||
"sha256": "0x77p2q4w58bmfvpxxks46vbi3zl8142mjqy7xap7nr1a06a262h",
|
||||
"rev": "b2f49e4f86582a8e3015f9cc4b869a9c9a28b3cf",
|
||||
"sha256": "1llz3jkz3a6xkb8yz4nsraxaxgq17mjslbicj6096vylny1gr2z5",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nix-community/fenix/archive/b2795124606227326e336062f7d2240446c9ae2b.tar.gz",
|
||||
"url": "https://github.com/nix-community/fenix/archive/b2f49e4f86582a8e3015f9cc4b869a9c9a28b3cf.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixpkgs": {
|
||||
@ -17,10 +17,10 @@
|
||||
"homepage": "",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "1b82144edfcd0c86486d2e07c7298f85510e7fb8",
|
||||
"sha256": "1qqh8hxynn0mzanmb2impfj4v62kkw6cbxcd6lghk9x4wagc229r",
|
||||
"rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b",
|
||||
"sha256": "1xi53rlslcprybsvrmipm69ypd3g3hr7wkxvzc73ag8296yclyll",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/1b82144edfcd0c86486d2e07c7298f85510e7fb8.tar.gz",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
}
|
||||
}
|
||||
|
@ -13,5 +13,6 @@ pkgs.mkShell {
|
||||
"rust-src"
|
||||
])
|
||||
cargo-watch
|
||||
gdb
|
||||
];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user