File tree Expand file tree Collapse file tree
crates/wasmtime/src/runtime/vm/gc/enabled Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -853,21 +853,20 @@ unsafe impl GcHeap for DrcHeap {
853853 }
854854
855855 fn expose_gc_ref_to_wasm ( & mut self , gc_ref : VMGcRef ) {
856+ // Read the current list head before borrowing through index_mut.
857+ let next = ( * self . over_approximated_stack_roots )
858+ . as_ref ( )
859+ . map ( |r| r. unchecked_copy ( ) ) ;
856860 let header = self . index_mut ( drc_ref ( & gc_ref) ) ;
857861 if header. is_in_over_approximated_stack_roots ( ) {
858862 // Already in the over-approximated-stack-roots list, nothing more
859863 // to do here.
860864 return ;
861865 }
862-
863866 // Push this object onto the head of the over-approximated-stack-roots
864- // list.
867+ // list using a single index_mut call .
865868 header. set_in_over_approximated_stack_roots_bit ( true ) ;
866- let next = ( * self . over_approximated_stack_roots )
867- . as_ref ( )
868- . map ( |r| r. unchecked_copy ( ) ) ;
869- self . index_mut ( drc_ref ( & gc_ref) )
870- . set_next_over_approximated_stack_root ( next) ;
869+ header. set_next_over_approximated_stack_root ( next) ;
871870 * self . over_approximated_stack_roots = Some ( gc_ref) ;
872871 }
873872
You can’t perform that action at this time.
0 commit comments