diff options
author | Petter Urkedal <urkedal@nbi.dk> | 2007-07-01 13:48:00 +0200 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2011-09-30 17:34:38 +0400 |
commit | 6c1a9244581cdceaf39c7321e524b1ef5a099980 (patch) | |
tree | 69789d0b45c46224f4675f0d37b6386251193d3e /thread_local_alloc.c | |
parent | afbc74ab7f0fb3f19d18294083cbcf68a6200e58 (diff) | |
download | bdwgc-6c1a9244581cdceaf39c7321e524b1ef5a099980.tar.gz |
Add disclaim callbacks for efficient finalization.
Importing gc-20070403-disclaim-1.0.patch.
* configure.ac: Add --disable-disclaim option and set ENABLE_DISCLAIM macro
and conditional accordingly.
* include/include.am, Makefile.am Add sources disclaim.c and
include/gc_disclaim.h.
* Makefile.direct: Ditto and define ENABLE_DISCLAIM.
* include/private/gc_priv.h (obj_kind): Add ok_mark_unconditionally,
ok_disclaim_proc and ok_disclaim_cd.
* misc.c (GC_new_kind_inner): Initialize them.
* include/private/gc_priv.h (hblkhdr): Add HAS_DISCLAIM and
MARK_UNCONDITIONALLY flags.
* allchblk.c (setup_header): Set HAS_DISCLAIM and MARK_UNCONDITIONALLY flags
as indicated by the object kind.
* reclaim.c: Main adjustments to support the disclaim callbacks.
* mark.c (GC_push_unconditionally, GC_push_next_marked_uncollecable):
Unconditionally mark from objects in blocks flagged MARK_UNCONDITIONALLY.
This preserves links reachable from the finalizer when using the the
finalized object kind.
* disclaim.c: Add file with support functions for disclaim callbacks and
implementation of the "finalized" object kind.
* include/gc_disclaim.h: Add file providing the corresponding API.
* include/private/thread_local_alloc.h (thread_local_freelists): Add
finalized_freelists.
* thread_local_alloc.c: Initialize them.
* tests/tests.am, tests/disclaim_test.c, tests/disclaim_bench.c: Add
disclaim-related tests.
Diffstat (limited to 'thread_local_alloc.c')
-rw-r--r-- | thread_local_alloc.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/thread_local_alloc.c b/thread_local_alloc.c index 610db6fd..ac351734 100644 --- a/thread_local_alloc.c +++ b/thread_local_alloc.c @@ -98,6 +98,9 @@ GC_INNER void GC_init_thread_local(GC_tlfs p) # ifdef GC_GCJ_SUPPORT p -> gcj_freelists[i] = (void *)(word)1; # endif +# ifdef ENABLE_DISCLAIM + p -> finalized_freelists[i] = (void *)1; +# endif } /* Set up the size 0 free lists. */ /* We now handle most of them like regular free lists, to ensure */ @@ -108,6 +111,9 @@ GC_INNER void GC_init_thread_local(GC_tlfs p) # ifdef GC_GCJ_SUPPORT p -> gcj_freelists[0] = ERROR_FL; # endif +# ifdef ENABLE_DISCLAIM + p -> finalized_freelists[0] = (void *)1; +# endif } /* We hold the allocator lock. */ @@ -280,6 +286,10 @@ GC_INNER void GC_mark_thread_local_fls_for(GC_tlfs p) if ((word)q > HBLKSIZE) GC_set_fl_marks(q); } # endif /* GC_GCJ_SUPPORT */ +# ifdef ENABLE_DISCLAIM + q = p -> finalized_freelists[j]; + if ((word)q > HBLKSIZE) GC_set_fl_marks(q); +# endif } } @@ -299,6 +309,10 @@ GC_INNER void GC_mark_thread_local_fls_for(GC_tlfs p) q = p -> gcj_freelists[j]; if ((word)q > HBLKSIZE) GC_check_fl_marks(q); # endif /* GC_GCJ_SUPPORT */ +# ifdef ENABLE_DISCLAIM + q = p -> finalized_freelists[j]; + if ((word)q > HBLKSIZE) GC_check_fl_marks(q); +# endif } } #endif /* GC_ASSERTIONS */ |