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 /finalize.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 'finalize.c')
-rw-r--r-- | finalize.c | 20 |
1 files changed, 7 insertions, 13 deletions
@@ -88,9 +88,8 @@ GC_API void GC_CALL GC_push_finalizer_structures(void) #endif /* Double the size of a hash table. *log_size_ptr is the log of its */ -/* current size. May be a no-op. */ -/* *table is a pointer to an array of hash headers. If we succeed, we */ -/* update both *table and *log_size_ptr. Lock is held. */ +/* current size. May be a no-op. *table is a pointer to an array of */ +/* hash headers. We update both *table and *log_size_ptr on success. */ STATIC void GC_grow_table(struct hash_chain_entry ***table, unsigned *log_size_ptr, word *entries_ptr) { @@ -293,8 +292,8 @@ GC_API int GC_CALL GC_unregister_disappearing_link(void * * link) /* Mark from one finalizable object using the specified mark proc. */ /* May not mark the object pointed to by real_ptr (i.e, it is the job */ /* of the caller, if appropriate). Note that this is called with the */ -/* mutator running, but we hold the GC lock. This is safe only */ -/* if the mutator (client) gets the GC lock to reveal hidden pointers. */ +/* mutator running. This is safe only if the mutator (client) gets */ +/* the allocation lock to reveal hidden pointers. */ GC_INLINE void GC_mark_fo(ptr_t real_ptr, finalization_mark_proc mark_proc) { GC_ASSERT(I_HOLD_LOCK()); @@ -522,7 +521,6 @@ GC_API GC_await_finalize_proc GC_CALL GC_get_await_finalize_proc(void) #endif /* !GC_LONG_REFS_NOT_NEEDED */ #ifndef GC_MOVE_DISAPPEARING_LINK_NOT_NEEDED - /* Moves a link. Assume the lock is held. */ STATIC int GC_move_disappearing_link_inner( struct dl_hashtbl_s *dl_hashtbl, void **link, void **new_link) @@ -698,7 +696,6 @@ STATIC void GC_register_finalizer_inner(void * obj, GC_COND_LOG_PRINTF("Grew fo table to %u entries\n", 1U << GC_log_fo_table_size); } - /* in the THREADS case we hold allocation lock. */ for (;;) { struct finalizable_object *prev_fo = NULL; GC_oom_func oom_fn; @@ -927,7 +924,7 @@ GC_API void GC_CALL GC_register_finalizer_unreachable(void * obj, *(char *)&GC_finalizer_nested = (char)(nesting_level + 1); return (unsigned char *)&GC_finalizer_nested; } -#endif /* THREADS */ +#endif /* !THREADS */ GC_INLINE void GC_make_disappearing_links_disappear( struct dl_hashtbl_s* dl_hashtbl, @@ -983,9 +980,8 @@ GC_INLINE void GC_make_disappearing_links_disappear( GC_dirty(dl_hashtbl -> head); /* entire object */ } -/* Called with held lock (but the world is running). */ /* Cause disappearing links to disappear and unreachable objects to be */ -/* enqueued for finalization. */ +/* enqueued for finalization. Called with the world running. */ GC_INNER void GC_finalize(void) { struct finalizable_object * curr_fo, * prev_fo, * next_fo; @@ -1208,8 +1204,6 @@ GC_INNER void GC_finalize(void) * may have been finalized when these finalizers are run. * Finalizers run at this point must be prepared to deal with a * mostly broken world. - * This routine is externally callable, so is called without - * the allocation lock. */ GC_API void GC_CALL GC_finalize_all(void) { @@ -1244,13 +1238,13 @@ GC_API int GC_CALL GC_should_invoke_finalizers(void) } /* Invoke finalizers for all objects that are ready to be finalized. */ -/* Should be called without allocation lock. */ GC_API int GC_CALL GC_invoke_finalizers(void) { int count = 0; word bytes_freed_before = 0; /* initialized to prevent warning. */ DCL_LOCK_STATE; + GC_ASSERT(I_DONT_HOLD_LOCK()); while (GC_should_invoke_finalizers()) { struct finalizable_object * curr_fo; |