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

Allow external use of keep-alive API #24

Merged
merged 1 commit into from
Sep 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
7 changes: 7 additions & 0 deletions include/gc/gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,13 @@ GC_API int GC_CALL GC_invoke_finalizers(void);
# define GC_reachable_here(ptr) GC_noop1((GC_word)(ptr))
#endif

/* Explicitly tell the collector that an object is reachable */
/* at a particular program point. This prevents the argument */
/* pointer from being optimized away, even it is otherwise no */
/* longer needed. Used to prevent finalizers from running when */
/* the associated object is still in use. */
GC_API void GC_CALL GC_keep_alive(GC_word);

/* Make the argument appear live to compiler. Should be robust against */
/* the whole program analysis. */
GC_API void GC_CALL GC_noop1(GC_word);
Expand Down
5 changes: 5 additions & 0 deletions mark.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ GC_API void GC_CALL GC_noop1(GC_word x)
# endif
}

GC_API void GC_keep_alive(GC_word x)
{
GC_reachable_here(x);
}

/* Initialize GC_obj_kinds properly and standard free lists properly. */
/* This must be done statically since they may be accessed before */
/* GC_init is called. */
Expand Down
Loading