From 4c160717caf980303ced3d3f17ad0bfd7381f3b2 Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Thu, 20 Sep 2001 15:12:54 +0000 Subject: fold-const.c (hashtab.h): Include. * fold-const.c (hashtab.h): Include. (int_const_binop): Remove FORSIZE arg and compute from type; all callers changed. Call size_int_type_wide for all single-word constants. (size_htab_hash, size_htab_eq): New functions. (size_int_type_wide): Rework to use hash table. * ggc-common.c (hashtab.h): Include. (struct d_htab_root): New struct. (d_htab_roots): New variable. (ggc_add_deletable_htab, ggc_htab_delete): New functions (ggc_mark_roots): Handle deletable htabs. * ggc-page.c (ggc_marked_p): New function. * ggc-simple.c (ggc_marked_p): Likewise. * ggc.h: Reformatting throughout. (ggc_marked_p, ggc_add_deletable_htab): New declarations. * tree.c (init_obstacks): Make type_hash_table a deletable root. (type_hash_add): Allocate struct type_hash from GC memory. (mark_hash_entry, mark_type_hash): Deleted. (type_hash_marked_p, type_hash_mark): New functions. * Makefile.in (ggc-common.o, fold-const.o): Include hashtab.h. From-SVN: r45710 --- gcc/ggc-page.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'gcc/ggc-page.c') diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c index b731b29..60517ae 100644 --- a/gcc/ggc-page.c +++ b/gcc/ggc-page.c @@ -1001,6 +1001,35 @@ ggc_set_mark (p) return 0; } +/* Return 1 if P has been marked, zero otherwise. + P must have been allocated by the GC allocator; it mustn't point to + static objects, stack variables, or memory allocated with malloc. */ + +int +ggc_marked_p (p) + const void *p; +{ + page_entry *entry; + unsigned bit, word; + unsigned long mask; + + /* Look up the page on which the object is alloced. If the object + wasn't allocated by the collector, we'll probably die. */ + entry = lookup_page_table_entry (p); +#ifdef ENABLE_CHECKING + if (entry == NULL) + abort (); +#endif + + /* Calculate the index of the object on the page; this is its bit + position in the in_use_p bitmap. */ + bit = (((const char *) p) - entry->page) / OBJECT_SIZE (entry->order); + word = bit / HOST_BITS_PER_LONG; + mask = (unsigned long) 1 << (bit % HOST_BITS_PER_LONG); + + return entry->in_use_p[word] & mask; +} + /* Return the size of the gc-able object P. */ size_t -- cgit v1.1