]> Repositorios git - scryer-prolog.git/commitdiff
don't hold on to popped or frames
authorMark Thom <[email protected]>
Tue, 21 Jan 2020 03:59:30 +0000 (20:59 -0700)
committerMark Thom <[email protected]>
Tue, 21 Jan 2020 03:59:30 +0000 (20:59 -0700)
src/prolog/machine/machine_state.rs
src/prolog/machine/machine_state_impl.rs
src/prolog/machine/stack.rs

index 134b2924d8663a75f173fc55f42b14b88cfba893..0574910546528bab80e835d99c6f80d082e6d3d9 100644 (file)
@@ -552,7 +552,7 @@ pub(crate) trait CallPolicy: Any {
             attr_var_init_queue_b,
             attr_var_init_bindings_b);
 
-        machine_st.truncate_stack();
+        machine_st.stack.truncate(machine_st.b);
         machine_st.b = machine_st.stack.index_or_frame(b).prelude.b;
 
         machine_st.hb = machine_st.heap.h;
@@ -600,7 +600,7 @@ pub(crate) trait CallPolicy: Any {
             attr_var_init_bindings_b,
         );
 
-        machine_st.truncate_stack();
+        machine_st.stack.truncate(machine_st.b);
         machine_st.b = machine_st.stack.index_or_frame(b).prelude.b;
 
         machine_st.hb = machine_st.heap.h;
index 11894901f9940d708e764d1c62a0e7665cb053a9..57aeab5dcf3eb373f4dc3e995a07dfd8b570ef78 100644 (file)
@@ -2077,12 +2077,6 @@ impl MachineState {
         self.fail = true;
     }
 
-    pub(super) fn truncate_stack(&mut self) {
-        if self.b > self.e {
-            self.stack.truncate_to_frame(self.b);
-        }
-    }
-
     pub(crate) fn is_cyclic_term(&self, addr: Addr) -> bool {
         let mut seen = IndexSet::new();
         let mut fail = false;
index 2de3582db473ab7cdd37a115c4501071fa2b9215..a95517561f01b7e00352c3d5e6ac2fa6d7e5b1c2 100644 (file)
@@ -321,18 +321,15 @@ impl Stack {
         }
     }
 
-    pub fn truncate_to_frame(&mut self, b: usize) {
+    pub fn truncate(&mut self, b: usize) {
         if b == 0 {
-            self.truncate(mem::align_of::<Addr>());
+            self.inner_truncate(mem::align_of::<Addr>());
         } else {
-            let univ_prelude = self.index_or_frame(b).prelude.univ_prelude;
-            let size = OrFrame::size_of(univ_prelude.num_cells);
-
-            self.truncate(b + size);
+            self.inner_truncate(b);
         }
     }
 
-    fn truncate(&mut self, b: usize) {
+    fn inner_truncate(&mut self, b: usize) {
         let mut b = b + self.base as usize;
         let base =  b;