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