@@ -5,7 +5,6 @@ use log::trace;
55use std:: cell:: RefCell ;
66use std:: fmt;
77use std:: num:: NonZeroU64 ;
8- use std:: rc:: Rc ;
98
109use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
1110use rustc_hir:: Mutability ;
@@ -14,17 +13,14 @@ use rustc_middle::ty::{
1413 self ,
1514 layout:: { HasParamEnv , LayoutOf } ,
1615} ;
17- use rustc_span:: def_id:: CrateNum ;
1816use rustc_span:: DUMMY_SP ;
1917use rustc_target:: abi:: Size ;
2018use std:: collections:: HashSet ;
2119
2220use crate :: * ;
2321
2422pub mod diagnostics;
25- use diagnostics:: AllocHistory ;
26-
27- use diagnostics:: TagHistory ;
23+ use diagnostics:: { AllocHistory , TagHistory } ;
2824
2925pub type PtrId = NonZeroU64 ;
3026pub type CallId = NonZeroU64 ;
@@ -376,7 +372,7 @@ impl<'tcx> Stack {
376372 tag : SbTag ,
377373 ( alloc_id, alloc_range, offset) : ( AllocId , AllocRange , Size ) , // just for debug printing and error messages
378374 global : & mut GlobalStateInner ,
379- threads : & ThreadManager < ' _ , ' tcx > ,
375+ current_span : & mut CurrentSpan < ' _ , ' _ , ' tcx > ,
380376 alloc_history : & mut AllocHistory ,
381377 ) -> InterpResult < ' tcx > {
382378 // Two main steps: Find granting item, remove incompatible items above.
@@ -400,7 +396,7 @@ impl<'tcx> Stack {
400396 global,
401397 alloc_history,
402398 ) ?;
403- alloc_history. log_invalidation ( item. tag , alloc_range, threads ) ;
399+ alloc_history. log_invalidation ( item. tag , alloc_range, current_span ) ;
404400 }
405401 } else {
406402 // On a read, *disable* all `Unique` above the granting item. This ensures U2 for read accesses.
@@ -422,7 +418,7 @@ impl<'tcx> Stack {
422418 alloc_history,
423419 ) ?;
424420 item. perm = Permission :: Disabled ;
425- alloc_history. log_invalidation ( item. tag , alloc_range, threads ) ;
421+ alloc_history. log_invalidation ( item. tag , alloc_range, current_span ) ;
426422 }
427423 }
428424 }
@@ -471,7 +467,7 @@ impl<'tcx> Stack {
471467 new : Item ,
472468 ( alloc_id, alloc_range, offset) : ( AllocId , AllocRange , Size ) , // just for debug printing and error messages
473469 global : & mut GlobalStateInner ,
474- threads : & ThreadManager < ' _ , ' tcx > ,
470+ current_span : & mut CurrentSpan < ' _ , ' _ , ' tcx > ,
475471 alloc_history : & mut AllocHistory ,
476472 ) -> InterpResult < ' tcx > {
477473 // Figure out which access `perm` corresponds to.
@@ -505,7 +501,7 @@ impl<'tcx> Stack {
505501 derived_from,
506502 ( alloc_id, alloc_range, offset) ,
507503 global,
508- threads ,
504+ current_span ,
509505 alloc_history,
510506 ) ?;
511507
@@ -533,13 +529,13 @@ impl<'tcx> Stack {
533529/// Map per-stack operations to higher-level per-location-range operations.
534530impl < ' tcx > Stacks {
535531 /// Creates new stack with initial tag.
536- fn new ( size : Size , perm : Permission , tag : SbTag , local_crates : Rc < [ CrateNum ] > ) -> Self {
532+ fn new ( size : Size , perm : Permission , tag : SbTag ) -> Self {
537533 let item = Item { perm, tag, protector : None } ;
538534 let stack = Stack { borrows : vec ! [ item] } ;
539535
540536 Stacks {
541537 stacks : RefCell :: new ( RangeMap :: new ( size, stack) ) ,
542- history : RefCell :: new ( AllocHistory :: new ( local_crates ) ) ,
538+ history : RefCell :: new ( AllocHistory :: new ( ) ) ,
543539 }
544540 }
545541
@@ -579,8 +575,7 @@ impl Stacks {
579575 size : Size ,
580576 state : & GlobalState ,
581577 kind : MemoryKind < MiriMemoryKind > ,
582- threads : & ThreadManager < ' _ , ' _ > ,
583- local_crates : Rc < [ CrateNum ] > ,
578+ mut current_span : CurrentSpan < ' _ , ' _ , ' _ > ,
584579 ) -> Self {
585580 let mut extra = state. borrow_mut ( ) ;
586581 let ( base_tag, perm) = match kind {
@@ -614,12 +609,12 @@ impl Stacks {
614609 ( tag, Permission :: SharedReadWrite )
615610 }
616611 } ;
617- let stacks = Stacks :: new ( size, perm, base_tag, local_crates ) ;
612+ let stacks = Stacks :: new ( size, perm, base_tag) ;
618613 stacks. history . borrow_mut ( ) . log_creation (
619614 None ,
620615 base_tag,
621616 alloc_range ( Size :: ZERO , size) ,
622- threads ,
617+ & mut current_span ,
623618 ) ;
624619 stacks
625620 }
@@ -631,7 +626,7 @@ impl Stacks {
631626 tag : SbTag ,
632627 range : AllocRange ,
633628 state : & GlobalState ,
634- threads : & ThreadManager < ' _ , ' tcx > ,
629+ mut current_span : CurrentSpan < ' _ , ' _ , ' tcx > ,
635630 ) -> InterpResult < ' tcx > {
636631 trace ! (
637632 "read access with tag {:?}: {:?}, size {}" ,
@@ -646,7 +641,7 @@ impl Stacks {
646641 tag,
647642 ( alloc_id, range, offset) ,
648643 & mut state,
649- threads ,
644+ & mut current_span ,
650645 history,
651646 )
652647 } )
@@ -659,7 +654,7 @@ impl Stacks {
659654 tag : SbTag ,
660655 range : AllocRange ,
661656 state : & GlobalState ,
662- threads : & ThreadManager < ' _ , ' tcx > ,
657+ mut current_span : CurrentSpan < ' _ , ' _ , ' tcx > ,
663658 ) -> InterpResult < ' tcx > {
664659 trace ! (
665660 "write access with tag {:?}: {:?}, size {}" ,
@@ -674,7 +669,7 @@ impl Stacks {
674669 tag,
675670 ( alloc_id, range, offset) ,
676671 & mut state,
677- threads ,
672+ & mut current_span ,
678673 history,
679674 )
680675 } )
@@ -723,6 +718,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
723718 }
724719 let ( alloc_id, base_offset, orig_tag) = this. ptr_get_alloc_id ( place. ptr ) ?;
725720
721+ let mut current_span = this. machine . current_span ( ) ;
726722 {
727723 let extra = this. get_alloc_extra ( alloc_id) ?;
728724 let stacked_borrows =
@@ -732,10 +728,10 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
732728 Some ( orig_tag) ,
733729 new_tag,
734730 alloc_range ( base_offset, size) ,
735- & this . machine . threads ,
731+ & mut current_span ,
736732 ) ;
737733 if protect {
738- alloc_history. log_protector ( orig_tag, new_tag, & this . machine . threads ) ;
734+ alloc_history. log_protector ( orig_tag, new_tag, & mut current_span ) ;
739735 }
740736 }
741737
@@ -804,7 +800,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
804800 item,
805801 ( alloc_id, range, offset) ,
806802 & mut * global,
807- & this . machine . threads ,
803+ & mut current_span ,
808804 history,
809805 )
810806 } )
@@ -821,13 +817,14 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
821817 let item = Item { perm, tag : new_tag, protector } ;
822818 let range = alloc_range ( base_offset, size) ;
823819 let mut global = machine. stacked_borrows . as_ref ( ) . unwrap ( ) . borrow_mut ( ) ;
820+ let mut current_span = machine. current_span ( ) ;
824821 stacked_borrows. for_each_mut ( range, |offset, stack, history| {
825822 stack. grant (
826823 orig_tag,
827824 item,
828825 ( alloc_id, range, offset) ,
829826 & mut global,
830- & machine . threads ,
827+ & mut current_span ,
831828 history,
832829 )
833830 } ) ?;
0 commit comments