diff options
author | tbsaunde <tbsaunde@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-05-17 23:08:00 +0000 |
---|---|---|
committer | tbsaunde <tbsaunde@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-05-17 23:08:00 +0000 |
commit | 92f06184bb548e33327e5c9895b5d00f9e6d0304 (patch) | |
tree | 10dcc038bf8bcfb0dd6268ffbf36527b525bfb4e /gcc/ggc-common.c | |
parent | 16f97f36c2d368ed6618b8ac65958c0232187b55 (diff) | |
download | gcc-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-common.c')
-rw-r--r-- | gcc/ggc-common.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c index e89cc64b958..b11a10c0072 100644 --- a/gcc/ggc-common.c +++ b/gcc/ggc-common.c @@ -174,9 +174,10 @@ ggc_mark_roots (void) /* Allocate a block of memory, then clear it. */ void * -ggc_internal_cleared_alloc (size_t size MEM_STAT_DECL) +ggc_internal_cleared_alloc (size_t size, void (*f)(void *), size_t s, size_t n + MEM_STAT_DECL) { - void *buf = ggc_internal_alloc (size PASS_MEM_STAT); + void *buf = ggc_internal_alloc (size, f, s, n PASS_MEM_STAT); memset (buf, 0, size); return buf; } |