aboutsummaryrefslogtreecommitdiff
path: root/gcc/ggc-page.c
diff options
context:
space:
mode:
authorRichard Kenner <kenner@vlsi1.ultra.nyu.edu>2001-09-20 15:12:54 +0000
committerRichard Kenner <kenner@gcc.gnu.org>2001-09-20 11:12:54 -0400
commit4c160717caf980303ced3d3f17ad0bfd7381f3b2 (patch)
tree9f82325d87e923ce9de88e1e1f44c7643f7d9c53 /gcc/ggc-page.c
parentc762ab6ebb62bc1e1d93b6d81b83737e39df2c01 (diff)
downloadgcc-4c160717caf980303ced3d3f17ad0bfd7381f3b2.zip
gcc-4c160717caf980303ced3d3f17ad0bfd7381f3b2.tar.gz
gcc-4c160717caf980303ced3d3f17ad0bfd7381f3b2.tar.bz2
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
Diffstat (limited to 'gcc/ggc-page.c')
-rw-r--r--gcc/ggc-page.c29
1 files changed, 29 insertions, 0 deletions
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