@@ -6,6 +6,10 @@ pub trait VisitMachineValues {
66 fn visit_machine_values ( & self , visit : & mut impl FnMut ( & Operand < Provenance > ) ) ;
77}
88
9+ pub trait VisitProvenance {
10+ fn visit_provenance ( & self , visit : & mut impl FnMut ( SbTag ) ) ;
11+ }
12+
913impl < ' mir , ' tcx : ' mir > EvalContextExt < ' mir , ' tcx > for crate :: MiriInterpCx < ' mir , ' tcx > { }
1014pub trait EvalContextExt < ' mir , ' tcx : ' mir > : MiriInterpCxExt < ' mir , ' tcx > {
1115 /// Generic GC helper to visit everything that can store a value. The `acc` offers some chance to
@@ -46,6 +50,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> {
4650 }
4751 } ;
4852
53+ let visit_provenance = |tags : & mut FxHashSet < SbTag > , tag : SbTag | {
54+ tags. insert ( tag) ;
55+ } ;
56+
4957 this. visit_all_machine_values (
5058 & mut tags,
5159 |tags, op| {
@@ -71,21 +79,15 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> {
7179 tags. insert ( * sb) ;
7280 }
7381 }
74- let stacks = alloc
75- . extra
76- . stacked_borrows
77- . as_ref ( )
78- . expect ( "we should not even enter the GC if Stacked Borrows is disabled" ) ;
79- tags . extend ( & stacks. borrow ( ) . exposed_tags ) ;
82+
83+ let stacks =
84+ alloc . extra . stacked_borrows . as_ref ( ) . expect (
85+ "we should not even enter the tag GC if Stacked Borrows is disabled" ,
86+ ) ;
87+ stacks. borrow ( ) . visit_provenance ( & mut |tag| visit_provenance ( tags , tag ) ) ;
8088
8189 if let Some ( store_buffers) = alloc. extra . weak_memory . as_ref ( ) {
82- store_buffers. iter ( |val| {
83- if let Scalar :: Ptr ( ptr, _) = val {
84- if let Provenance :: Concrete { sb, .. } = ptr. provenance {
85- tags. insert ( sb) ;
86- }
87- }
88- } ) ;
90+ store_buffers. visit_provenance ( & mut |tag| visit_provenance ( tags, tag) ) ;
8991 }
9092 } ,
9193 ) ;
0 commit comments