unsigned int magic;
#endif
unsigned int type:1;
- unsigned int typecode:14;
- unsigned int large:1;
- unsigned int size:15;
unsigned int mark:1;
+ unsigned char large;
+ unsigned short size;
+ /* Right now, on 32-bit hosts we don't have enough room to save the
+ typecode unless we make the one remaining flag into a bitfield.
+ There's a performance cost to that, so we don't do it until we're
+ ready to use the type information for something. */
union {
struct alloc_chunk *next_free;
char data[1];
struct alloc_chunk *chunk;
chunk = (struct alloc_chunk *) ((char *)p - CHUNK_OVERHEAD);
#ifdef COOKIE_CHECKING
- if (chunk->magic != CHUNK_MAGIC)
- abort ();
+ gcc_assert (chunk->magic == CHUNK_MAGIC);
#endif
if (chunk->type == 1)
return true;
size_t bin = 0;
bin = SIZE_BIN_DOWN (size);
- if (bin == 0)
- abort ();
+ gcc_assert (bin);
if (bin > NUM_FREE_BINS)
bin = 0;
#ifdef COOKIE_CHECKING
- if (chunk->magic != CHUNK_MAGIC && chunk->magic != DEADCHUNK_MAGIC)
- abort ();
+ gcc_assert (chunk->magic == CHUNK_MAGIC || chunk->magic == DEADCHUNK_MAGIC);
chunk->magic = DEADCHUNK_MAGIC;
#endif
chunk->u.next_free = zone->free_chunks[bin];
/* Allocate a chunk of memory of SIZE bytes. */
static void *
-ggc_alloc_zone_1 (size_t orig_size, struct alloc_zone *zone, short type
+ggc_alloc_zone_1 (size_t orig_size, struct alloc_zone *zone,
+ short type ATTRIBUTE_UNUSED
MEM_STAT_DECL)
{
size_t bin = 0;
#endif
chunk->type = 1;
chunk->mark = 0;
- chunk->typecode = type;
+ /* We could save TYPE in the chunk, but we don't use that for
+ anything yet. */
result = chunk->u.data;
#ifdef ENABLE_GC_CHECKING
chunk = (struct alloc_chunk *) ((char *)p - CHUNK_OVERHEAD);
#ifdef COOKIE_CHECKING
- if (chunk->magic != CHUNK_MAGIC)
- abort ();
+ gcc_assert (chunk->magic == CHUNK_MAGIC);
#endif
if (chunk->mark)
return 1;
chunk = (struct alloc_chunk *) ((char *)p - CHUNK_OVERHEAD);
#ifdef COOKIE_CHECKING
- if (chunk->magic != CHUNK_MAGIC)
- abort ();
+ gcc_assert (chunk->magic == CHUNK_MAGIC);
#endif
return chunk->mark;
}
chunk = (struct alloc_chunk *) ((char *)p - CHUNK_OVERHEAD);
#ifdef COOKIE_CHECKING
- if (chunk->magic != CHUNK_MAGIC)
- abort ();
+ gcc_assert (chunk->magic == CHUNK_MAGIC);
#endif
if (chunk->large)
return chunk->size * 1024;
G.lg_pagesize = exact_log2 (G.pagesize);
#ifdef HAVE_MMAP_DEV_ZERO
G.dev_zero_fd = open ("/dev/zero", O_RDONLY);
- if (G.dev_zero_fd == -1)
- abort ();
+ gcc_assert (G.dev_zero_fd != -1);
#endif
#if 0
can't get something useful, give up. */
p = alloc_anon (NULL, G.pagesize, &main_zone);
- if ((size_t)p & (G.pagesize - 1))
- abort ();
+ gcc_assert (!((size_t)p & (G.pagesize - 1)));
}
/* We have a good page, might as well hold onto it... */
struct alloc_zone *z;
for (z = G.zones; z && z->next_zone != dead_zone; z = z->next_zone)
- /* Just find that zone. */ ;
+ /* Just find that zone. */
+ continue;
-#ifdef ENABLE_CHECKING
/* We should have found the zone in the list. Anything else is fatal. */
- if (!z)
- abort ();
-#endif
+ gcc_assert (z);
/* z is dead, baby. z is dead. */
z->dead= true;
for (zone = G.zones; zone; zone = zone->next_zone)
++(zone->context_depth);
/* Die on wrap. */
- if (main_zone.context_depth >= HOST_BITS_PER_LONG)
- abort ();
+ gcc_assert (main_zone.context_depth < HOST_BITS_PER_LONG);
}
/* Decrement the `GC context'. All objects allocated since the
struct alloc_chunk *end = (struct alloc_chunk *)(p->page + G.pagesize);
do
{
- if (chunk->magic != CHUNK_MAGIC && chunk->magic != DEADCHUNK_MAGIC)
- abort ();
+ gcc_assert (chunk->magic == CHUNK_MAGIC
+ || chunk->magic == DEADCHUNK_MAGIC);
chunk = (struct alloc_chunk *)(chunk->u.data + chunk->size);
}
while (chunk < end);
printf ("Zone `%s' is dead and will be freed.\n", dead_zone->name);
/* The zone must be empty. */
- if (dead_zone->allocated != 0)
- abort ();
+ gcc_assert (!dead_zone->allocated);
/* Unchain the dead zone, release all its pages and free it. */
zone->next_zone = zone->next_zone->next_zone;
in_use += p->bytes - CHUNK_OVERHEAD;
chunk = (struct alloc_chunk *) p->page;
overhead += CHUNK_OVERHEAD;
- if (!chunk->type)
- abort ();
- if (chunk->mark)
- abort ();
+ gcc_assert (chunk->type && !chunk->mark);
continue;
}
overhead += CHUNK_OVERHEAD;
if (chunk->type)
in_use += chunk->size;
- if (chunk->mark)
- abort ();
+ gcc_assert (!chunk->mark);
}
}
fprintf (stderr, "%20s %10lu%c %10lu%c %10lu%c\n",
SCALE (in_use), LABEL (in_use),
SCALE (overhead), LABEL (overhead));
- if (in_use != zone->allocated)
- abort ();
+ gcc_assert (in_use == zone->allocated);
total_overhead += overhead;
total_allocated += zone->allocated;