@@ -101,13 +101,26 @@ JL_DLLEXPORT void jl_gc_set_max_memory(uint64_t max_mem);
101
101
JL_DLLEXPORT void jl_gc_collect (jl_gc_collection_t collection );
102
102
// Returns whether the thread with `tid` is a collector thread
103
103
JL_DLLEXPORT int gc_is_collector_thread (int tid ) JL_NOTSAFEPOINT ;
104
+ // Pinning objects; Returns whether the object has been pinned by this call.
105
+ JL_DLLEXPORT unsigned char jl_gc_pin_object (void * obj );
104
106
// Returns which GC implementation is being used and possibly its version according to the list of supported GCs
105
107
// NB: it should clearly identify the GC by including e.g. ‘stock’ or ‘mmtk’ as a substring.
106
108
JL_DLLEXPORT const char * jl_gc_active_impl (void );
107
109
// Sweep Julia's stack pools and mtarray buffers. Note that this function has been added to the interface as
108
110
// each GC should implement it but it will most likely not be used by other code in the runtime.
109
111
// It still needs to be annotated with JL_DLLEXPORT since it is called from Rust by MMTk.
110
112
JL_DLLEXPORT void jl_gc_sweep_stack_pools_and_mtarraylist_buffers (jl_ptls_t ptls ) JL_NOTSAFEPOINT ;
113
+ // Notifies the GC that the given thread is about to yield for a GC. ctx is the ucontext for the thread
114
+ // if it is already fetched by the caller, otherwise it is NULL.
115
+ JL_DLLEXPORT void jl_gc_notify_thread_yield (jl_ptls_t ptls , void * ctx );
116
+
117
+ // TODO: The preserve hook functions may be temporary. We should see the performance impact of the change.
118
+
119
+ // Runtime hook for gc preserve begin. The GC needs to make sure that the preserved objects and its children stay alive and won't move.
120
+ JL_DLLEXPORT void jl_gc_preserve_begin_hook (int n , ...) JL_NOTSAFEPOINT ;
121
+ // Runtime hook for gc preserve end. The GC needs to make sure that the preserved objects and its children stay alive and won't move.
122
+ JL_DLLEXPORT void jl_gc_preserve_end_hook (void ) JL_NOTSAFEPOINT ;
123
+
111
124
112
125
// ========================================================================= //
113
126
// Metrics
@@ -207,10 +220,22 @@ JL_DLLEXPORT void *jl_gc_perm_alloc(size_t sz, int zero, unsigned align,
207
220
// the allocated object. All objects stored in fields of this object
208
221
// must be either permanently allocated or have other roots.
209
222
struct _jl_value_t * jl_gc_permobj (size_t sz , void * ty ) JL_NOTSAFEPOINT ;
223
+ // permanently allocates a symbol (jl_sym_t). The object needs to be word aligned,
224
+ // and tagged with jl_sym_tag.
225
+ // FIXME: Ideally we should merge this with jl_gc_permobj, as symbol is an object.
226
+ // Currently there are a few differences between the two functions, and refactoring is needed.
227
+ // 1. sz for this function includes the object header, and sz for jl_gc_permobj excludes the header size.
228
+ // 2. align for this function is word align, and align for jl_gc_permobj depends on the allocation size.
229
+ // 3. ty for this function is jl_symbol_tag << 4, and ty for jl_gc_permobj is a datatype pointer.
230
+ struct _jl_value_t * jl_gc_permsymbol (size_t sz ) JL_NOTSAFEPOINT ;
210
231
// This function notifies the GC about memory addresses that are set when loading the boot image.
211
232
// The GC may use that information to, for instance, determine that such objects should
212
233
// be treated as marked and belonged to the old generation in nursery collections.
213
234
void jl_gc_notify_image_load (const char * img_data , size_t len );
235
+ // This function notifies the GC about memory addresses that are set when allocating the boot image.
236
+ // The GC may use that information to, for instance, determine that all objects in that chunk of memory should
237
+ // be treated as marked and belonged to the old generation in nursery collections.
238
+ void jl_gc_notify_image_alloc (const char * img_data , size_t len );
214
239
215
240
// ========================================================================= //
216
241
// Runtime Write-Barriers
0 commit comments