| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| # ifndef GC_HEADERS_H |
| # define GC_HEADERS_H |
| typedef struct hblkhdr hdr; |
|
|
| # if CPP_WORDSZ != 32 && CPP_WORDSZ < 36 |
| --> Get a real machine. |
| # endif |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| # if CPP_WORDSZ > 32 |
| # define HASH_TL |
| # endif |
|
|
| |
| # ifdef SMALL_CONFIG |
| # define LOG_BOTTOM_SZ 11 |
| |
| # else |
| # define LOG_BOTTOM_SZ 10 |
| # endif |
| # ifndef HASH_TL |
| # define LOG_TOP_SZ (WORDSZ - LOG_BOTTOM_SZ - LOG_HBLKSIZE) |
| # else |
| # define LOG_TOP_SZ 11 |
| # endif |
| # define TOP_SZ (1 << LOG_TOP_SZ) |
| # define BOTTOM_SZ (1 << LOG_BOTTOM_SZ) |
|
|
| #ifndef SMALL_CONFIG |
| # define USE_HDR_CACHE |
| #endif |
|
|
| |
|
|
| # ifdef COUNT_HDR_CACHE_HITS |
| extern word GC_hdr_cache_hits; |
| extern word GC_hdr_cache_misses; |
| # define HC_HIT() ++GC_hdr_cache_hits |
| # define HC_MISS() ++GC_hdr_cache_misses |
| # else |
| # define HC_HIT() |
| # define HC_MISS() |
| # endif |
|
|
| typedef struct hce { |
| word block_addr; |
| hdr * hce_hdr; |
| } hdr_cache_entry; |
|
|
| # define HDR_CACHE_SIZE 8 |
|
|
| # define DECLARE_HDR_CACHE \ |
| hdr_cache_entry hdr_cache[HDR_CACHE_SIZE] |
|
|
| # define INIT_HDR_CACHE BZERO(hdr_cache, sizeof(hdr_cache)) |
|
|
| # define HCE(h) hdr_cache + (((word)(h) >> LOG_HBLKSIZE) & (HDR_CACHE_SIZE-1)) |
|
|
| # define HCE_VALID_FOR(hce,h) ((hce) -> block_addr == \ |
| ((word)(h) >> LOG_HBLKSIZE)) |
|
|
| # define HCE_HDR(h) ((hce) -> hce_hdr) |
|
|
| #ifdef PRINT_BLACK_LIST |
| hdr * GC_header_cache_miss(ptr_t p, hdr_cache_entry *hce, ptr_t source); |
| # define HEADER_CACHE_MISS(p, hce, source) \ |
| GC_header_cache_miss(p, hce, source) |
| #else |
| hdr * GC_header_cache_miss(ptr_t p, hdr_cache_entry *hce); |
| # define HEADER_CACHE_MISS(p, hce, source) GC_header_cache_miss(p, hce) |
| #endif |
|
|
| |
| |
| |
| |
| |
| |
| # define HC_GET_HDR(p, hhdr, source, exit_label) \ |
| { \ |
| hdr_cache_entry * hce = HCE(p); \ |
| if (EXPECT(HCE_VALID_FOR(hce, p), 1)) { \ |
| HC_HIT(); \ |
| hhdr = hce -> hce_hdr; \ |
| } else { \ |
| hhdr = HEADER_CACHE_MISS(p, hce, source); \ |
| if (0 == hhdr) goto exit_label; \ |
| } \ |
| } |
|
|
| typedef struct bi { |
| hdr * index[BOTTOM_SZ]; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| struct bi * asc_link; |
| |
| struct bi * desc_link; |
| word key; |
| # ifdef HASH_TL |
| struct bi * hash_link; |
| # endif |
| } bottom_index; |
|
|
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| # define MAX_JUMP (HBLKSIZE - 1) |
|
|
| # define HDR_FROM_BI(bi, p) \ |
| ((bi)->index[((word)(p) >> LOG_HBLKSIZE) & (BOTTOM_SZ - 1)]) |
| # ifndef HASH_TL |
| # define BI(p) (GC_top_index \ |
| [(word)(p) >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE)]) |
| # define HDR_INNER(p) HDR_FROM_BI(BI(p),p) |
| # ifdef SMALL_CONFIG |
| # define HDR(p) GC_find_header((ptr_t)(p)) |
| # else |
| # define HDR(p) HDR_INNER(p) |
| # endif |
| # define GET_BI(p, bottom_indx) (bottom_indx) = BI(p) |
| # define GET_HDR(p, hhdr) (hhdr) = HDR(p) |
| # define SET_HDR(p, hhdr) HDR_INNER(p) = (hhdr) |
| # define GET_HDR_ADDR(p, ha) (ha) = &(HDR_INNER(p)) |
| # else |
| |
| # define TL_HASH(hi) ((hi) & (TOP_SZ - 1)) |
| |
| # define GET_BI(p, bottom_indx) \ |
| { \ |
| register word hi = \ |
| (word)(p) >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE); \ |
| register bottom_index * _bi = GC_top_index[TL_HASH(hi)]; \ |
| \ |
| while (_bi -> key != hi && _bi != GC_all_nils) \ |
| _bi = _bi -> hash_link; \ |
| (bottom_indx) = _bi; \ |
| } |
| # define GET_HDR_ADDR(p, ha) \ |
| { \ |
| register bottom_index * bi; \ |
| \ |
| GET_BI(p, bi); \ |
| (ha) = &(HDR_FROM_BI(bi, p)); \ |
| } |
| # define GET_HDR(p, hhdr) { register hdr ** _ha; GET_HDR_ADDR(p, _ha); \ |
| (hhdr) = *_ha; } |
| # define SET_HDR(p, hhdr) { register hdr ** _ha; GET_HDR_ADDR(p, _ha); \ |
| *_ha = (hhdr); } |
| # define HDR(p) GC_find_header((ptr_t)(p)) |
| # endif |
| |
| |
| |
| # define IS_FORWARDING_ADDR_OR_NIL(hhdr) ((size_t) (hhdr) <= MAX_JUMP) |
|
|
| |
| |
| # define FORWARDED_ADDR(h, hhdr) ((struct hblk *)(h) - (size_t)(hhdr)) |
| # endif |
|
|