Back to index

plt-scheme  4.2.1
Defines | Functions | Variables
headers.c File Reference
#include "private/gc_priv.h"

Go to the source code of this file.

Defines

#define GRANULARITY   sizeof(word)

Functions

hdrGC_find_header (ptr_t h)
ptr_t GC_scratch_alloc (word bytes)
static hdralloc_hdr ()
static void free_hdr (hdr *hhdr)
void GC_init_headers ()
static GC_bool get_index (word addr)
struct hblkhdrGC_install_header (struct hblk *h)
GC_bool GC_install_counts (struct hblk *h, word sz)
void GC_remove_header (struct hblk *h)
void GC_remove_counts (struct hblk *h, word sz)
void GC_apply_to_all_blocks (void *fn, word client_data)
struct hblkGC_next_used_block (struct hblk *h)
struct hblkGC_prev_block (struct hblk *h)

Variables

bottom_indexGC_all_bottom_indices = 0
bottom_indexGC_all_bottom_indices_end = 0
static ptr_t scratch_free_ptr = 0
static hdrhdr_free_list = 0
hdrGC_invalid_header

Define Documentation

#define GRANULARITY   sizeof(word)

Function Documentation

static hdr* alloc_hdr ( ) [static]

Definition at line 110 of file headers.c.

{
    register hdr * result;
    
    if (hdr_free_list == 0) {
        result = (hdr *) GC_scratch_alloc((word)(sizeof(hdr)));
    } else {
        result = hdr_free_list;
        hdr_free_list = (hdr *) (result -> hb_next);
    }
    return(result);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void free_hdr ( hdr hhdr) [static]

Definition at line 123 of file headers.c.

{
    hhdr -> hb_next = (struct hblk *) hdr_free_list;
    hdr_free_list = hhdr;
}

Here is the caller graph for this function:

void GC_apply_to_all_blocks ( void fn,
word  client_data 
)

Definition at line 262 of file headers.c.

{
    register int j;
    register bottom_index * index_p;
    
    for (index_p = GC_all_bottom_indices; index_p != 0;
         index_p = index_p -> asc_link) {
        for (j = BOTTOM_SZ-1; j >= 0;) {
            if (!IS_FORWARDING_ADDR_OR_NIL(index_p->index[j])) {
                if (index_p->index[j]->hb_map != GC_invalid_map) {
                    (*fn)(((struct hblk *)
                           (((index_p->key << LOG_BOTTOM_SZ) + (word)j)
                            << LOG_HBLKSIZE)),
                          client_data);
                }
                j--;
             } else if (index_p->index[j] == 0) {
                j--;
             } else {
                j -= (word)(index_p->index[j]);
             }
         }
     }
}

Here is the caller graph for this function:

Definition at line 36 of file headers.c.

{
#   ifdef HASH_TL
       register hdr * result;
       GET_HDR(h, result);
       return(result);
#   else
       return(HDR_INNER(h));
#   endif
}

Here is the caller graph for this function:

Definition at line 137 of file headers.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 219 of file headers.c.

{
    register struct hblk * hbp;
    register int i;
    
    for (hbp = h; (char *)hbp < (char *)h + sz; hbp += BOTTOM_SZ) {
        if (!get_index((word) hbp)) return(FALSE);
    }
    if (!get_index((word)h + sz - 1)) return(FALSE);
    for (hbp = h + 1; (char *)hbp < (char *)h + sz; hbp += 1) {
        i = HBLK_PTR_DIFF(hbp, h);
        SET_HDR(hbp, (hdr *)(i > MAX_JUMP? MAX_JUMP : i));
    }
    return(TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 204 of file headers.c.

{
    hdr * result;
    
    if (!get_index((word) h)) return(0);
    result = alloc_hdr();
    SET_HDR(h, result);
#   ifdef USE_MUNMAP
       result -> hb_last_reclaimed = (unsigned short)GC_gc_no;
#   endif
    return(result);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 291 of file headers.c.

{
    register bottom_index * bi;
    register word j = ((word)h >> LOG_HBLKSIZE) & (BOTTOM_SZ-1);
    
    GET_BI(h, bi);
    if (bi == GC_all_nils) {
        register word hi = (word)h >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE);
        bi = GC_all_bottom_indices;
        while (bi != 0 && bi -> key < hi) bi = bi -> asc_link;
        j = 0;
    }
    while(bi != 0) {
        while (j < BOTTOM_SZ) {
           hdr * hhdr = bi -> index[j];
            if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) {
                j++;
            } else {
                if (hhdr->hb_map != GC_invalid_map) {
                    return((struct hblk *)
                           (((bi -> key << LOG_BOTTOM_SZ) + j)
                            << LOG_HBLKSIZE));
                } else {
                    j += divHBLKSZ(hhdr -> hb_sz);
                }
            }
        }
        j = 0;
        bi = bi -> asc_link;
    }
    return(0);
}

Here is the caller graph for this function:

struct hblk* GC_prev_block ( struct hblk h) [read]

Definition at line 328 of file headers.c.

{
    register bottom_index * bi;
    register signed_word j = ((word)h >> LOG_HBLKSIZE) & (BOTTOM_SZ-1);
    
    GET_BI(h, bi);
    if (bi == GC_all_nils) {
        register word hi = (word)h >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE);
        bi = GC_all_bottom_indices_end;
        while (bi != 0 && bi -> key > hi) bi = bi -> desc_link;
        j = BOTTOM_SZ - 1;
    }
    while(bi != 0) {
        while (j >= 0) {
           hdr * hhdr = bi -> index[j];
           if (0 == hhdr) {
              --j;
            } else if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) {
                j -= (signed_word)hhdr;
            } else {
                return((struct hblk *)
                          (((bi -> key << LOG_BOTTOM_SZ) + j)
                            << LOG_HBLKSIZE));
            }
        }
        j = BOTTOM_SZ - 1;
        bi = bi -> desc_link;
    }
    return(0);
}

