summaryrefslogtreecommitdiff
path: root/gcc/ggc-page.c
diff options
context:
space:
mode:
authorkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>2001-09-20 15:12:54 +0000
committerkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>2001-09-20 15:12:54 +0000
commit15d769aab42c4ea8a8863b8b37dee46c77155be0 (patch)
tree9f82325d87e923ce9de88e1e1f44c7643f7d9c53 /gcc/ggc-page.c
parent41f4d177c8884f82b1a6f3cf74af02cfd7e1c15c (diff)
downloadgcc-15d769aab42c4ea8a8863b8b37dee46c77155be0.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45710 138bc75d-0d04-0410-961f-82ee72b054a4
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 b731b296071..60517ae9020 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