aboutsummaryrefslogtreecommitdiff
path: root/gcc/ggc-none.c
diff options
context:
space:
mode:
authorTrevor Saunders <tsaunders@mozilla.com>2014-05-17 23:08:00 +0000
committerTrevor Saunders <tbsaunde@gcc.gnu.org>2014-05-17 23:08:00 +0000
commitde49ce19cc37f620ee42caabda56f71bcb350887 (patch)
tree10dcc038bf8bcfb0dd6268ffbf36527b525bfb4e /gcc/ggc-none.c
parent04eec9877832c7cbb0ed270f700db8e5e3f25c93 (diff)
downloadgcc-de49ce19cc37f620ee42caabda56f71bcb350887.zip
gcc-de49ce19cc37f620ee42caabda56f71bcb350887.tar.gz
gcc-de49ce19cc37f620ee42caabda56f71bcb350887.tar.bz2
add finalizers to ggc
This implements finalizers by keeping a list of registered finalizers and after every mark but before sweeping check to see if any of them are for unmarked blocks. gcc/ChangeLog: * ggc-common.c (ggc_internal_cleared_alloc): Adjust. * ggc-none.c (ggc_internal_alloc): Assert if a finalizer is passed. (ggc_internal_cleared_alloc): Likewise. * ggc-page.c (finalizer): New class. (vec_finalizer): Likewise. (globals::finalizers): New member. (globals::vec_finalizers): Likewise. (ggc_internal_alloc): Record the finalizer if any for the block being allocated. (ggc_handle_finalizers): New function. (ggc_collect): Call ggc_handle_finalizers. * ggc.h (ggc_internal_alloc): Add arguments to allow installing a finalizer. (ggc_internal_cleared_alloc): Likewise. (finalize): New function. (need_finalization_p): Likewise. (ggc_alloc): Install the type's destructor as the finalizer if it might do something. (ggc_cleared_alloc): Likewise. (ggc_vec_alloc): Likewise. (ggc_cleared_vec_alloc): Likewise. From-SVN: r210568
Diffstat (limited to 'gcc/ggc-none.c')
-rw-r--r--gcc/ggc-none.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/ggc-none.c b/gcc/ggc-none.c
index aad89bf..97d3566 100644
--- a/gcc/ggc-none.c
+++ b/gcc/ggc-none.c
@@ -41,14 +41,18 @@ ggc_round_alloc_size (size_t requested_size)
}
void *
-ggc_internal_alloc (size_t size MEM_STAT_DECL)
+ggc_internal_alloc (size_t size, void (*f)(void *), size_t, size_t
+ MEM_STAT_DECL)
{
+ gcc_assert (!f); // ggc-none doesn't support finalizers
return xmalloc (size);
}
void *
-ggc_internal_cleared_alloc (size_t size MEM_STAT_DECL)
+ggc_internal_cleared_alloc (size_t size, void (*f)(void *), size_t, size_t
+ MEM_STAT_DECL)
{
+ gcc_assert (!f); // ggc-none doesn't support finalizers
return xcalloc (size, 1);
}