@@ -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,15 @@ 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
20+ use crate :: machine:: CurrentSpan ;
2221use crate :: * ;
2322
2423pub mod diagnostics;
25- use diagnostics:: AllocHistory ;
26-
27- use diagnostics:: TagHistory ;
24+ use diagnostics:: { AllocHistory , TagHistory } ;
2825
2926pub type PtrId = NonZeroU64 ;
3027pub type CallId = NonZeroU64 ;
@@ -376,7 +373,7 @@ impl<'tcx> Stack {
376373 tag : SbTag ,
377374 ( alloc_id, alloc_range, offset) : ( AllocId , AllocRange , Size ) , // just for debug printing and error messages
378375 global : & mut GlobalStateInner ,
379- threads : & ThreadManager < ' _ , ' tcx > ,
376+ current_span : & mut CurrentSpan < ' _ , ' _ , ' tcx > ,
380377 alloc_history : & mut AllocHistory ,
381378 ) -> InterpResult < ' tcx > {
382379 // Two main steps: Find granting item, remove incompatible items above.
@@ -400,7 +397,7 @@ impl<'tcx> Stack {
400397 global,
401398 alloc_history,
402399 ) ?;
403- alloc_history. log_invalidation ( item. tag , alloc_range, threads ) ;
400+ alloc_history. log_invalidation ( item. tag , alloc_range, current_span ) ;
404401 }
405402 } else {
406403 // On a read, *disable* all `Unique` above the granting item. This ensures U2 for read accesses.
@@ -422,7 +419,7 @@ impl<'tcx> Stack {
422419 alloc_history,
423420 ) ?;
424421 item. perm = Permission :: Disabled ;
425- alloc_history. log_invalidation ( item. tag , alloc_range, threads ) ;
422+ alloc_history. log_invalidation ( item. tag , alloc_range, current_span ) ;
426423 }
427424 }
428425 }
@@ -471,7 +468,7 @@ impl<'tcx> Stack {
471468 new : Item ,
472469 ( alloc_id, alloc_range, offset) : ( AllocId , AllocRange , Size ) , // just for debug printing and error messages
473470 global : & mut GlobalStateInner ,
474- threads : & ThreadManager < ' _ , ' tcx > ,
471+ current_span : & mut CurrentSpan < ' _ , ' _ , ' tcx > ,
475472 alloc_history : & mut AllocHistory ,
476473 ) -> InterpResult < ' tcx > {
477474 // Figure out which access `perm` corresponds to.
@@ -505,7 +502,7 @@ impl<'tcx> Stack {
505502 derived_from,
506503 ( alloc_id, alloc_range, offset) ,
507504 global,
508- threads ,
505+ current_span ,
509506 alloc_history,
510507 ) ?;
511508
@@ -533,13 +530,13 @@ impl<'tcx> Stack {
533530/// Map per-stack operations to higher-level per-location-range operations.
534531impl < ' tcx > Stacks {
535532 /// Creates new stack with initial tag.
536- fn new ( size : Size , perm : Permission , tag : SbTag , local_crates : Rc < [ CrateNum ] > ) -> Self {
533+ fn new ( size : Size , perm : Permission , tag : SbTag ) -> Self {
537534 let item = Item { perm, tag, protector : None } ;
538535 let stack = Stack { borrows : vec ! [ item] } ;
539536
540537 Stacks {
541538 stacks : RefCell :: new ( RangeMap :: new ( size, stack) ) ,
542- history : RefCell :: new ( AllocHistory :: new ( local_crates ) ) ,
539+ history : RefCell :: new ( AllocHistory :: new ( ) ) ,
543540 }
544541 }
545542
@@ -579,8 +576,7 @@ impl Stacks {
579576 size : Size ,
580577 state : & GlobalState ,
581578 kind : MemoryKind < MiriMemoryKind > ,
582- threads : & ThreadManager < ' _ , ' _ > ,
583- local_crates : Rc < [ CrateNum ] > ,
579+ mut current_span : CurrentSpan < ' _ , ' _ , ' _ > ,
584580 ) -> Self {
585581 let mut extra = state. borrow_mut ( ) ;
586582 let ( base_tag, perm) = match kind {
@@ -614,12 +610,12 @@ impl Stacks {
614610 ( tag, Permission :: SharedReadWrite )
615611 }
616612 } ;
617- let stacks = Stacks :: new ( size, perm, base_tag, local_crates ) ;
613+ let stacks = Stacks :: new ( size, perm, base_tag) ;
618614 stacks. history . borrow_mut ( ) . log_creation (
619615 None ,
620616 base_tag,
621617 alloc_range ( Size :: ZERO , size) ,
622- threads ,
618+ & mut current_span ,
623619 ) ;
624620 stacks
625621 }
@@ -631,7 +627,7 @@ impl Stacks {
631627 tag : SbTag ,
632628 range : AllocRange ,
633629 state : & GlobalState ,
634- threads : & ThreadManager < ' _ , ' tcx > ,
630+ mut current_span : CurrentSpan < ' _ , ' _ , ' tcx > ,
635631 ) -> InterpResult < ' tcx > {
636632 trace ! (
637633 "read access with tag {:?}: {:?}, size {}" ,
@@ -646,7 +642,7 @@ impl Stacks {
646642 tag,
647643 ( alloc_id, range, offset) ,
648644 & mut state,
649- threads ,
645+ & mut current_span ,
650646 history,
651647 )
652648 } )
@@ -659,7 +655,7 @@ impl Stacks {
659655 tag : SbTag ,
660656 range : AllocRange ,
661657 state : & GlobalState ,
662- threads : & ThreadManager < ' _ , ' tcx > ,
658+ mut current_span : CurrentSpan < ' _ , ' _ , ' tcx > ,
663659 ) -> InterpResult < ' tcx > {
664660 trace ! (
665661 "write access with tag {:?}: {:?}, size {}" ,
@@ -674,7 +670,7 @@ impl Stacks {
674670 tag,
675671 ( alloc_id, range, offset) ,
676672 & mut state,
677- threads ,
673+ & mut current_span ,
678674 history,
679675 )
680676 } )
@@ -723,6 +719,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
723719 }
724720 let ( alloc_id, base_offset, orig_tag) = this. ptr_get_alloc_id ( place. ptr ) ?;
725721
722+ let mut current_span = this. machine . current_span ( ) ;
726723 {
727724 let extra = this. get_alloc_extra ( alloc_id) ?;
728725 let stacked_borrows =
@@ -732,10 +729,10 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
732729 Some ( orig_tag) ,
733730 new_tag,
734731 alloc_range ( base_offset, size) ,
735- & this . machine . threads ,
732+ & mut current_span ,
736733 ) ;
737734 if protect {
738- alloc_history. log_protector ( orig_tag, new_tag, & this . machine . threads ) ;
735+ alloc_history. log_protector ( orig_tag, new_tag, & mut current_span ) ;
739736 }
740737 }
741738
@@ -804,7 +801,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
804801 item,
805802 ( alloc_id, range, offset) ,
806803 & mut * global,
807- & this . machine . threads ,
804+ & mut current_span ,
808805 history,
809806 )
810807 } )
@@ -821,13 +818,14 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
821818 let item = Item { perm, tag : new_tag, protector } ;
822819 let range = alloc_range ( base_offset, size) ;
823820 let mut global = machine. stacked_borrows . as_ref ( ) . unwrap ( ) . borrow_mut ( ) ;
821+ let mut current_span = machine. current_span ( ) ;
824822 stacked_borrows. for_each_mut ( range, |offset, stack, history| {
825823 stack. grant (
826824 orig_tag,
827825 item,
828826 ( alloc_id, range, offset) ,
829827 & mut global,
830- & machine . threads ,
828+ & mut current_span ,
831829 history,
832830 )
833831 } ) ?;
0 commit comments