diff options
author | hboehm <hboehm> | 2009-05-28 00:51:35 +0000 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2011-07-26 21:06:45 +0400 |
commit | ebabfaa4168439668bb8b3b033276f8998cacb4b (patch) | |
tree | ca7bde930cc0c8bb24c623fe58c9c6a4a87854db /mallocx.c | |
parent | 5190c1d75ea1f284124e52628625a83bcee5fc3c (diff) | |
download | bdwgc-ebabfaa4168439668bb8b3b033276f8998cacb4b.tar.gz |
2009-05-27 Hans Boehm <Hans.Boehm@hp.com> (Really Ivan Maidanski)
(diff26)
* win32_threads.c: restructure parallel marking mutex intialization.
* win32_threads.c, alloc.c, darwin_stop_world.c, mallocx.c, mark.c,
pthread_stop_world.c, pthread_support.c: Add runtime conditions
on GC_parallel were appropriate.
* pthread_support.c: Condition marker_bsp on ia64.
(GC_segment_is_thread_stack): Fix loop upper bound.
* reclaim.c: Limit some assertions to PARALLEL_MARK.
* pthread_support.c: Don't acquire mark lock for thread-local
allocation.
* include/private/gc_priv.h: Don't define parallel mark sync
support just for THREAD_LOCAL_ALLOC.
Diffstat (limited to 'mallocx.c')
-rw-r--r-- | mallocx.c | 85 |
1 files changed, 45 insertions, 40 deletions
@@ -307,7 +307,7 @@ DCL_LOCK_STATE; GC_ASSERT(hhdr -> hb_sz == lb); hhdr -> hb_last_reclaimed = (unsigned short) GC_gc_no; # ifdef PARALLEL_MARK - { + if (GC_parallel) { signed_word my_bytes_allocd_tmp = GC_bytes_allocd_tmp; GC_ASSERT(my_bytes_allocd_tmp >= 0); @@ -320,11 +320,11 @@ DCL_LOCK_STATE; (AO_t)(-my_bytes_allocd_tmp)); GC_bytes_allocd += my_bytes_allocd_tmp; } - } - GC_acquire_mark_lock(); - ++ GC_fl_builder_count; - UNLOCK(); - GC_release_mark_lock(); + GC_acquire_mark_lock(); + ++ GC_fl_builder_count; + UNLOCK(); + GC_release_mark_lock(); + } # endif op = GC_reclaim_generic(hbp, hhdr, lb, ok -> ok_init, 0, &my_bytes_allocd); @@ -335,30 +335,33 @@ DCL_LOCK_STATE; /* inaccurate. */ GC_bytes_found += my_bytes_allocd; # ifdef PARALLEL_MARK - *result = op; - (void)AO_fetch_and_add( + if (GC_parallel) { + *result = op; + (void)AO_fetch_and_add( (volatile AO_t *)(&GC_bytes_allocd_tmp), (AO_t)(my_bytes_allocd)); + GC_acquire_mark_lock(); + -- GC_fl_builder_count; + if (GC_fl_builder_count == 0) GC_notify_all_builder(); + GC_release_mark_lock(); + (void) GC_clear_stack(0); + return; + } +# endif + GC_bytes_allocd += my_bytes_allocd; + goto out; + } +# ifdef PARALLEL_MARK + if (GC_parallel) { GC_acquire_mark_lock(); -- GC_fl_builder_count; if (GC_fl_builder_count == 0) GC_notify_all_builder(); GC_release_mark_lock(); - (void) GC_clear_stack(0); - return; -# else - GC_bytes_allocd += my_bytes_allocd; - goto out; -# endif - } -# ifdef PARALLEL_MARK - GC_acquire_mark_lock(); - -- GC_fl_builder_count; - if (GC_fl_builder_count == 0) GC_notify_all_builder(); - GC_release_mark_lock(); - LOCK(); - /* GC lock is needed for reclaim list access. We */ - /* must decrement fl_builder_count before reaquiring GC */ - /* lock. Hopefully this path is rare. */ + LOCK(); + /* GC lock is needed for reclaim list access. We */ + /* must decrement fl_builder_count before reaquiring GC */ + /* lock. Hopefully this path is rare. */ + } # endif } } @@ -387,24 +390,26 @@ DCL_LOCK_STATE; if (IS_UNCOLLECTABLE(k)) GC_set_hdr_marks(HDR(h)); GC_bytes_allocd += HBLKSIZE - HBLKSIZE % lb; # ifdef PARALLEL_MARK - GC_acquire_mark_lock(); - ++ GC_fl_builder_count; - UNLOCK(); - GC_release_mark_lock(); -# endif + if (GC_parallel) { + GC_acquire_mark_lock(); + ++ GC_fl_builder_count; + UNLOCK(); + GC_release_mark_lock(); - op = GC_build_fl(h, lw, (ok -> ok_init || GC_debugging_started), 0); -# ifdef PARALLEL_MARK - *result = op; - GC_acquire_mark_lock(); - -- GC_fl_builder_count; - if (GC_fl_builder_count == 0) GC_notify_all_builder(); - GC_release_mark_lock(); - (void) GC_clear_stack(0); - return; -# else - goto out; + op = GC_build_fl(h, lw, + (ok -> ok_init || GC_debugging_started), 0); + + *result = op; + GC_acquire_mark_lock(); + -- GC_fl_builder_count; + if (GC_fl_builder_count == 0) GC_notify_all_builder(); + GC_release_mark_lock(); + (void) GC_clear_stack(0); + return; + } # endif + op = GC_build_fl(h, lw, (ok -> ok_init || GC_debugging_started), 0); + goto out; } } |