Ejemplo n.º 1
0
/* A couple ways to speed this up:
   - inline push_constituents
   - Cache the stack pointer, stack bottom, and stack limit in
     register variables to avoid the loads and stores; compiler is
     unlikely to do this.
   - Back-to-back push/pop pairs, like when pushing the car of a pair
     and then looping around to pop it again can be joined.
   */
static void mark_from_stack( msgc_context_t *context )
{
  word w;
  word first = (word)context->lowest_heap_address;
  word *bitmap = context->bitmap;
  int traced=0, marked=0, words_marked=0;
  bool already_marked;

  while (! context->signal_stop) {
    /* Pop */
    if (context->stack.stkp == context->stack.stkbot)  /* Stack underflow */
      if (!pop_segment( &context->stack )) {
        if (fill_from_los_stack( context ))
          continue;
        else
          break;
      }
    w = *--context->stack.stkp;
    traced++;

    /* Mark */
    already_marked = my_mark_object( context, w );
    if (already_marked) continue;
    marked++;

    words_marked += push_constituents( context, w );
  }
  context->traced += traced;
  context->marked += marked;
  context->words_marked += words_marked;
}
Ejemplo n.º 2
0
/* A couple ways to speed this up:
   - inline push_constituents
   - Cache the stack pointer, stack bottom, and stack limit in
     register variables to avoid the loads and stores; compiler is
     unlikely to do this.
   - Back-to-back push/pop pairs, like when pushing the car of a pair
     and then looping around to pop it again can be joined.
   */
static void mark_from_stack( msgc_context_t *context )
{
  word w, bit_idx, word_idx, bit;
  word first = (word)context->lowest_heap_address;
  word *bitmap = context->bitmap;
  int traced=0, marked=0, words_marked=0;

  while (1) {
    /* Pop */
    if (context->stack.stkp == context->stack.stkbot)  /* Stack underflow */
      if (!pop_segment( &context->stack )) 
        if (fill_from_los_stack( context ))
          continue;
        else
          break;
    w = *--context->stack.stkp;
    traced++;

    /* Mark */
    /* Note: marks object only, not entire address range occupied
       by object.  A "real" collector must mark the range.
       */
    bit_idx = (w - first) >> BIT_IDX_SHIFT;
    word_idx = bit_idx >> BITS_TO_WORDS;
    bit = 1 << (bit_idx & BIT_IN_WORD_MASK);
    if (bitmap[ word_idx ] & bit) continue; /* Already marked */
    bitmap[ word_idx ] |= bit;
    marked++;

    words_marked += push_constituents( context, w );
  }
  context->traced += traced;
  context->marked += marked;
  context->words_marked += words_marked;
}