This is needed to make the size of hb_sz to be the same as of AO_t.
* allchblk.c [USE_MUNMAP] (GC_unmap_old): Cast hhdr->hb_sz to size_t
when passed to GC_unmap().
* allchblk.c (GC_allochblk_nth): Cast hhdr->hb_sz to signed_word when
assigned to size_avail.
* allchblk.c [USE_MUNMAP] (GC_allochblk_nth): Cast hhdr->hb_sz to
size_t when passed to GC_remap().
* alloc.c (GC_set_fl_marks, GC_clear_fl_marks): Change type of sz and
bit_no local variables from size_t/unsigned to word.
* dbg_mlc.c (GC_check_heap_block): Likewise.
* backgraph.c [MAKE_BACK_GRAPH] (per_object_helper): Cast hhdr->hb_sz
to size_t; change type of i local variables from int to size_t.
* checksums.c [CHECKSUMS] (GC_on_free_list): Change type of sz local
variable from size_t to word.
* mark.c (GC_push_marked, GC_push_unconditionally, GC_block_was_dirty):
Likewise.
* reclaim.c (GC_reclaim_small_nonempty_block,
GC_disclaim_and_reclaim_or_free_small_block, GC_reclaim_block,
GC_n_set_marks): Likewise.
* checksums.c [CHECKSUMS] (GC_add_block): Remove bytes local variable
(to avoid casting of hhdr->hb_sz).
* dbg_mlc.c (GC_debug_free): Change type of i and obj_sz local
variables from size_t to word.
* dbg_mlc.c (GC_check_leaked): Likewise.
* extra/pcr_interface.c (GC_enumerate_block): Change type of sz local
variable from int to size_t.
* extra/pcr_interface.c (GC_enumerate_block): Cast hhdr->hb_sz to
size_t when assigned to sz.
* mallocx.c (GC_realloc): Likewise.
* mark.c (GC_set_hdr_marks): Likewise.
* reclaim.c (GC_do_enumerate_reachable_objects): Likewise.
* include/private/gc_pmark.h [MARK_BIT_PER_OBJ] (PUSH_CONTENTS_HDR):
Cast hhdr->hb_sz to size_t in assignment of obj_displ.
* include/private/gc_priv.h (struct hblkhdr): Change type of hb_sz from
size_t to word.
* include/private/gc_priv.h (MARK_BIT_NO): Cast offset argument to word
instead of unsigned.
* malloc.c (GC_free): Cast hhdr->hb_sz to size_t.
* mallocx.c (GC_get_kind_and_size): Likewise.
* mark.c (GC_clear_hdr_marks): Likewise.
* misc.c (GC_size): Likewise.
* misc.c (GC_do_blocking): Remove redundant cast of hhdr->hb_sz.
* reclaim.c (GC_reclaim_clear, GC_reclaim_uninit,
GC_disclaim_and_reclaim, GC_continue_reclaim): Change type of sz
argument from size_t to word.
* typd_mlc.c (GC_array_mark_proc): Change type of sz and nwords local
variables from size_t to word.
/* truncated counter value wrapping is handled correctly). */
if ((unsigned short)(GC_gc_no - hhdr->hb_last_reclaimed) >
(unsigned short)GC_unmap_threshold) {
- GC_unmap((ptr_t)h, hhdr -> hb_sz);
+ GC_unmap((ptr_t)h, (size_t)hhdr->hb_sz);
hhdr -> hb_flags |= WAS_UNMAPPED;
}
}
if (NULL == hbp) return NULL;
GET_HDR(hbp, hhdr); /* set hhdr value */
- size_avail = hhdr->hb_sz;
+ size_avail = (signed_word)hhdr->hb_sz;
if (size_avail < size_needed) continue;
if (size_avail != size_needed) {
if (!may_split) continue;
/* Make sure it's mapped before we mangle it. */
# ifdef USE_MUNMAP
if (!IS_MAPPED(hhdr)) {
- GC_remap((ptr_t)hbp, hhdr -> hb_sz);
+ GC_remap((ptr_t)hbp, (size_t)hhdr->hb_sz);
hhdr -> hb_flags &= ~WAS_UNMAPPED;
}
# endif
if( size_avail >= size_needed ) {
# ifdef USE_MUNMAP
if (!IS_MAPPED(hhdr)) {
- GC_remap((ptr_t)hbp, hhdr -> hb_sz);
+ GC_remap((ptr_t)hbp, (size_t)hhdr->hb_sz);
hhdr -> hb_flags &= ~WAS_UNMAPPED;
/* Note: This may leave adjacent, mapped free blocks. */
}
struct hblk *h = HBLKPTR(q);
struct hblk *last_h = h;
hdr *hhdr = HDR(h);
- IF_PER_OBJ(size_t sz = hhdr->hb_sz;)
+ IF_PER_OBJ(word sz = hhdr->hb_sz;)
for (;;) {
- unsigned bit_no = MARK_BIT_NO((ptr_t)q - (ptr_t)h, sz);
+ word bit_no = MARK_BIT_NO((ptr_t)q - (ptr_t)h, sz);
if (!mark_bit_from_hdr(hhdr, bit_no)) {
set_mark_bit_from_hdr(hhdr, bit_no);
struct hblk *h = HBLKPTR(q);
struct hblk *last_h = h;
hdr *hhdr = HDR(h);
- size_t sz = hhdr->hb_sz; /* Normally set only once. */
+ word sz = hhdr->hb_sz; /* Normally set only once. */
for (;;) {
- unsigned bit_no = MARK_BIT_NO((ptr_t)q - (ptr_t)h, sz);
+ word bit_no = MARK_BIT_NO((ptr_t)q - (ptr_t)h, sz);
if (mark_bit_from_hdr(hhdr, bit_no)) {
size_t n_marks = hhdr -> hb_n_marks;
static void per_object_helper(struct hblk *h, word fn)
{
hdr * hhdr = HDR(h);
- size_t sz = hhdr -> hb_sz;
+ size_t sz = (size_t)hhdr->hb_sz;
word descr = hhdr -> hb_descr;
per_object_func f = (per_object_func)fn;
- int i = 0;
+ size_t i = 0;
do {
f((ptr_t)(h -> hb_body + i), sz, descr);
- i += (int)sz;
- } while ((word)i + sz <= BYTES_TO_WORDS(HBLKSIZE));
+ i += sz;
+ } while (i + sz <= BYTES_TO_WORDS(HBLKSIZE));
}
GC_INLINE void GC_apply_to_each_object(per_object_func f)
STATIC GC_bool GC_on_free_list(struct hblk *h)
{
hdr * hhdr = HDR(h);
- size_t sz = BYTES_TO_WORDS(hhdr -> hb_sz);
+ word sz = BYTES_TO_WORDS(hhdr -> hb_sz);
ptr_t p;
if (sz > MAXOBJWORDS) return(FALSE);
STATIC void GC_add_block(struct hblk *h, word dummy GC_ATTR_UNUSED)
{
hdr * hhdr = HDR(h);
- size_t bytes = hhdr -> hb_sz;
- bytes += HBLKSIZE-1;
- bytes &= ~(HBLKSIZE-1);
- GC_bytes_in_used_blocks += bytes;
+ GC_bytes_in_used_blocks += (hhdr->hb_sz + HBLKSIZE-1) & ~(HBLKSIZE-1);
}
STATIC void GC_check_blocks(void)
) {
GC_free(base);
} else {
- size_t i;
- size_t obj_sz = BYTES_TO_WORDS(hhdr -> hb_sz - sizeof(oh));
+ word i;
+ word obj_sz = BYTES_TO_WORDS(hhdr->hb_sz - sizeof(oh));
for (i = 0; i < obj_sz; ++i)
((word *)p)[i] = GC_FREED_MEM_MARKER;
STATIC void GC_check_heap_block(struct hblk *hbp, word dummy GC_ATTR_UNUSED)
{
struct hblkhdr * hhdr = HDR(hbp);
- size_t sz = hhdr -> hb_sz;
- size_t bit_no;
+ word sz = hhdr -> hb_sz;
+ word bit_no;
char *p, *plim;
p = hbp->hb_body;
GC_INNER GC_bool GC_check_leaked(ptr_t base)
{
- size_t i;
- size_t obj_sz;
+ word i;
+ word obj_sz;
word *p;
if (
void GC_enumerate_block(struct hblk *h; enumerate_data * ed)
{
register hdr * hhdr;
- register int sz;
+ register size_t sz;
ptr_t p;
ptr_t lim;
word descr;
# endif
hhdr = HDR(h);
descr = hhdr -> hb_descr;
- sz = hhdr -> hb_sz;
+ sz = (size_t)hhdr->hb_sz;
if (descr != 0 && ed -> ed_pointerfree
|| descr == 0 && !(ed -> ed_pointerfree)) return;
lim = (ptr_t)(h+1) - sz;
size_t obj_displ; \
/* Accurate enough if HBLKSIZE <= 2**15. */ \
GC_STATIC_ASSERT(HBLKSIZE <= (1 << 15)); \
- obj_displ = (((low_prod >> 16) + 1) * hhdr->hb_sz) >> 16; \
+ obj_displ = (((low_prod >> 16) + 1) * (size_t)hhdr->hb_sz) >> 16; \
if (do_offset_check && !GC_valid_offsets[obj_displ]) { \
GC_ADD_TO_BLACK_LIST_NORMAL(current, source); \
break; \
/* LARGE_INV_SZ. */
# define LARGE_INV_SZ (1 << 16)
# endif
- size_t hb_sz; /* If in use, size in bytes, of objects in the block. */
- /* if free, the size in bytes of the whole block */
- /* We assume that this is convertible to signed_word */
- /* without generating a negative result. We avoid */
- /* generating free blocks larger than that. */
+ word hb_sz; /* If in use, size in bytes, of objects in the block. */
+ /* if free, the size in bytes of the whole block. */
+ /* We assume that this is convertible to signed_word */
+ /* without generating a negative result. We avoid */
+ /* generating free blocks larger than that. */
word hb_descr; /* object descriptor for marking. See */
/* gc_mark.h. */
# ifdef MARK_BIT_PER_GRANULE
#endif /* !USE_MARK_BYTES */
#ifdef MARK_BIT_PER_OBJ
-# define MARK_BIT_NO(offset, sz) (((unsigned)(offset))/(sz))
+# define MARK_BIT_NO(offset, sz) (((word)(offset))/(sz))
/* Get the mark bit index corresponding to the given byte */
/* offset and size (in bytes). */
# define MARK_BIT_OFFSET(sz) 1
# define FINAL_MARK_BIT(sz) ((sz) > MAXOBJBYTES? 1 : HBLK_OBJS(sz))
/* Position of final, always set, mark bit. */
#else /* MARK_BIT_PER_GRANULE */
-# define MARK_BIT_NO(offset, sz) BYTES_TO_GRANULES((unsigned)(offset))
+# define MARK_BIT_NO(offset, sz) BYTES_TO_GRANULES((word)(offset))
# define MARK_BIT_OFFSET(sz) BYTES_TO_GRANULES(sz)
# define IF_PER_OBJ(x)
# define FINAL_MARK_BIT(sz) \
if (0 == hhdr) return;
# endif
GC_ASSERT(GC_base(p) == p);
- sz = hhdr -> hb_sz;
+ sz = (size_t)hhdr->hb_sz;
ngranules = BYTES_TO_GRANULES(sz);
knd = hhdr -> hb_obj_kind;
ok = &GC_obj_kinds[knd];
h = HBLKPTR(p);
hhdr = HDR(h);
knd = hhdr -> hb_obj_kind;
- sz = hhdr -> hb_sz;
+ sz = (size_t)hhdr->hb_sz;
ngranules = BYTES_TO_GRANULES(sz);
ok = &GC_obj_kinds[knd];
if (ngranules <= MAXOBJGRANULES) {
hdr * hhdr = HDR(p);
if (psize != NULL) {
- *psize = hhdr -> hb_sz;
+ *psize = (size_t)hhdr->hb_sz;
}
return hhdr -> hb_obj_kind;
}
}
h = HBLKPTR(p);
hhdr = HDR(h);
- sz = hhdr -> hb_sz;
+ sz = (size_t)hhdr->hb_sz;
obj_kind = hhdr -> hb_obj_kind;
orig_sz = sz;
/* clear all mark bits in the header */
GC_INNER void GC_clear_hdr_marks(hdr *hhdr)
{
- size_t last_bit = FINAL_MARK_BIT(hhdr -> hb_sz);
+ size_t last_bit = FINAL_MARK_BIT((size_t)hhdr->hb_sz);
BZERO(hhdr -> hb_marks, sizeof(hhdr->hb_marks));
set_mark_bit_from_hdr(hhdr, last_bit);
hhdr -> hb_n_marks = 0;
GC_INNER void GC_set_hdr_marks(hdr *hhdr)
{
unsigned i;
- size_t sz = hhdr -> hb_sz;
+ size_t sz = (size_t)hhdr->hb_sz;
unsigned n_marks = (unsigned)FINAL_MARK_BIT(sz);
# ifdef USE_MARK_BYTES
/* Push all objects reachable from marked objects in the given block */
STATIC void GC_push_marked(struct hblk *h, hdr *hhdr)
{
- size_t sz = hhdr -> hb_sz;
+ word sz = hhdr -> hb_sz;
word descr = hhdr -> hb_descr;
ptr_t p;
word bit_no;
/* first word. */
STATIC void GC_push_unconditionally(struct hblk *h, hdr *hhdr)
{
- size_t sz = hhdr -> hb_sz;
+ word sz = hhdr -> hb_sz;
word descr = hhdr -> hb_descr;
ptr_t p;
ptr_t lim;
/* Test whether any page in the given block is dirty. */
STATIC GC_bool GC_block_was_dirty(struct hblk *h, hdr *hhdr)
{
- size_t sz = hhdr -> hb_sz;
+ word sz = hhdr -> hb_sz;
if (sz <= MAXOBJBYTES) {
return(GC_page_was_dirty(h));
{
hdr * hhdr = HDR(p);
- return hhdr -> hb_sz;
+ return (size_t)hhdr->hb_sz;
}
static void block_add_size(struct hblk *h, word pbytes)
{
hdr *hhdr = HDR(h);
- *(word *)pbytes += (WORDS_TO_BYTES((word)hhdr->hb_sz) + (HBLKSIZE - 1))
+ *(word *)pbytes += (WORDS_TO_BYTES(hhdr->hb_sz) + (HBLKSIZE - 1))
& ~(word)(HBLKSIZE - 1);
}
* free list. Returns the new list.
* Clears unmarked objects. Sz is in bytes.
*/
-STATIC ptr_t GC_reclaim_clear(struct hblk *hbp, hdr *hhdr, size_t sz,
+STATIC ptr_t GC_reclaim_clear(struct hblk *hbp, hdr *hhdr, word sz,
ptr_t list, signed_word *count)
{
word bit_no = 0;
}
/* The same thing, but don't clear objects: */
-STATIC ptr_t GC_reclaim_uninit(struct hblk *hbp, hdr *hhdr, size_t sz,
+STATIC ptr_t GC_reclaim_uninit(struct hblk *hbp, hdr *hhdr, word sz,
ptr_t list, signed_word *count)
{
word bit_no = 0;
#ifdef ENABLE_DISCLAIM
/* Call reclaim notifier for block's kind on each unmarked object in */
/* block, all within a pair of corresponding enter/leave callbacks. */
- STATIC ptr_t GC_disclaim_and_reclaim(struct hblk *hbp, hdr *hhdr, size_t sz,
+ STATIC ptr_t GC_disclaim_and_reclaim(struct hblk *hbp, hdr *hhdr, word sz,
ptr_t list, signed_word *count)
{
word bit_no = 0;
GC_bool report_if_found)
{
hdr *hhdr = HDR(hbp);
- size_t sz = hhdr -> hb_sz;
+ word sz = hhdr -> hb_sz;
struct obj_kind * ok = &GC_obj_kinds[hhdr -> hb_obj_kind];
void **flh = &(ok -> ok_freelist[BYTES_TO_GRANULES(sz)]);
STATIC void GC_disclaim_and_reclaim_or_free_small_block(struct hblk *hbp)
{
hdr *hhdr = HDR(hbp);
- size_t sz = hhdr -> hb_sz;
+ word sz = hhdr -> hb_sz;
struct obj_kind * ok = &GC_obj_kinds[hhdr -> hb_obj_kind];
void **flh = &(ok -> ok_freelist[BYTES_TO_GRANULES(sz)]);
void *flh_next;
STATIC void GC_reclaim_block(struct hblk *hbp, word report_if_found)
{
hdr * hhdr = HDR(hbp);
- size_t sz = hhdr -> hb_sz; /* size of objects in current block */
+ word sz = hhdr -> hb_sz; /* size of objects in current block */
struct obj_kind * ok = &GC_obj_kinds[hhdr -> hb_obj_kind];
if( sz > MAXOBJBYTES ) { /* 1 big object */
if (report_if_found) {
GC_add_leaked((ptr_t)hbp);
} else {
- size_t blocks;
+ word blocks;
# ifdef ENABLE_DISCLAIM
if (EXPECT(hhdr->hb_flags & HAS_DISCLAIM, 0)) {
{
int result = 0;
int i;
- size_t sz = hhdr -> hb_sz;
+ word sz = hhdr -> hb_sz;
int offset = (int)MARK_BIT_OFFSET(sz);
int limit = (int)FINAL_MARK_BIT(sz);
* appropriate free list is nonempty, or there are no more blocks to
* sweep.
*/
-GC_INNER void GC_continue_reclaim(size_t sz /* granules */, int kind)
+GC_INNER void GC_continue_reclaim(word sz /* granules */, int kind)
{
hdr * hhdr;
struct hblk * hbp;
STATIC void GC_do_enumerate_reachable_objects(struct hblk *hbp, word ped)
{
struct hblkhdr *hhdr = HDR(hbp);
- size_t sz = hhdr -> hb_sz;
+ size_t sz = (size_t)hhdr->hb_sz;
size_t bit_no;
char *p, *plim;
word env GC_ATTR_UNUSED)
{
hdr * hhdr = HDR(addr);
- size_t sz = hhdr -> hb_sz;
- size_t nwords = BYTES_TO_WORDS(sz);
+ word sz = hhdr -> hb_sz;
+ word nwords = BYTES_TO_WORDS(sz);
complex_descriptor * descr = (complex_descriptor *)(addr[nwords-1]);
mse * orig_mark_stack_ptr = mark_stack_ptr;
mse * new_mark_stack_ptr;