Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API for getting number of objects finalised #19

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions fnlz_mlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ void GC_finalize_buffer(GC_finalization_buffer_hdr* buffer) {
word finalizer_word = (*(word *)obj) & ~(word)FINALIZER_CLOSURE_FLAG;
GC_disclaim_proc finalizer = (GC_disclaim_proc) finalizer_word;
(finalizer)(obj);
GC_num_finalized++;
/* Prevent the object from being re-added to the finalization queue */
*(word *)obj = finalizer_word | HAS_BEEN_FINALIZED_FLAG;
cursor++;
Expand Down Expand Up @@ -327,6 +328,10 @@ GC_INNER void GC_maybe_spawn_finalize_thread()
GC_finalizer_thread_exists = 1;
}

GC_API size_t GC_finalized_total(void) {
return GC_num_finalized;
}

# endif

#endif /* ENABLE_DISCLAIM */
2 changes: 2 additions & 0 deletions include/gc/gc_disclaim.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ GC_API int GC_CALL GC_buffered_finalize_posix_memalign(void ** /* memptr */, siz

GC_API void GC_CALL GC_finalize_objects(void);

GC_API size_t GC_finalized_total(void);

#ifdef __cplusplus
} /* extern "C" */
#endif
Expand Down
2 changes: 2 additions & 0 deletions include/private/gc_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1609,6 +1609,8 @@ struct _GC_arrays {
struct GC_current_buffer _fin_buffer_current;
# define GC_finalizer_thread_exists GC_arrays._fin_thread_exists
int _fin_thread_exists;
# define GC_num_finalized GC_arrays._fin_total
unsigned _fin_total;
# endif
# endif
# define n_root_sets GC_arrays._n_root_sets
Expand Down
Loading