summaryrefslogtreecommitdiff
path: root/gcc/ggc-none.c
diff options
context:
space:
mode:
authortbsaunde <tbsaunde@138bc75d-0d04-0410-961f-82ee72b054a4>2014-05-17 23:08:00 +0000
committertbsaunde <tbsaunde@138bc75d-0d04-0410-961f-82ee72b054a4>2014-05-17 23:08:00 +0000
commit92f06184bb548e33327e5c9895b5d00f9e6d0304 (patch)
tree10dcc038bf8bcfb0dd6268ffbf36527b525bfb4e /gcc/ggc-none.c
parent16f97f36c2d368ed6618b8ac65958c0232187b55 (diff)
downloadgcc-92f06184bb548e33327e5c9895b5d00f9e6d0304.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210568 138bc75d-0d04-0410-961f-82ee72b054a4
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 aad89bfe009..97d356657f0 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);
}