Garbage collection in STk.

From: Paul Anderson <>
Date: Wed, 05 Apr 2000 12:17:40 -0400


We encountered and have fixed another couple of problems
with the STk garbage collector. I wanted to let you know
about them, and to solicit your advice on how best to have
a general fix for the second.

Our implementation is still based on version 3.99.4.

The first problem was that the longjmp solution for
marking the registers does not work for the x86 platform -
it misses some of the registers. The fix for this
was easy - we copy the relevant registers to local variables
in gc_mark_and_sweep, and mark them individually.

Paul Anderson. GrammaTech, Inc. Tel: +1 607 273-7340

#ifdef PURE_WIN32
  static DWORD REG_EAX;
  static DWORD REG_EBX;
  static DWORD REG_ECX;
  static DWORD REG_EDX;
  static DWORD REG_EBP;
  static DWORD REG_ESI;
  static DWORD REG_EDI;
static void mark_one_DWORD(DWORD* ptr){
        STk_mark_stack((SCM *)ptr, (SCM *) (ptr+1));
#endif /* PURE_WIN32 */

static void gc_mark_and_sweep(void)
  long prev_context = STk_err_handler->context;

  SCM stack_end; /* The topmost variable (at least a SCM) allocated on stack */

  /**** Disallow interrupts while GC'ing because signal handlers may cons */
  STk_err_handler->context = ERR_FATAL;

  /**** Marking phase */
#ifdef PURE_WIN32
          __asm mov REG_EAX, eax
        __asm mov REG_EBX, ebx
        __asm mov REG_ECX, ecx
        __asm mov REG_EDX, edx
        __asm mov REG_EBP, ebp
        __asm mov REG_ESI, esi
        __asm mov REG_EDI, edi
#endif /* PURE_WIN32 */
  STk_mark_stack((SCM *) STk_stack_start_ptr, (SCM *) &stack_end); /* stack */
  mark_protected(); /* globals */

  /**** Sweep phase */

  /* Re-allow signals */
  STk_err_handler->context = prev_context;

  /* send the pseudo-signal SIGHADGC to say that we had a finished GC'ing */
Received on Wed Apr 05 2000 - 18:19:18 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST