Back to index

plt-scheme  4.2.1
Functions
weak.c File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static int size_weak_array (void *p)
static int mark_weak_array (void *p)
static int fixup_weak_array (void *p)
voidGC_malloc_weak_array (size_t size_in_bytes, void *replace_val)
static void init_weak_arrays (GCTYPE *gc)
static void zero_weak_arrays (GCTYPE *gc)
static int size_weak_box (void *p)
static int mark_weak_box (void *p)
static int fixup_weak_box (void *p)
voidGC_malloc_weak_box (void *p, void **secondary, int soffset)
static void init_weak_boxes (GCTYPE *gc)
static void zero_weak_boxes (GCTYPE *gc)
static int size_ephemeron (void *p)
static int mark_ephemeron (void *p)
static int fixup_ephemeron (void *p)
voidGC_malloc_ephemeron (void *k, void *v)
void init_ephemerons (GCTYPE *gc)
static void mark_ready_ephemerons (GCTYPE *gc)
static void zero_remaining_ephemerons (GCTYPE *gc)

Function Documentation

static int fixup_ephemeron ( void p) [static]

Definition at line 252 of file weak.c.

{
  GC_Ephemeron *eph = (GC_Ephemeron *)p;
    
  gcFIXUP(eph->key);
  gcFIXUP(eph->val);

  return gcBYTES_TO_WORDS(sizeof(GC_Ephemeron));
}

Here is the caller graph for this function:

static int fixup_weak_array ( void p) [static]

Definition at line 67 of file weak.c.

{
  GC_Weak_Array *a = (GC_Weak_Array *)p;
  int i;
  void **data;

  gcFIXUP(a->replace_val);

  data = a->data;
  for (i = a->count; i--; ) {
    if (data[i])
      gcFIXUP(data[i]);
  }

  return gcBYTES_TO_WORDS(sizeof(GC_Weak_Array) 
                       + ((a->count - 1) * sizeof(void *)));
}
static int fixup_weak_box ( void p) [static]

Definition at line 155 of file weak.c.

void* GC_malloc_ephemeron ( void k,
void v 
)

Definition at line 262 of file weak.c.

