File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -2848,6 +2848,9 @@ sgen_gc_invoke_finalizers (void)
2848
2848
2849
2849
g_assert (!pending_unqueued_finalizer );
2850
2850
2851
+ gboolean gchandle_allocated = FALSE;
2852
+ guint32 gchandle = 0 ;
2853
+
2851
2854
/* FIXME: batch to reduce lock contention */
2852
2855
while (sgen_have_pending_finalizers ()) {
2853
2856
GCObject * obj ;
@@ -2878,8 +2881,16 @@ sgen_gc_invoke_finalizers (void)
2878
2881
if (!obj )
2879
2882
break ;
2880
2883
2884
+ // We explicitly pin the object via a gchandle so we don't rely on the ref being
2885
+ // present on stack/regs which is not scannable on WASM.
2886
+ if (!gchandle_allocated ) {
2887
+ gchandle = sgen_gchandle_new (obj , TRUE);
2888
+ gchandle_allocated = TRUE;
2889
+ } else {
2890
+ sgen_gchandle_set_target (gchandle , obj );
2891
+ }
2892
+
2881
2893
count ++ ;
2882
- /* the object is on the stack so it is pinned */
2883
2894
/*g_print ("Calling finalizer for object: %p (%s)\n", obj, sgen_client_object_safe_name (obj));*/
2884
2895
sgen_client_run_finalize (obj );
2885
2896
}
@@ -2889,6 +2900,9 @@ sgen_gc_invoke_finalizers (void)
2889
2900
pending_unqueued_finalizer = FALSE;
2890
2901
}
2891
2902
2903
+ if (gchandle_allocated )
2904
+ sgen_gchandle_free (gchandle );
2905
+
2892
2906
return count ;
2893
2907
}
2894
2908
You can’t perform that action at this time.
0 commit comments