Here is the caller graph for this function:

void GC_remove_counts ( struct hblk h,
word  sz 
)

Definition at line 249 of file headers.c.

{
    register struct hblk * hbp;
    
    for (hbp = h+1; (char *)hbp < (char *)h + sz; hbp += 1) {
        SET_HDR(hbp, 0);
    }
}

Here is the caller graph for this function:

Definition at line 238 of file headers.c.

{
    hdr ** ha;
    
    GET_HDR_ADDR(h, ha);
    free_hdr(*ha);
    *ha = 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 56 of file headers.c.

{
    register ptr_t result = scratch_free_ptr;

#   ifdef ALIGN_DOUBLE
#      define GRANULARITY (2 * sizeof(word))
#   else
#      define GRANULARITY sizeof(word)
#   endif
    bytes += GRANULARITY-1;
    bytes &= ~(GRANULARITY-1);
    scratch_free_ptr += bytes;
    if (scratch_free_ptr <= GC_scratch_end_ptr) {
        return(result);
    }
    {
        word bytes_to_get = MINHINCR * HBLKSIZE;
         
        if (bytes_to_get <= bytes) {
          /* Undo the damage, and get memory directly */
           bytes_to_get = bytes;
#          ifdef USE_MMAP
              bytes_to_get += GC_page_size - 1;
              bytes_to_get &= ~(GC_page_size - 1);
#          endif
           result = (ptr_t)GET_MEM(bytes_to_get);
            scratch_free_ptr -= bytes;
           GC_scratch_last_end_ptr = result + bytes;
            return(result);
        }
        result = (ptr_t)GET_MEM(bytes_to_get);
        if (result == 0) {
#          ifdef PRINTSTATS
                GC_printf0("Out of memory - trying to allocate less\n");
#          endif
            scratch_free_ptr -= bytes;
           bytes_to_get = bytes;
#          ifdef USE_MMAP
              bytes_to_get += GC_page_size - 1;
              bytes_to_get &= ~(GC_page_size - 1);
#          endif
            return((ptr_t)GET_MEM(bytes_to_get));
        }
        scratch_free_ptr = result;
        GC_scratch_end_ptr = scratch_free_ptr + bytes_to_get;
        GC_scratch_last_end_ptr = GC_scratch_end_ptr;
        return(GC_scratch_alloc(bytes));
    }
}

Here is the caller graph for this function:

static GC_bool get_index ( word  addr) [static]

Definition at line 152 of file headers.c.

{
    word hi = (word)(addr) >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE);
    bottom_index * r;
    bottom_index * p;
    bottom_index ** prev;
    bottom_index *pi;
    
#   ifdef HASH_TL
      unsigned i = TL_HASH(hi);
      bottom_index * old;
      
      old = p = GC_top_index[i];
      while(p != GC_all_nils) {
          if (p -> key == hi) return(TRUE);
          p = p -> hash_link;
      }
      r = (bottom_index*)GC_scratch_alloc((word)(sizeof (bottom_index)));
      if (r == 0) return(FALSE);
      BZERO(r, sizeof (bottom_index));
      r -> hash_link = old;
      GC_top_index[i] = r;
#   else
      if (GC_top_index[hi] != GC_all_nils) return(TRUE);
      r = (bottom_index*)GC_scratch_alloc((word)(sizeof (bottom_index)));
      if (r == 0) return(FALSE);
      GC_top_index[hi] = r;
      BZERO(r, sizeof (bottom_index));
#   endif
    r -> key = hi;
    /* Add it to the list of bottom indices */
      prev = &GC_all_bottom_indices;      /* pointer to p */
      pi = 0;                      /* bottom_index preceding p */
      while ((p = *prev) != 0 && p -> key < hi) {
       pi = p;
       prev = &(p -> asc_link);
      }
      r -> desc_link = pi;
      if (0 == p) {
       GC_all_bottom_indices_end = r;
      } else {
       p -> desc_link = r;
      }
      r -> asc_link = p;
      *prev = r;
    return(TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 27 of file headers.c.

Definition at line 31 of file headers.c.

Definition at line 130 of file headers.c.

hdr* hdr_free_list = 0 [static]

Definition at line 107 of file headers.c.

ptr_t scratch_free_ptr = 0 [static]

Definition at line 51 of file headers.c.