@@ -25,7 +25,6 @@ use rustc_middle::{
2525} ;
2626use rustc_span:: def_id:: { CrateNum , DefId } ;
2727use rustc_span:: symbol:: { sym, Symbol } ;
28- use rustc_span:: DUMMY_SP ;
2928use rustc_target:: abi:: Size ;
3029use rustc_target:: spec:: abi:: Abi ;
3130
@@ -308,6 +307,7 @@ impl<'mir, 'tcx> Evaluator<'mir, 'tcx> {
308307 config. tracked_pointer_tags . clone ( ) ,
309308 config. tracked_call_ids . clone ( ) ,
310309 config. tag_raw ,
310+ local_crates. clone ( ) ,
311311 ) ) )
312312 } else {
313313 None
@@ -562,15 +562,20 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
562562 alloc : Cow < ' b , Allocation > ,
563563 kind : Option < MemoryKind < Self :: MemoryKind > > ,
564564 ) -> Cow < ' b , Allocation < Self :: PointerTag , Self :: AllocExtra > > {
565- set_current_span ( & ecx. machine ) ;
566565 if ecx. machine . tracked_alloc_ids . contains ( & id) {
567566 register_diagnostic ( NonHaltingDiagnostic :: CreatedAlloc ( id) ) ;
568567 }
569568
570569 let kind = kind. expect ( "we set our STATIC_KIND so this cannot be None" ) ;
571570 let alloc = alloc. into_owned ( ) ;
572571 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+ ) )
574579 } else {
575580 None
576581 } ;
@@ -591,7 +596,6 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
591596 ecx : & MiriEvalContext < ' mir , ' tcx > ,
592597 ptr : Pointer < AllocId > ,
593598 ) -> Pointer < Tag > {
594- set_current_span ( & ecx. machine ) ;
595599 let absolute_addr = intptrcast:: GlobalStateInner :: rel_ptr_to_addr ( ecx, ptr) ;
596600 let sb_tag = if let Some ( stacked_borrows) = & ecx. machine . stacked_borrows {
597601 stacked_borrows. borrow_mut ( ) . base_tag ( ptr. provenance )
@@ -627,7 +631,6 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
627631 ( alloc_id, tag) : ( AllocId , Self :: TagExtra ) ,
628632 range : AllocRange ,
629633 ) -> InterpResult < ' tcx > {
630- set_current_span ( & machine) ;
631634 if let Some ( data_race) = & alloc_extra. data_race {
632635 data_race. read ( alloc_id, range, machine. data_race . as_ref ( ) . unwrap ( ) ) ?;
633636 }
@@ -637,6 +640,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
637640 tag,
638641 range,
639642 machine. stacked_borrows . as_ref ( ) . unwrap ( ) ,
643+ & machine. threads ,
640644 )
641645 } else {
642646 Ok ( ( ) )
@@ -651,7 +655,6 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
651655 ( alloc_id, tag) : ( AllocId , Self :: TagExtra ) ,
652656 range : AllocRange ,
653657 ) -> InterpResult < ' tcx > {
654- set_current_span ( & machine) ;
655658 if let Some ( data_race) = & mut alloc_extra. data_race {
656659 data_race. write ( alloc_id, range, machine. data_race . as_mut ( ) . unwrap ( ) ) ?;
657660 }
@@ -661,6 +664,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
661664 tag,
662665 range,
663666 machine. stacked_borrows . as_ref ( ) . unwrap ( ) ,
667+ & machine. threads ,
664668 )
665669 } else {
666670 Ok ( ( ) )
@@ -675,7 +679,6 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
675679 ( alloc_id, tag) : ( AllocId , Self :: TagExtra ) ,
676680 range : AllocRange ,
677681 ) -> InterpResult < ' tcx > {
678- set_current_span ( & machine) ;
679682 if machine. tracked_alloc_ids . contains ( & alloc_id) {
680683 register_diagnostic ( NonHaltingDiagnostic :: FreedAlloc ( alloc_id) ) ;
681684 }
@@ -700,12 +703,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
700703 kind : mir:: RetagKind ,
701704 place : & PlaceTy < ' tcx , Tag > ,
702705 ) -> 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 ( ( ) ) }
709707 }
710708
711709 #[ inline( always) ]
@@ -751,12 +749,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
751749
752750 #[ inline( always) ]
753751 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 ( ( ) ) }
760753 }
761754
762755 #[ inline( always) ]
@@ -773,30 +766,3 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
773766 res
774767 }
775768}
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