Back to index

lightning-sunbird  0.9+nobinonly
Functions
new_hblk.c File Reference
#include <stdio.h>
#include "gc_priv.h"

Go to the source code of this file.

Functions

ptr_t GC_build_fl1 (struct hblk *h, ptr_t ofl)
ptr_t GC_build_fl_clear2 (struct hblk *h, ptr_t ofl)
ptr_t GC_build_fl_clear3 (struct hblk *h, ptr_t ofl)
ptr_t GC_build_fl_clear4 (struct hblk *h, ptr_t ofl)
ptr_t GC_build_fl2 (struct hblk *h, ptr_t ofl)
ptr_t GC_build_fl4 (struct hblk *h, ptr_t ofl)
void GC_new_hblk (word sz, int kind)

Function Documentation

ptr_t GC_build_fl1 ( struct hblk h,
ptr_t  ofl 
)

Definition at line 29 of file new_hblk.c.

{
    register word * p = (word *)h;
    register word * lim = (word *)(h + 1);
    
    p[0] = (word)ofl;
    p[1] = (word)(p);
    p[2] = (word)(p+1);
    p[3] = (word)(p+2);
    p += 4;
    for (; p < lim; p += 4) {
        p[0] = (word)(p-1);
        p[1] = (word)(p);
        p[2] = (word)(p+1);
        p[3] = (word)(p+2);
    };
    return((ptr_t)(p-1));
}

Here is the caller graph for this function:

ptr_t GC_build_fl2 ( struct hblk h,
ptr_t  ofl 
)

Definition at line 115 of file new_hblk.c.

{
    register word * p = (word *)h;
    register word * lim = (word *)(h + 1);
    
    p[0] = (word)ofl;
    p[2] = (word)p;
    p += 4;
    for (; p < lim; p += 4) {
        p[0] = (word)(p-2);
        p[2] = (word)p;
    };
    return((ptr_t)(p-2));
}

Here is the caller graph for this function:

ptr_t GC_build_fl4 ( struct hblk h,
ptr_t  ofl 
)

Definition at line 133 of file new_hblk.c.

{
    register word * p = (word *)h;
    register word * lim = (word *)(h + 1);
    
    p[0] = (word)ofl;
    p[4] = (word)p;
    p += 8;
    for (; p < lim; p += 8) {
        p[0] = (word)(p-4);
        p[4] = (word)p;
    };
    return((ptr_t)(p-4));
}

Here is the caller graph for this function:

ptr_t GC_build_fl_clear2 ( struct hblk h,
ptr_t  ofl 
)

Definition at line 51 of file new_hblk.c.

{
    register word * p = (word *)h;
    register word * lim = (word *)(h + 1);
    
    p[0] = (word)ofl;
    p[1] = 0;
    p[2] = (word)p;
    p[3] = 0;
    p += 4;
    for (; p < lim; p += 4) {
        p[0] = (word)(p-2);
        p[1] = 0;
        p[2] = (word)p;
        p[3] = 0;
    };
    return((ptr_t)(p-2));
}

Here is the caller graph for this function:

ptr_t GC_build_fl_clear3 ( struct hblk h,
ptr_t  ofl 
)

Definition at line 73 of file new_hblk.c.

{
    register word * p = (word *)h;
    register word * lim = (word *)(h + 1) - 2;
    
    p[0] = (word)ofl;
    p[1] = 0;
    p[2] = 0;
    p += 3;
    for (; p < lim; p += 3) {
        p[0] = (word)(p-3);
        p[1] = 0;
        p[2] = 0;
    };
    return((ptr_t)(p-3));
}

Here is the caller graph for this function:

ptr_t GC_build_fl_clear4 ( struct hblk h,
ptr_t  ofl 
)

Definition at line 93 of file new_hblk.c.

{
    register word * p = (word *)h;
    register word * lim = (word *)(h + 1);
    
    p[0] = (word)ofl;
    p[1] = 0;
    p[2] = 0;
    p[3] = 0;
    p += 4;
    for (; p < lim; p += 4) {
        p[0] = (word)(p-4);
        p[1] = 0;
        p[2] = 0;
        p[3] = 0;
    };
    return((ptr_t)(p-4));
}

Here is the caller graph for this function:

void GC_new_hblk ( word  sz,
int  kind 
)

Definition at line 159 of file new_hblk.c.

{
    register word *p,
                *prev;
    word *last_object;             /* points to last object in new hblk      */
    register struct hblk *h;       /* the new heap block                     */
    register GC_bool clear = GC_obj_kinds[kind].ok_init;

#   ifdef PRINTSTATS
       if ((sizeof (struct hblk)) > HBLKSIZE) {
           ABORT("HBLK SZ inconsistency");
        }
#   endif

  /* Allocate a new heap block */
    h = GC_allochblk(sz, kind, 0);
    if (h == 0) return;

  /* Mark all objects if appropriate. */
      if (IS_UNCOLLECTABLE(kind)) GC_set_hdr_marks(HDR(h));

  /* Handle small objects sizes more efficiently.  For larger objects        */
  /* the difference is less significant.                       */
#  ifndef SMALL_CONFIG
    switch (sz) {
        case 1: GC_obj_kinds[kind].ok_freelist[1] =
                GC_build_fl1(h, GC_obj_kinds[kind].ok_freelist[1]);
              return;
        case 2: if (clear) {
                  GC_obj_kinds[kind].ok_freelist[2] =
                    GC_build_fl_clear2(h, GC_obj_kinds[kind].ok_freelist[2]);
              } else {
                  GC_obj_kinds[kind].ok_freelist[2] =
                    GC_build_fl2(h, GC_obj_kinds[kind].ok_freelist[2]);
              }
              return;
        case 3: if (clear) {
                  GC_obj_kinds[kind].ok_freelist[3] =
                    GC_build_fl_clear3(h, GC_obj_kinds[kind].ok_freelist[3]);
                  return;
              } else {
                  /* It's messy to do better than the default here. */
                  break;
              }
        case 4: if (clear) {
                  GC_obj_kinds[kind].ok_freelist[4] =
                    GC_build_fl_clear4(h, GC_obj_kinds[kind].ok_freelist[4]);
              } else {
                  GC_obj_kinds[kind].ok_freelist[4] =
                    GC_build_fl4(h, GC_obj_kinds[kind].ok_freelist[4]);
              }
              return;
        default:
              break;
    }
#  endif /* !SMALL_CONFIG */
    
  /* Clear the page if necessary. */
    if (clear) BZERO(h, HBLKSIZE);
    
  /* Add objects to free list */
    p = &(h -> hb_body[sz]);       /* second object in *h      */
    prev = &(h -> hb_body[0]);            /* One object behind p      */
    last_object = (word *)((char *)h + HBLKSIZE);
    last_object -= sz;
                         /* Last place for last object to start */

  /* make a list of all objects in *h with head as last object */
    while (p <= last_object) {
      /* current object's link points to last object */
        obj_link(p) = (ptr_t)prev;
       prev = p;
       p += sz;
    }
    p -= sz;                /* p now points to last object */

  /*
   * put p (which is now head of list of objects in *h) as first
   * pointer in the appropriate free list for this size.
   */
      obj_link(h -> hb_body) = GC_obj_kinds[kind].ok_freelist[sz];
      GC_obj_kinds[kind].ok_freelist[sz] = ((ptr_t)p);
}

Here is the call graph for this function: