/* * Is the block starting at h of size len bytes black listed? If so, * return the address of the next plausible r such that (r, len) might not * be black listed. (R may not actually be in the heap. We guarantee only * that every smaller value of r after h is also black listed.) * If (h,len) is not black listed, return 0. * Knows about the structure of the black list hash tables. */ struct hblk * GC_is_black_listed(struct hblk *h, word len) { word index = PHT_HASH((word)h); word i; word nblocks; if (!GC_all_interior_pointers && (get_pht_entry_from_index(GC_old_normal_bl, index) || get_pht_entry_from_index(GC_incomplete_normal_bl, index))) { return (h+1); } nblocks = divHBLKSZ(len); for (i = 0;;) { if (GC_old_stack_bl[divWORDSZ(index)] == 0 && GC_incomplete_stack_bl[divWORDSZ(index)] == 0) { /* An easy case */ i += WORDSZ - modWORDSZ(index); } else { if (get_pht_entry_from_index(GC_old_stack_bl, index) || get_pht_entry_from_index(GC_incomplete_stack_bl, index)) { return(h+i+1); } i++; } if (i >= nblocks) break; index = PHT_HASH((word)(h+i)); } return(0); }
/* Return the total number of (stack) black-listed bytes. */ static word total_stack_black_listed(void) { unsigned i; word total = 0; for (i = 0; i < GC_n_heap_sects; i++) { struct hblk * start = (struct hblk *) GC_heap_sects[i].hs_start; struct hblk * endp1 = start + divHBLKSZ(GC_heap_sects[i].hs_bytes); total += GC_number_stack_black_listed(start, endp1); } return(total * HBLKSIZE); }
/* debugging intolerably slow.) */ GC_API void * GC_CALL GC_same_obj(void *p, void *q) { struct hblk *h; hdr *hhdr; ptr_t base, limit; word sz; if (!GC_is_initialized) GC_init(); hhdr = HDR((word)p); if (hhdr == 0) { if (divHBLKSZ((word)p) != divHBLKSZ((word)q) && HDR((word)q) != 0) { goto fail; } return(p); } /* If it's a pointer to the middle of a large object, move it */ /* to the beginning. */ if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) { h = HBLKPTR(p) - (word)hhdr; hhdr = HDR(h); while (IS_FORWARDING_ADDR_OR_NIL(hhdr)) { h = FORWARDED_ADDR(h, hhdr); hhdr = HDR(h); } limit = (ptr_t)h + hhdr -> hb_sz; if ((ptr_t)p >= limit || (ptr_t)q >= limit || (ptr_t)q < (ptr_t)h ) { goto fail; } return(p); } sz = hhdr -> hb_sz; if (sz > MAXOBJBYTES) { base = (ptr_t)HBLKPTR(p); limit = base + sz; if ((ptr_t)p >= limit) { goto fail; } } else { size_t offset; size_t pdispl = HBLKDISPL(p); offset = pdispl % sz; if (HBLKPTR(p) != HBLKPTR(q)) goto fail; /* W/o this check, we might miss an error if */ /* q points to the first object on a page, and */ /* points just before the page. */ base = (ptr_t)p - offset; limit = base + sz; } /* [base, limit) delimits the object containing p, if any. */ /* If p is not inside a valid object, then either q is */ /* also outside any valid object, or it is outside */ /* [base, limit). */ if ((ptr_t)q >= limit || (ptr_t)q < base) { goto fail; } return(p); fail: (*GC_same_obj_print_proc)((ptr_t)p, (ptr_t)q); return(p); }