@@ -25,7 +25,6 @@ use rustc_middle::{
25
25
} ;
26
26
use rustc_span:: def_id:: { CrateNum , DefId } ;
27
27
use rustc_span:: symbol:: { sym, Symbol } ;
28
- use rustc_span:: DUMMY_SP ;
29
28
use rustc_target:: abi:: Size ;
30
29
use rustc_target:: spec:: abi:: Abi ;
31
30
@@ -308,6 +307,7 @@ impl<'mir, 'tcx> Evaluator<'mir, 'tcx> {
308
307
config. tracked_pointer_tags . clone ( ) ,
309
308
config. tracked_call_ids . clone ( ) ,
310
309
config. tag_raw ,
310
+ local_crates. clone ( ) ,
311
311
) ) )
312
312
} else {
313
313
None
@@ -562,15 +562,20 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
562
562
alloc : Cow < ' b , Allocation > ,
563
563
kind : Option < MemoryKind < Self :: MemoryKind > > ,
564
564
) -> Cow < ' b , Allocation < Self :: PointerTag , Self :: AllocExtra > > {
565
- set_current_span ( & ecx. machine ) ;
566
565
if ecx. machine . tracked_alloc_ids . contains ( & id) {
567
566
register_diagnostic ( NonHaltingDiagnostic :: CreatedAlloc ( id) ) ;
568
567
}
569
568
570
569
let kind = kind. expect ( "we set our STATIC_KIND so this cannot be None" ) ;
571
570
let alloc = alloc. into_owned ( ) ;
572
571
let stacks = if let Some ( stacked_borrows) = & ecx. machine . stacked_borrows {
573
- Some ( Stacks :: new_allocation ( id, alloc. size ( ) , stacked_borrows, kind) )
572
+ Some ( Stacks :: new_allocation (
573
+ id,
574
+ alloc. size ( ) ,
575
+ stacked_borrows,
576
+ kind,
577
+ & ecx. machine . threads ,
578
+ ) )
574
579
} else {
575
580
None
576
581
} ;
@@ -591,7 +596,6 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
591
596
ecx : & MiriEvalContext < ' mir , ' tcx > ,
592
597
ptr : Pointer < AllocId > ,
593
598
) -> Pointer < Tag > {
594
- set_current_span ( & ecx. machine ) ;
595
599
let absolute_addr = intptrcast:: GlobalStateInner :: rel_ptr_to_addr ( ecx, ptr) ;
596
600
let sb_tag = if let Some ( stacked_borrows) = & ecx. machine . stacked_borrows {
597
601
stacked_borrows. borrow_mut ( ) . base_tag ( ptr. provenance )
@@ -627,7 +631,6 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
627
631
( alloc_id, tag) : ( AllocId , Self :: TagExtra ) ,
628
632
range : AllocRange ,
629
633
) -> InterpResult < ' tcx > {
630
- set_current_span ( & machine) ;
631
634
if let Some ( data_race) = & alloc_extra. data_race {
632
635
data_race. read ( alloc_id, range, machine. data_race . as_ref ( ) . unwrap ( ) ) ?;
633
636
}
@@ -637,6 +640,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
637
640
tag,
638
641
range,
639
642
machine. stacked_borrows . as_ref ( ) . unwrap ( ) ,
643
+ & machine. threads ,
640
644
)
641
645
} else {
642
646
Ok ( ( ) )
@@ -651,7 +655,6 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
651
655
( alloc_id, tag) : ( AllocId , Self :: TagExtra ) ,
652
656
range : AllocRange ,
653
657
) -> InterpResult < ' tcx > {
654
- set_current_span ( & machine) ;
655
658
if let Some ( data_race) = & mut alloc_extra. data_race {
656
659
data_race. write ( alloc_id, range, machine. data_race . as_mut ( ) . unwrap ( ) ) ?;
657
660
}
@@ -661,6 +664,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
661
664
tag,
662
665
range,
663
666
machine. stacked_borrows . as_ref ( ) . unwrap ( ) ,
667
+ & machine. threads ,
664
668
)
665
669
} else {
666
670
Ok ( ( ) )
@@ -675,7 +679,6 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
675
679
( alloc_id, tag) : ( AllocId , Self :: TagExtra ) ,
676
680
range : AllocRange ,
677
681
) -> InterpResult < ' tcx > {
678
- set_current_span ( & machine) ;
679
682
if machine. tracked_alloc_ids . contains ( & alloc_id) {
680
683
register_diagnostic ( NonHaltingDiagnostic :: FreedAlloc ( alloc_id) ) ;
681
684
}
@@ -700,12 +703,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
700
703
kind : mir:: RetagKind ,
701
704
place : & PlaceTy < ' tcx , Tag > ,
702
705
) -> InterpResult < ' tcx > {
703
- if ecx. machine . stacked_borrows . is_some ( ) {
704
- set_current_span ( & ecx. machine ) ;
705
- ecx. retag ( kind, place)
706
- } else {
707
- Ok ( ( ) )
708
- }
706
+ if ecx. machine . stacked_borrows . is_some ( ) { ecx. retag ( kind, place) } else { Ok ( ( ) ) }
709
707
}
710
708
711
709
#[ inline( always) ]
@@ -751,12 +749,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
751
749
752
750
#[ inline( always) ]
753
751
fn after_stack_push ( ecx : & mut InterpCx < ' mir , ' tcx , Self > ) -> InterpResult < ' tcx > {
754
- if ecx. machine . stacked_borrows . is_some ( ) {
755
- set_current_span ( & ecx. machine ) ;
756
- ecx. retag_return_place ( )
757
- } else {
758
- Ok ( ( ) )
759
- }
752
+ if ecx. machine . stacked_borrows . is_some ( ) { ecx. retag_return_place ( ) } else { Ok ( ( ) ) }
760
753
}
761
754
762
755
#[ inline( always) ]
@@ -773,30 +766,3 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
773
766
res
774
767
}
775
768
}
776
-
777
- // This is potentially a performance hazard.
778
- // Factoring it into its own function lets us keep an eye on how much it shows up in a profile.
779
- ///
780
- fn set_current_span < ' mir , ' tcx : ' mir > ( machine : & Evaluator < ' mir , ' tcx > ) {
781
- if let Some ( sb) = machine. stacked_borrows . as_ref ( ) {
782
- if sb. borrow ( ) . current_span != DUMMY_SP {
783
- return ;
784
- }
785
- let current_span = machine
786
- . threads
787
- . active_thread_stack ( )
788
- . into_iter ( )
789
- . rev ( )
790
- . find ( |frame| {
791
- let info = FrameInfo {
792
- instance : frame. instance ,
793
- span : frame. current_span ( ) ,
794
- lint_root : None ,
795
- } ;
796
- machine. is_local ( & info)
797
- } )
798
- . map ( |frame| frame. current_span ( ) )
799
- . unwrap_or ( rustc_span:: DUMMY_SP ) ;
800
- sb. borrow_mut ( ) . current_span = current_span;
801
- }
802
- }
0 commit comments