@@ -74,7 +74,7 @@ void jl_gc_init(void) {
74
74
75
75
jl_set_check_alive_type (mmtk_is_reachable_object );
76
76
77
- arraylist_new (& gc_pinned_objects , 0 );
77
+ arraylist_new (& extra_gc_roots , 0 );
78
78
arraylist_new (& to_finalize , 0 );
79
79
arraylist_new (& finalizer_list_marked , 0 );
80
80
gc_num .interval = default_collect_interval ;
@@ -254,36 +254,6 @@ JL_DLLEXPORT void jl_gc_collect(jl_gc_collection_t collection) {
254
254
// print_fragmentation();
255
255
}
256
256
257
- void gc_pin_objects_from_compiler_frontend (arraylist_t * objects_pinned_by_call )
258
- {
259
- for (size_t i = 0 ; i < gc_pinned_objects .len ; i ++ ) {
260
- void * obj = gc_pinned_objects .items [i ];
261
- unsigned char got_pinned = mmtk_pin_object (obj );
262
- if (got_pinned ) {
263
- arraylist_push (objects_pinned_by_call , obj );
264
- }
265
- }
266
- for (size_t i = 0 ; i < jl_ast_ctx_used .len ; i ++ ) {
267
- void * ctx = jl_ast_ctx_used .items [i ];
268
- arraylist_t * pinned_objects = extract_pinned_objects_from_ast_ctx (ctx );
269
- for (size_t j = 0 ; j < pinned_objects -> len ; j ++ ) {
270
- void * obj = pinned_objects -> items [j ];
271
- unsigned char got_pinned = mmtk_pin_object (obj );
272
- if (got_pinned ) {
273
- arraylist_push (objects_pinned_by_call , obj );
274
- }
275
- }
276
- }
277
- }
278
-
279
- void gc_unpin_objects_from_compiler_frontend (arraylist_t * objects_pinned_by_call )
280
- {
281
- for (size_t i = 0 ; i < objects_pinned_by_call -> len ; i ++ ) {
282
- void * obj = objects_pinned_by_call -> items [i ];
283
- mmtk_unpin_object (obj );
284
- }
285
- }
286
-
287
257
// Based on jl_gc_collect from gc-stock.c
288
258
// called when stopping the thread in `mmtk_block_for_gc`
289
259
JL_DLLEXPORT void jl_gc_prepare_to_collect (void )
@@ -346,12 +316,7 @@ JL_DLLEXPORT void jl_gc_prepare_to_collect(void)
346
316
jl_gc_notify_thread_yield (ptls , NULL );
347
317
JL_LOCK_NOGC (& finalizers_lock ); // all the other threads are stopped, so this does not make sense, right? otherwise, failing that, this seems like plausibly a deadlock
348
318
#ifndef __clang_gcanalyzer__
349
- arraylist_t objects_pinned_by_call ;
350
- arraylist_new (& objects_pinned_by_call , 0 );
351
- gc_pin_objects_from_compiler_frontend (& objects_pinned_by_call );
352
319
mmtk_block_thread_for_gc ();
353
- gc_unpin_objects_from_compiler_frontend (& objects_pinned_by_call );
354
- arraylist_free (& objects_pinned_by_call );
355
320
#endif
356
321
JL_UNLOCK_NOGC (& finalizers_lock );
357
322
}
@@ -838,6 +803,22 @@ JL_DLLEXPORT void jl_gc_scan_vm_specific_roots(RootsWorkClosure* closure)
838
803
}
839
804
}
840
805
806
+ // Trace objects in extra_gc_roots
807
+ for (size_t i = 0 ; i < extra_gc_roots .len ; i ++ ) {
808
+ void * obj = extra_gc_roots .items [i ];
809
+ add_node_to_roots_buffer (closure , & buf , & len , obj );
810
+ }
811
+
812
+ // Trace objects in jl_ast_ctx_used
813
+ for (size_t i = 0 ; i < jl_ast_ctx_used .len ; i ++ ) {
814
+ void * ctx = jl_ast_ctx_used .items [i ];
815
+ arraylist_t * ast_roots = extract_ast_roots_from_ast_ctx (ctx );
816
+ for (size_t j = 0 ; j < ast_roots -> len ; j ++ ) {
817
+ void * obj = ast_roots -> items [j ];
818
+ add_node_to_roots_buffer (closure , & buf , & len , obj );
819
+ }
820
+ }
821
+
841
822
// // add module
842
823
// add_node_to_roots_buffer(closure, &buf, &len, jl_main_module);
843
824
0 commit comments