From: Ivan Maidanski Date: Sat, 21 Dec 2013 17:16:56 +0000 (+0400) Subject: Remove hb_large_block field (use 1 extra bit of hb_flags instead) X-Git-Tag: gc7_6_0~299 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a49b495533b253ffba733c5ccf76e61442fe0c22;p=gc Remove hb_large_block field (use 1 extra bit of hb_flags instead) * allchblk.c (setup_header): Use (hb_flags & LARGE_BLOCK) != 0 instead of hb_large_block. * private/gc_pmark.h (PUSH_CONTENTS_HDR): Likewise. * mallocx.c (GC_realloc): Likewise. * include/private/gc_priv.h (struct hblkhdr): Remove hb_large_block; define LARGE_BLOCK to access corresponding bit in hb_flags (only if MARK_BIT_PER_GRANULE). --- diff --git a/allchblk.c b/allchblk.c index 98085b6d..8ae1f671 100644 --- a/allchblk.c +++ b/allchblk.c @@ -226,10 +226,12 @@ static GC_bool setup_header(hdr * hhdr, struct hblk *block, size_t byte_sz, int kind, unsigned flags) { word descr; -# ifndef MARK_BIT_PER_OBJ +# ifdef MARK_BIT_PER_GRANULE size_t granules; -# endif + if (byte_sz > MAXOBJBYTES) + flags |= LARGE_BLOCK; +# endif # ifdef ENABLE_DISCLAIM if (GC_obj_kinds[kind].ok_disclaim_proc) flags |= HAS_DISCLAIM; @@ -267,19 +269,17 @@ static GC_bool setup_header(hdr * hhdr, struct hblk *block, size_t byte_sz, hhdr -> hb_inv_sz = inv_sz; } # else /* MARK_BIT_PER_GRANULE */ - hhdr -> hb_large_block = (unsigned char)(byte_sz > MAXOBJBYTES); granules = BYTES_TO_GRANULES(byte_sz); if (EXPECT(!GC_add_map_entry(granules), FALSE)) { /* Make it look like a valid block. */ hhdr -> hb_sz = HBLKSIZE; hhdr -> hb_descr = 0; - hhdr -> hb_large_block = TRUE; + hhdr -> hb_flags |= LARGE_BLOCK; hhdr -> hb_map = 0; return FALSE; - } else { - size_t index = (hhdr -> hb_large_block? 0 : granules); - hhdr -> hb_map = GC_obj_map[index]; } + hhdr -> hb_map = GC_obj_map[(hhdr -> hb_flags & LARGE_BLOCK) != 0 ? + 0 : granules]; # endif /* MARK_BIT_PER_GRANULE */ /* Clear mark bits */ diff --git a/include/private/gc_pmark.h b/include/private/gc_pmark.h index 9c3aee54..76fcd1f5 100644 --- a/include/private/gc_pmark.h +++ b/include/private/gc_pmark.h @@ -240,7 +240,7 @@ GC_INNER mse * GC_signal_mark_stack_overflow(mse *msp); ptr_t base = current; \ /* The following always fails for large block references. */ \ if (EXPECT((gran_offset | byte_offset) != 0, FALSE)) { \ - if (hhdr -> hb_large_block) { \ + if ((hhdr -> hb_flags & LARGE_BLOCK) != 0) { \ /* gran_offset is bogus. */ \ size_t obj_displ; \ base = (ptr_t)(hhdr -> hb_block); \ diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 54309a96..87b66b2a 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -902,6 +902,9 @@ struct hblkhdr { /* Mark from all objects, marked or */ /* not. Used to mark objects needed by */ /* reclaim notifier. */ +# endif +# ifdef MARK_BIT_PER_GRANULE +# define LARGE_BLOCK 0x10 # endif unsigned short hb_last_reclaimed; /* Value of GC_gc_no when block was */ @@ -924,7 +927,6 @@ struct hblkhdr { /* LARGE_INV_SZ. */ # define LARGE_INV_SZ (1 << 16) # else - unsigned char hb_large_block; short * hb_map; /* Essentially a table of remainders */ /* mod BYTES_TO_GRANULES(hb_sz), except */ /* for large blocks. See GC_obj_map. */ diff --git a/mallocx.c b/mallocx.c index eb96124c..a2d9c70e 100644 --- a/mallocx.c +++ b/mallocx.c @@ -100,8 +100,8 @@ GC_API void * GC_CALL GC_realloc(void * p, size_t lb) # ifdef MARK_BIT_PER_OBJ GC_ASSERT(hhdr -> hb_inv_sz == LARGE_INV_SZ); # else - GC_ASSERT(hhdr -> hb_large_block && - hhdr -> hb_map[ANY_INDEX] == 1); + GC_ASSERT((hhdr -> hb_flags & LARGE_BLOCK) != 0 + && hhdr -> hb_map[ANY_INDEX] == 1); # endif if (IS_UNCOLLECTABLE(obj_kind)) GC_non_gc_bytes += (sz - orig_sz); /* Extra area is already cleared by GC_alloc_large_and_clear. */