@@ -5,7 +5,6 @@ use log::trace;
5
5
use std:: cell:: RefCell ;
6
6
use std:: fmt;
7
7
use std:: num:: NonZeroU64 ;
8
- use std:: rc:: Rc ;
9
8
10
9
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
11
10
use rustc_hir:: Mutability ;
@@ -14,17 +13,15 @@ use rustc_middle::ty::{
14
13
self ,
15
14
layout:: { HasParamEnv , LayoutOf } ,
16
15
} ;
17
- use rustc_span:: def_id:: CrateNum ;
18
16
use rustc_span:: DUMMY_SP ;
19
17
use rustc_target:: abi:: Size ;
20
18
use std:: collections:: HashSet ;
21
19
20
+ use crate :: machine:: CurrentSpan ;
22
21
use crate :: * ;
23
22
24
23
pub mod diagnostics;
25
- use diagnostics:: AllocHistory ;
26
-
27
- use diagnostics:: TagHistory ;
24
+ use diagnostics:: { AllocHistory , TagHistory } ;
28
25
29
26
pub type PtrId = NonZeroU64 ;
30
27
pub type CallId = NonZeroU64 ;
@@ -376,7 +373,7 @@ impl<'tcx> Stack {
376
373
tag : SbTag ,
377
374
( alloc_id, alloc_range, offset) : ( AllocId , AllocRange , Size ) , // just for debug printing and error messages
378
375
global : & mut GlobalStateInner ,
379
- threads : & ThreadManager < ' _ , ' tcx > ,
376
+ current_span : & mut CurrentSpan < ' _ , ' _ , ' tcx > ,
380
377
alloc_history : & mut AllocHistory ,
381
378
) -> InterpResult < ' tcx > {
382
379
// Two main steps: Find granting item, remove incompatible items above.
@@ -400,7 +397,7 @@ impl<'tcx> Stack {
400
397
global,
401
398
alloc_history,
402
399
) ?;
403
- alloc_history. log_invalidation ( item. tag , alloc_range, threads ) ;
400
+ alloc_history. log_invalidation ( item. tag , alloc_range, current_span ) ;
404
401
}
405
402
} else {
406
403
// On a read, *disable* all `Unique` above the granting item. This ensures U2 for read accesses.
@@ -422,7 +419,7 @@ impl<'tcx> Stack {
422
419
alloc_history,
423
420
) ?;
424
421
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 ) ;
426
423
}
427
424
}
428
425
}
@@ -471,7 +468,7 @@ impl<'tcx> Stack {
471
468
new : Item ,
472
469
( alloc_id, alloc_range, offset) : ( AllocId , AllocRange , Size ) , // just for debug printing and error messages
473
470
global : & mut GlobalStateInner ,
474
- threads : & ThreadManager < ' _ , ' tcx > ,
471
+ current_span : & mut CurrentSpan < ' _ , ' _ , ' tcx > ,
475
472
alloc_history : & mut AllocHistory ,
476
473
) -> InterpResult < ' tcx > {
477
474
// Figure out which access `perm` corresponds to.
@@ -505,7 +502,7 @@ impl<'tcx> Stack {
505
502
derived_from,
506
503
( alloc_id, alloc_range, offset) ,
507
504
global,
508
- threads ,
505
+ current_span ,
509
506
alloc_history,
510
507
) ?;
511
508
@@ -533,13 +530,13 @@ impl<'tcx> Stack {
533
530
/// Map per-stack operations to higher-level per-location-range operations.
534
531
impl < ' tcx > Stacks {
535
532
/// 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 {
537
534
let item = Item { perm, tag, protector : None } ;
538
535
let stack = Stack { borrows : vec ! [ item] } ;
539
536
540
537
Stacks {
541
538
stacks : RefCell :: new ( RangeMap :: new ( size, stack) ) ,
542
- history : RefCell :: new ( AllocHistory :: new ( local_crates ) ) ,
539
+ history : RefCell :: new ( AllocHistory :: new ( ) ) ,
543
540
}
544
541
}
545
542
@@ -579,8 +576,7 @@ impl Stacks {
579
576
size : Size ,
580
577
state : & GlobalState ,
581
578
kind : MemoryKind < MiriMemoryKind > ,
582
- threads : & ThreadManager < ' _ , ' _ > ,
583
- local_crates : Rc < [ CrateNum ] > ,
579
+ mut current_span : CurrentSpan < ' _ , ' _ , ' _ > ,
584
580
) -> Self {
585
581
let mut extra = state. borrow_mut ( ) ;
586
582
let ( base_tag, perm) = match kind {
@@ -614,12 +610,12 @@ impl Stacks {
614
610
( tag, Permission :: SharedReadWrite )
615
611
}
616
612
} ;
617
- let stacks = Stacks :: new ( size, perm, base_tag, local_crates ) ;
613
+ let stacks = Stacks :: new ( size, perm, base_tag) ;
618
614
stacks. history . borrow_mut ( ) . log_creation (
619
615
None ,
620
616
base_tag,
621
617
alloc_range ( Size :: ZERO , size) ,
622
- threads ,
618
+ & mut current_span ,
623
619
) ;
624
620
stacks
625
621
}
@@ -631,7 +627,7 @@ impl Stacks {
631
627
tag : SbTag ,
632
628
range : AllocRange ,
633
629
state : & GlobalState ,
634
- threads : & ThreadManager < ' _ , ' tcx > ,
630
+ mut current_span : CurrentSpan < ' _ , ' _ , ' tcx > ,
635
631
) -> InterpResult < ' tcx > {
636
632
trace ! (
637
633
"read access with tag {:?}: {:?}, size {}" ,
@@ -646,7 +642,7 @@ impl Stacks {
646
642
tag,
647
643
( alloc_id, range, offset) ,
648
644
& mut state,
649
- threads ,
645
+ & mut current_span ,
650
646
history,
651
647
)
652
648
} )
@@ -659,7 +655,7 @@ impl Stacks {
659
655
tag : SbTag ,
660
656
range : AllocRange ,
661
657
state : & GlobalState ,
662
- threads : & ThreadManager < ' _ , ' tcx > ,
658
+ mut current_span : CurrentSpan < ' _ , ' _ , ' tcx > ,
663
659
) -> InterpResult < ' tcx > {
664
660
trace ! (
665
661
"write access with tag {:?}: {:?}, size {}" ,
@@ -674,7 +670,7 @@ impl Stacks {
674
670
tag,
675
671
( alloc_id, range, offset) ,
676
672
& mut state,
677
- threads ,
673
+ & mut current_span ,
678
674
history,
679
675
)
680
676
} )
@@ -723,6 +719,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
723
719
}
724
720
let ( alloc_id, base_offset, orig_tag) = this. ptr_get_alloc_id ( place. ptr ) ?;
725
721
722
+ let mut current_span = this. machine . current_span ( ) ;
726
723
{
727
724
let extra = this. get_alloc_extra ( alloc_id) ?;
728
725
let stacked_borrows =
@@ -732,10 +729,10 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
732
729
Some ( orig_tag) ,
733
730
new_tag,
734
731
alloc_range ( base_offset, size) ,
735
- & this . machine . threads ,
732
+ & mut current_span ,
736
733
) ;
737
734
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 ) ;
739
736
}
740
737
}
741
738
@@ -804,7 +801,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
804
801
item,
805
802
( alloc_id, range, offset) ,
806
803
& mut * global,
807
- & this . machine . threads ,
804
+ & mut current_span ,
808
805
history,
809
806
)
810
807
} )
@@ -821,13 +818,14 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
821
818
let item = Item { perm, tag : new_tag, protector } ;
822
819
let range = alloc_range ( base_offset, size) ;
823
820
let mut global = machine. stacked_borrows . as_ref ( ) . unwrap ( ) . borrow_mut ( ) ;
821
+ let mut current_span = machine. current_span ( ) ;
824
822
stacked_borrows. for_each_mut ( range, |offset, stack, history| {
825
823
stack. grant (
826
824
orig_tag,
827
825
item,
828
826
( alloc_id, range, offset) ,
829
827
& mut global,
830
- & machine . threads ,
828
+ & mut current_span ,
831
829
history,
832
830
)
833
831
} ) ?;
0 commit comments