mirror of
https://github.com/urbit/ares.git
synced 2024-12-23 05:12:15 +03:00
Merge pull request #160 from urbit/eamsden/pass-in-hot
Pass in hot state
This commit is contained in:
commit
1c61e58bc0
@ -19,7 +19,7 @@ use crate::jets::bits::*;
|
|||||||
use crate::jets::cold::Cold;
|
use crate::jets::cold::Cold;
|
||||||
use crate::jets::form::*;
|
use crate::jets::form::*;
|
||||||
use crate::jets::hash::*;
|
use crate::jets::hash::*;
|
||||||
use crate::jets::hot::Hot;
|
use crate::jets::hot::{Hot, URBIT_HOT_STATE};
|
||||||
use crate::jets::list::*;
|
use crate::jets::list::*;
|
||||||
use crate::jets::lute::*;
|
use crate::jets::lute::*;
|
||||||
use crate::jets::math::*;
|
use crate::jets::math::*;
|
||||||
@ -281,7 +281,7 @@ pub mod util {
|
|||||||
let newt = Newt::new_mock();
|
let newt = Newt::new_mock();
|
||||||
let cold = Cold::new(&mut stack);
|
let cold = Cold::new(&mut stack);
|
||||||
let warm = Warm::new();
|
let warm = Warm::new();
|
||||||
let hot = Hot::init(&mut stack);
|
let hot = Hot::init(&mut stack, URBIT_HOT_STATE);
|
||||||
let cache = Hamt::<Noun>::new();
|
let cache = Hamt::<Noun>::new();
|
||||||
|
|
||||||
Context {
|
Context {
|
||||||
|
@ -4,8 +4,9 @@ use ares_macros::tas;
|
|||||||
use either::Either::{self, Left, Right};
|
use either::Either::{self, Left, Right};
|
||||||
use std::ptr::null_mut;
|
use std::ptr::null_mut;
|
||||||
|
|
||||||
// const A_50: Either<u64, (u64, u64)> = Right((b"a", 50));
|
/** Root for Hoon %k.139
|
||||||
const K_139: Either<&[u8], (u64, u64)> = Right((tas!(b"k"), 139));
|
*/
|
||||||
|
pub const K_139: Either<&[u8], (u64, u64)> = Right((tas!(b"k"), 139));
|
||||||
|
|
||||||
// // This is the const state all in one spot as literals
|
// // This is the const state all in one spot as literals
|
||||||
// #[allow(clippy::complexity)]
|
// #[allow(clippy::complexity)]
|
||||||
@ -57,8 +58,14 @@ const K_139: Either<&[u8], (u64, u64)> = Right((tas!(b"k"), 139));
|
|||||||
// (&[A_50, Left(b"mink")], 1, jet_mink),
|
// (&[A_50, Left(b"mink")], 1, jet_mink),
|
||||||
// ];
|
// ];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (path, axis in battery, jet function pointer)
|
||||||
|
* see the [Jet] typedef in ares::jets for the proper prototype
|
||||||
|
*/
|
||||||
|
pub type HotEntry = (&'static [Either<&'static [u8], (u64, u64)>], u64, Jet);
|
||||||
|
|
||||||
#[allow(clippy::complexity)]
|
#[allow(clippy::complexity)]
|
||||||
const TRUE_HOT_STATE: &[(&[Either<&[u8], (u64, u64)>], u64, Jet)] = &[
|
pub const URBIT_HOT_STATE: &[HotEntry] = &[
|
||||||
(&[K_139, Left(b"one"), Left(b"add")], 1, jet_add),
|
(&[K_139, Left(b"one"), Left(b"add")], 1, jet_add),
|
||||||
(&[K_139, Left(b"one"), Left(b"dec")], 1, jet_dec),
|
(&[K_139, Left(b"one"), Left(b"dec")], 1, jet_dec),
|
||||||
(&[K_139, Left(b"one"), Left(b"div")], 1, jet_div),
|
(&[K_139, Left(b"one"), Left(b"div")], 1, jet_div),
|
||||||
@ -595,10 +602,10 @@ const TRUE_HOT_STATE: &[(&[Either<&[u8], (u64, u64)>], u64, Jet)] = &[
|
|||||||
pub struct Hot(*mut HotMem);
|
pub struct Hot(*mut HotMem);
|
||||||
|
|
||||||
impl Hot {
|
impl Hot {
|
||||||
pub fn init(stack: &mut NockStack) -> Self {
|
pub fn init(stack: &mut NockStack, constant_hot_state: &[HotEntry]) -> Self {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut next = Hot(null_mut());
|
let mut next = Hot(null_mut());
|
||||||
for (htap, axe, jet) in TRUE_HOT_STATE {
|
for (htap, axe, jet) in constant_hot_state {
|
||||||
let mut a_path = D(0);
|
let mut a_path = D(0);
|
||||||
for i in *htap {
|
for i in *htap {
|
||||||
match i {
|
match i {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use ares::jets::hot::URBIT_HOT_STATE;
|
||||||
use ares::serf::serf;
|
use ares::serf::serf;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::io;
|
use std::io;
|
||||||
@ -31,7 +32,7 @@ fn main() -> io::Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if filename == "serf" {
|
if filename == "serf" {
|
||||||
return serf();
|
return serf(URBIT_HOT_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
panic!("Ares can only run as a serf!");
|
panic!("Ares can only run as a serf!");
|
||||||
|
@ -2,7 +2,7 @@ use crate::hamt::Hamt;
|
|||||||
use crate::interpreter;
|
use crate::interpreter;
|
||||||
use crate::interpreter::{inc, interpret, Error};
|
use crate::interpreter::{inc, interpret, Error};
|
||||||
use crate::jets::cold::Cold;
|
use crate::jets::cold::Cold;
|
||||||
use crate::jets::hot::Hot;
|
use crate::jets::hot::{Hot, HotEntry};
|
||||||
use crate::jets::list::util::{lent, zing};
|
use crate::jets::list::util::{lent, zing};
|
||||||
use crate::jets::nock::util::mook;
|
use crate::jets::nock::util::mook;
|
||||||
use crate::jets::warm::Warm;
|
use crate::jets::warm::Warm;
|
||||||
@ -38,14 +38,18 @@ struct Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Context {
|
impl Context {
|
||||||
pub fn new(snap_path: &PathBuf, trace_info: Option<TraceInfo>) -> Self {
|
pub fn new(
|
||||||
|
snap_path: &PathBuf,
|
||||||
|
trace_info: Option<TraceInfo>,
|
||||||
|
constant_hot_state: &[HotEntry],
|
||||||
|
) -> Self {
|
||||||
// TODO: switch to Pma when ready
|
// TODO: switch to Pma when ready
|
||||||
// let snap = &mut snapshot::pma::Pma::new(snap_path);
|
// let snap = &mut snapshot::pma::Pma::new(snap_path);
|
||||||
let mut snapshot = DoubleJam::new(snap_path);
|
let mut snapshot = DoubleJam::new(snap_path);
|
||||||
let mut stack = NockStack::new(512 << 10 << 10, 0);
|
let mut stack = NockStack::new(512 << 10 << 10, 0);
|
||||||
|
|
||||||
let cold = Cold::new(&mut stack);
|
let cold = Cold::new(&mut stack);
|
||||||
let hot = Hot::init(&mut stack);
|
let hot = Hot::init(&mut stack, constant_hot_state);
|
||||||
|
|
||||||
let (epoch, event_num, arvo) = snapshot.load(&mut stack).unwrap_or((0, 0, D(0)));
|
let (epoch, event_num, arvo) = snapshot.load(&mut stack).unwrap_or((0, 0, D(0)));
|
||||||
let mug = mug_u32(&mut stack, arvo);
|
let mug = mug_u32(&mut stack, arvo);
|
||||||
@ -176,7 +180,7 @@ lazy_static! {
|
|||||||
* This is suitable for talking to the king process. To test, change the arg_c[0] line in
|
* This is suitable for talking to the king process. To test, change the arg_c[0] line in
|
||||||
* u3_lord_init in vere to point at this binary and start vere like normal.
|
* u3_lord_init in vere to point at this binary and start vere like normal.
|
||||||
*/
|
*/
|
||||||
pub fn serf() -> io::Result<()> {
|
pub fn serf(constant_hot_state: &[HotEntry]) -> io::Result<()> {
|
||||||
// Register SIGINT signal hook to set flag first time, shutdown second time
|
// Register SIGINT signal hook to set flag first time, shutdown second time
|
||||||
signal_hook::flag::register_conditional_shutdown(SIGINT, 1, Arc::clone(&TERMINATOR))?;
|
signal_hook::flag::register_conditional_shutdown(SIGINT, 1, Arc::clone(&TERMINATOR))?;
|
||||||
signal_hook::flag::register(SIGINT, Arc::clone(&TERMINATOR))?;
|
signal_hook::flag::register(SIGINT, Arc::clone(&TERMINATOR))?;
|
||||||
@ -212,7 +216,7 @@ pub fn serf() -> io::Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut context = Context::new(&snap_path, trace_info);
|
let mut context = Context::new(&snap_path, trace_info, constant_hot_state);
|
||||||
context.ripe();
|
context.ripe();
|
||||||
|
|
||||||
// Can't use for loop because it borrows newt
|
// Can't use for loop because it borrows newt
|
||||||
|
Loading…
Reference in New Issue
Block a user