{
  GCTYPE *gc = GC_get_GC();
  GC_Ephemeron *eph;

  /* Allcation might trigger GC, so we use park: */
  gc->park[0] = k;
  gc->park[1] = v;

  eph = (GC_Ephemeron *)GC_malloc_one_tagged(sizeof(GC_Ephemeron));

  k = gc->park[0];
  v = gc->park[1];
  gc->park[0] = NULL;
  gc->park[1] = NULL;
  
  eph->type = gc->ephemeron_tag;
  eph->key = k;
  eph->val = v;

  return eph;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* GC_malloc_weak_array ( size_t  size_in_bytes,
void replace_val 
)

Definition at line 85 of file weak.c.

{
  GCTYPE *gc = GC_get_GC();
  GC_Weak_Array *w;

  /* Allcation might trigger GC, so we use park: */
  gc->park[0] = replace_val;

  w = (GC_Weak_Array *)GC_malloc_one_tagged(size_in_bytes 
                                       + sizeof(GC_Weak_Array) 
                                       - sizeof(void *));

  replace_val = gc->park[0];
  gc->park[0] = NULL;

  w->type = gc->weak_array_tag;
  w->replace_val = replace_val;
  w->count = (size_in_bytes >> LOG_WORD_SIZE);
  
  return w;
}

Here is the call graph for this function:

void* GC_malloc_weak_box ( void p,
void **  secondary,
int  soffset 
)

Definition at line 165 of file weak.c.

{
  GCTYPE *gc = GC_get_GC();
  GC_Weak_Box *w;

  /* Allcation might trigger GC, so we use park: */
  gc->park[0] = p;
  gc->park[1] = secondary;

  w = (GC_Weak_Box *)GC_malloc_one_tagged(sizeof(GC_Weak_Box));

  p = gc->park[0];
  secondary = (void **)gc->park[1];
  gc->park[0] = NULL;
  gc->park[1] = NULL;
  
  w->type = gc->weak_box_tag;
  w->val = p;
  w->secondary_erase = secondary;
  w->soffset = soffset;

  return w;
}

Here is the call graph for this function:

Definition at line 285 of file weak.c.

                                 {
  gc->ephemerons = NULL;
  gc->num_last_seen_ephemerons = 0;
}

Here is the caller graph for this function:

static void init_weak_arrays ( GCTYPE gc) [static]

Definition at line 107 of file weak.c.

                                         {
  gc->weak_arrays = NULL;
}

Here is the caller graph for this function:

static void init_weak_boxes ( GCTYPE gc) [static]

Definition at line 189 of file weak.c.

                                        {
  gc->weak_boxes = NULL;
}

Here is the caller graph for this function:

static int mark_ephemeron ( void p) [static]

Definition at line 221 of file weak.c.

{
  GCTYPE *gc = GC_get_GC();
  GC_Ephemeron *eph = (GC_Ephemeron *)p;

  if (eph->val) {
    eph->next = gc->ephemerons;
    gc->ephemerons = eph;
  }

  return gcBYTES_TO_WORDS(sizeof(GC_Ephemeron));
}

Here is the caller graph for this function:

static void mark_ready_ephemerons ( GCTYPE gc) [static]

Definition at line 290 of file weak.c.

{
  GC_Ephemeron *waiting = NULL, *next, *eph;

  for (eph = gc->ephemerons; eph; eph = next) {
    next = eph->next;
    if (is_marked(gc, eph->key)) {
      gcMARK(eph->val);
      gc->num_last_seen_ephemerons++;
    } else {
      eph->next = waiting;
      waiting = eph;
    }
  }
  gc->ephemerons = waiting;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int mark_weak_array ( void p) [static]

Definition at line 36 of file weak.c.

{
  GCTYPE *gc = GC_get_GC();
  GC_Weak_Array *a = (GC_Weak_Array *)p;

  gcMARK(a->replace_val);

  a->next = gc->weak_arrays;
  gc->weak_arrays = a;

#if CHECKS
  /* For now, weak arrays only used for symbols, keywords, and falses: */
  {
    void **data;
    int i;
    data = a->data;
    for (i = a->count; i--; ) {
      if (data[i] 
         && (*(short *)(data[i]) != 48)
         && (*(short *)(data[i]) != 49)
         && (*(short *)(data[i]) != 58)) {
       CRASH(1);
      }
    }
  }
#endif

  return gcBYTES_TO_WORDS(sizeof(GC_Weak_Array) 
                       + ((a->count - 1) * sizeof(void *)));
}
static int mark_weak_box ( void p) [static]

Definition at line 140 of file weak.c.

{
  GCTYPE *gc = GC_get_GC();
  GC_Weak_Box *wb = (GC_Weak_Box *)p;
    
  gcMARK(wb->secondary_erase);

  if (wb->val) {
    wb->next = gc->weak_boxes;
    gc->weak_boxes = wb;
  }

  return gcBYTES_TO_WORDS(sizeof(GC_Weak_Box));
}
static int size_ephemeron ( void p) [static]

Definition at line 216 of file weak.c.

{
  return gcBYTES_TO_WORDS(sizeof(GC_Ephemeron));
}

Here is the caller graph for this function:

static int size_weak_array ( void p) [static]

Definition at line 28 of file weak.c.

{
  GC_Weak_Array *a = (GC_Weak_Array *)p;

  return gcBYTES_TO_WORDS(sizeof(GC_Weak_Array) 
                       + ((a->count - 1) * sizeof(void *)));
}
static int size_weak_box ( void p) [static]

Definition at line 135 of file weak.c.

{
  return gcBYTES_TO_WORDS(sizeof(GC_Weak_Box));
}
static void zero_remaining_ephemerons ( GCTYPE gc) [static]

Definition at line 307 of file weak.c.

{
  GC_Ephemeron *eph;

  /* After unordered finalization, any remaining ephemerons
     should be zeroed. */
  for (eph = gc->ephemerons; eph; eph = eph->next) {
    eph->key = NULL;
    eph->val = NULL;
  }
}

Here is the caller graph for this function:

static void zero_weak_arrays ( GCTYPE gc) [static]

Definition at line 111 of file weak.c.

{
  GC_Weak_Array *wa;
  int i;

  wa = gc->weak_arrays;
  while (wa) {
    void **data;

    data = wa->data;
    for (i = wa->count; i--; ) {
      void *p = data[i];
      if (p && !is_marked(gc, p))
        data[i] = wa->replace_val;
    }

    wa = wa->next;
  }
}

Here is the caller graph for this function:

static void zero_weak_boxes ( GCTYPE gc) [static]

Definition at line 193 of file weak.c.

{
  GC_Weak_Box *wb;

  wb = gc->weak_boxes;
  while (wb) {
    if (!is_marked(gc, wb->val)) {
      wb->val = NULL;
      if (wb->secondary_erase) {
        void **p;
        p = (void **)GC_resolve(wb->secondary_erase);
        *(p + wb->soffset) = NULL;
        wb->secondary_erase = NULL;
      }
    }
    wb = wb->next;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function: