diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-05-11 08:07:05 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-05-11 12:01:20 +0300 |
commit | 8f72b3545c60e79b18b9cfc18ff6b72270da653e (patch) | |
tree | 7216d509546d8cd1987b6be180ce970e42a6e6e6 /mark.c | |
parent | 970cf9d5e32f7023eb9acb082f241593bcc9a5bd (diff) | |
download | bdwgc-8f72b3545c60e79b18b9cfc18ff6b72270da653e.tar.gz |
Replace comments about GC is held or not with relevant assertions
(refactoring)
* alloc.c (GC_default_stop_func): Refine comment about the allocation
lock.
* alloc.c (GC_finish_collection): Remove comment that the allocation
lock is held because the assertion about it already exists.
* finalize.c (GC_grow_table, GC_mark_fo, GC_finalize): Likewise.
* finalize.c [!GC_MOVE_DISAPPEARING_LINK_NOT_NEEDED]
(GC_move_disappearing_link_inner): Likewise.
* mark.c (GC_mark_some_inner): Likewise.
* mark.c [PARALLEL_MARK] (GC_do_parallel_mark): Likewise.
* os_dep.c [OPENBSD && GC_OPENBSD_UTHREADS] (GC_find_limit_openbsd,
GC_skip_hole_openbsd): Likewise.
* os_dep.c [NEED_FIND_LIMIT || USE_PROC_FOR_LIBRARIES && THREADS]
(GC_find_limit_with_bound): Likewise.
* os_dep.c (GC_register_data_segments): Likewise.
* os_dep.c [MPROTECT_VDB || PROC_VDB || SOFT_VDB] (GC_dirty_init):
Likewise.
* pthread_stop_world.c (GC_start_world): Likewise.
* pthread_support.c (GC_new_thread): Likewise.
* thread_local_alloc.c (return_freelists): Likewise.
* win32_threads.c (GC_new_thread, GC_lookup_thread_inner,
GC_delete_gc_thread_no_free): Likewise.
* blacklst.c (GC_promote_black_lists): Remove comment that the
allocation lock is held, and add the corresponding assertion to the
beginning of the function.
* blacklst.c [!PARALLEL_MARK] (GC_add_to_black_list_normal,
GC_add_to_black_list_stack): Likewise.
* darwin_stop_world.c (GC_stop_world, GC_start_world): Likewise.
* mark_rts.c (GC_remove_root_at_pos, GC_remove_roots_inner,
GC_exclude_static_roots_inner): Likewise.
* pthread_stop_world.c (GC_push_all_stacks, GC_suspend_all): Likewise.
* pthread_support.c (GC_check_finalizer_nested): Likewise.
* thread_local_alloc.c (GC_destroy_thread_local): Likewise.
* win32_threads.c (GC_check_finalizer_nested, GC_push_all_stacks):
Likewise.
* blacklst.c (GC_is_black_listed): Refine comment about the allocation
lock.
* darwin_stop_world.c (GC_push_all_stacks): Add assertion that the lock
is held on entrance.
* gcj_mlc.c (maybe_finalize): Likewise.
* malloc.c [THREADS] (GC_free_inner): Likewise.
* dyn_load.c (GC_dyld_image_add, GC_dyld_image_remove, GC_init_dyld):
Remove comment the allocation lock should not be held, and add the
corresponding assertion to the beginning of the function.
* finalize.c (GC_invoke_finalizers): Likewise.
* mark.c [PARALLEL_MARK] (GC_help_marker): Likewise.
* pthread_support.c (GC_init_parallel): Likewise.
* win32_threads.c (GC_lookup_pthread, GC_init_parallel): Likewise.
* finalize.c (GC_finalize_all): Remove comment that the lock is not
held on entrance.
* gcj_mlc.c (GC_init_gcj_malloc): Likewise.
* typd_mlc.c (GC_add_ext_descriptor): Likewise.
* include/gc/javaxfc.h (GC_finalize_all): Add comment the function
acquires the allocation lock.
* mallocx.c (GC_generic_malloc_many): Adjust comment about GC lock.
* new_hblk.c (GC_build_fl): Likewise.
* pthread_support.c (GC_new_thread): Move the assertion about the
allocation lock closer to the beginning of the function.
* win32_threads.c (GC_new_thread): Likewise.
Diffstat (limited to 'mark.c')
-rw-r--r-- | mark.c | 22 |
1 files changed, 9 insertions, 13 deletions
@@ -293,14 +293,12 @@ static void push_roots_and_advance(GC_bool push_all, ptr_t cold_gc_frame) /* Cold_gc_frame is an address inside a GC frame that */ /* remains valid until all marking is complete. */ /* A zero value indicates that it's OK to miss some */ -/* register values. */ -/* We hold the allocation lock. In the case of */ -/* incremental collection, the world may not be stopped.*/ +/* register values. In the case of an incremental */ +/* collection, the world may be running. */ #ifdef WRAP_MARK_SOME /* For win32, this is called after we establish a structured */ /* exception handler, in case Windows unmaps one of our root */ - /* segments. See below. In either case, we acquire the */ - /* allocator lock long before we get here. */ + /* segments. */ STATIC GC_bool GC_mark_some_inner(ptr_t cold_gc_frame) #else GC_INNER GC_bool GC_mark_some(ptr_t cold_gc_frame) @@ -1192,14 +1190,13 @@ STATIC void GC_mark_local(mse *local_mark_stack, int id) } } -/* Perform Parallel mark. */ -/* We hold the GC lock, not the mark lock. */ -/* Currently runs until the mark stack is */ -/* empty. */ +/* Perform parallel mark. We hold the GC lock, not the mark lock. */ +/* Currently runs until the mark stack is empty. */ STATIC void GC_do_parallel_mark(void) { GC_acquire_mark_lock(); GC_ASSERT(I_HOLD_LOCK()); + /* This could be a GC_ASSERT, but it seems safer to keep it on */ /* all the time, especially since it's cheap. */ if (GC_help_wanted || GC_active_count != 0 || GC_helper_count != 0) @@ -1226,10 +1223,8 @@ STATIC void GC_do_parallel_mark(void) GC_notify_all_marker(); } - -/* Try to help out the marker, if it's running. */ -/* We do not hold the GC lock, but the requestor does. */ -/* And we hold the mark lock. */ +/* Try to help out the marker, if it's running. We hold the mark lock */ +/* only, the initiating thread holds the allocation lock. */ GC_INNER void GC_help_marker(word my_mark_no) { # define my_id my_id_mse.mse_descr.w @@ -1237,6 +1232,7 @@ GC_INNER void GC_help_marker(word my_mark_no) mse local_mark_stack[LOCAL_MARK_STACK_SIZE]; /* Note: local_mark_stack is quite big (up to 128 KiB). */ + GC_ASSERT(I_DONT_HOLD_LOCK()); GC_ASSERT(GC_parallel); while (GC_mark_no < my_mark_no || (!GC_help_wanted && GC_mark_no == my_mark_no)) { |