From: Mark Thom Date: Fri, 12 Feb 2021 02:21:20 +0000 (-0700) Subject: Box LoadStatePayload when storing it in the heap X-Git-Tag: v0.9.0~150^2~53 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=72c1a0222c7daedae5bab154b4a8c487d7dad222;p=scryer-prolog.git Box LoadStatePayload when storing it in the heap --- diff --git a/src/machine/loader.rs b/src/machine/loader.rs index 95a1f13a..07b00e20 100644 --- a/src/machine/loader.rs +++ b/src/machine/loader.rs @@ -1098,7 +1098,7 @@ impl Machine { #[inline] pub(crate) fn push_load_state_payload(&mut self) { - let payload = LoadStatePayload::new(self); + let payload = Box::new(LoadStatePayload::new(self)); let addr = Addr::LoadStatePayload( self.machine_st .heap @@ -1171,7 +1171,8 @@ impl Machine { ) { match result { Ok(payload) => { - self.machine_st.heap[evacuable_h] = HeapCellValue::LoadStatePayload(payload); + self.machine_st.heap[evacuable_h] = + HeapCellValue::LoadStatePayload(Box::new(payload)); } Err(e) => { self.throw_session_error(e, (clause_name!("load"), 1)); @@ -1785,7 +1786,7 @@ impl<'a> Loader<'a, LiveTermStream> { pub(super) fn from_load_state_payload( wam: &'a mut Machine, - mut payload: LoadStatePayload, + mut payload: Box, ) -> Self { Loader { term_stream: mem::replace( diff --git a/src/machine/machine_indices.rs b/src/machine/machine_indices.rs index cb39fede..b72fff67 100644 --- a/src/machine/machine_indices.rs +++ b/src/machine/machine_indices.rs @@ -311,7 +311,7 @@ pub enum HeapCellValue { Atom(ClauseName, Option), DBRef(DBRef), Integer(Rc), - LoadStatePayload(LoadStatePayload), + LoadStatePayload(Box), NamedStr(usize, ClauseName, Option), // arity, name, precedence/Specifier if it has one. Rational(Rc), PartialString(PartialString, bool), // the partial string, a bool indicating whether it came from a Constant. @@ -324,10 +324,10 @@ impl HeapCellValue { pub fn as_addr(&self, focus: usize) -> Addr { match self { HeapCellValue::Addr(ref a) => *a, - HeapCellValue::Atom(..) - | HeapCellValue::DBRef(..) - | HeapCellValue::Integer(..) - | HeapCellValue::Rational(..) => Addr::Con(focus), + HeapCellValue::Atom(..) | + HeapCellValue::DBRef(..) | + HeapCellValue::Integer(..) | + HeapCellValue::Rational(..) => Addr::Con(focus), HeapCellValue::LoadStatePayload(_) => Addr::LoadStatePayload(focus), HeapCellValue::NamedStr(_, _, _) => Addr::Str(focus), HeapCellValue::PartialString(..) => Addr::PStrLocation(focus, 0),