Garbage collection in STk.

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

Erick:

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
mailto:paul_at_grammatech.com http://www.grammatech.com

#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_ignore_signals();
  STk_err_handler->context = ERR_FATAL;
  gc_start();

  /**** 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
        mark_one_DWORD(&REG_EAX);
        mark_one_DWORD(&REG_EBX);
        mark_one_DWORD(&REG_ECX);
        mark_one_DWORD(&REG_EDX);
        mark_one_DWORD(&REG_EBP);
        mark_one_DWORD(&REG_ESI);
        mark_one_DWORD(&REG_EDI);
#else
  register_scan();
#endif /* PURE_WIN32 */
  STk_mark_stack((SCM *) STk_stack_start_ptr, (SCM *) &stack_end); /* stack */
  mark_protected(); /* globals */

  /**** Sweep phase */
  gc_sweep();

  /* Re-allow signals */
  gc_end();
  STk_err_handler->context = prev_context;
  STk_allow_signals();

  /* send the pseudo-signal SIGHADGC to say that we had a finished GC'ing */
  STk_signal_GC();
}
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