fix marking empty VM continuations
authorAndy Wingo <wingo@pobox.com>
Tue, 13 Jan 2009 21:33:21 +0000 (22:33 +0100)
committerAndy Wingo <wingo@pobox.com>
Tue, 13 Jan 2009 21:33:21 +0000 (22:33 +0100)
* libguile/vm.h (struct scm_vm_cont):
* libguile/vm.c (capture_vm_cont, reinstate_vm_cont): Change so we just
  store the registers as they are, with the reloc.
  (vm_cont_mark): Only mark the stack if it has elements on it, otherwise
  we get a bogus fp.

* libguile/stacks.c (scm_make_stack): Update for change to vm
  continuations.

INSTALL
libguile/stacks.c
libguile/vm.c
libguile/vm.h

diff --git a/INSTALL b/INSTALL
index 5458714..d3c5b40 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -2,7 +2,7 @@ Installation Instructions
 *************************
 
 Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
-2006 Free Software Foundation, Inc.
+2006, 2007 Free Software Foundation, Inc.
 
 This file is free documentation; the Free Software Foundation gives
 unlimited permission to copy, distribute and modify it.
@@ -67,6 +67,9 @@ The simplest way to compile this package is:
      all sorts of other programs in order to regenerate files that came
      with the distribution.
 
+  6. Often, you can also type `make uninstall' to remove the installed
+     files again.
+
 Compilers and Options
 =====================
 
index 85527bd..e3d131d 100644 (file)
@@ -516,8 +516,8 @@ SCM_DEFINE (scm_make_stack, "make-stack", 1, 0, 1,
           vm_cont = scm_cdr (scm_car (cont->vm_conts));
           data = SCM_VM_CONT_DATA (vm_cont);
           vmframe = scm_c_make_vm_frame (vm_cont,
-                                         data->stack_base + data->fp,
-                                         data->stack_base + data->sp,
+                                         data->fp + data->reloc,
+                                         data->sp + data->reloc,
                                          data->ip,
                                          data->reloc);
         } else 
index d75fed8..429c090 100644 (file)
@@ -119,7 +119,8 @@ vm_cont_mark (SCM obj)
 {
   struct scm_vm_cont *p = SCM_VM_CONT_DATA (obj);
 
-  vm_mark_stack (p->stack_base, p->stack_size, p->stack_base + p->fp, p->reloc);
+  if (p->stack_size)
+    vm_mark_stack (p->stack_base, p->stack_size, p->fp + p->reloc, p->reloc);
 
   return SCM_BOOL_F;
 }
@@ -149,8 +150,8 @@ capture_vm_cont (struct scm_vm *vp)
   memset (p->stack_base, 0, p->stack_size * sizeof (SCM));
 #endif
   p->ip = vp->ip;
-  p->sp = vp->sp - vp->stack_base;
-  p->fp = vp->fp - vp->stack_base;
+  p->sp = vp->sp;
+  p->fp = vp->fp;
   memcpy (p->stack_base, vp->stack_base, p->stack_size * sizeof (SCM));
   p->reloc = p->stack_base - vp->stack_base;
   SCM_RETURN_NEWSMOB (scm_tc16_vm_cont, p);
@@ -167,7 +168,7 @@ reinstate_vm_cont (struct scm_vm *vp, SCM cont)
     }
 #ifdef VM_ENABLE_STACK_NULLING
   {
-    scm_t_ptrdiff nzero = (vp->sp - vp->stack_base) - p->sp;
+    scm_t_ptrdiff nzero = (vp->sp - p->sp);
     if (nzero > 0)
       memset (vp->stack_base + p->stack_size, 0, nzero * sizeof (SCM));
     /* actually nzero should always be negative, because vm_reset_stack will
@@ -175,8 +176,8 @@ reinstate_vm_cont (struct scm_vm *vp, SCM cont)
   }
 #endif
   vp->ip = p->ip;
-  vp->sp = vp->stack_base + p->sp;
-  vp->fp = vp->stack_base + p->fp;
+  vp->sp = p->sp;
+  vp->fp = p->fp;
   memcpy (vp->stack_base, p->stack_base, p->stack_size * sizeof (SCM));
 }
 
index 90a2891..d8b6ee2 100644 (file)
@@ -102,8 +102,8 @@ extern SCM scm_vm_trace_frame (SCM vm);
 
 struct scm_vm_cont {
   scm_byte_t *ip;
-  scm_t_ptrdiff sp;
-  scm_t_ptrdiff fp;
+  SCM *sp;
+  SCM *fp;
   scm_t_ptrdiff stack_size;
   SCM *stack_base;
   scm_t_ptrdiff reloc;