@@ -130,17 +130,14 @@ impl fmt::Display for MiriMemoryKind {
130
130
/// Pointer provenance (tag).
131
131
#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash ) ]
132
132
pub enum Tag {
133
- Concrete ( ConcreteTag ) ,
133
+ Concrete {
134
+ alloc_id : AllocId ,
135
+ /// Stacked Borrows tag.
136
+ sb : SbTag ,
137
+ } ,
134
138
Wildcard ,
135
139
}
136
140
137
- #[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash ) ]
138
- pub struct ConcreteTag {
139
- pub alloc_id : AllocId ,
140
- /// Stacked Borrows tag.
141
- pub sb : SbTag ,
142
- }
143
-
144
141
#[ cfg( all( target_arch = "x86_64" , target_pointer_width = "64" ) ) ]
145
142
static_assert_size ! ( Pointer <Tag >, 24 ) ;
146
143
// #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
@@ -160,15 +157,15 @@ impl Provenance for Tag {
160
157
write ! ( f, "0x{:x}" , addr. bytes( ) ) ?;
161
158
162
159
match tag {
163
- Tag :: Concrete ( tag ) => {
160
+ Tag :: Concrete { alloc_id , sb } => {
164
161
// Forward `alternate` flag to `alloc_id` printing.
165
162
if f. alternate ( ) {
166
- write ! ( f, "[{:#?}]" , tag . alloc_id) ?;
163
+ write ! ( f, "[{:#?}]" , alloc_id) ?;
167
164
} else {
168
- write ! ( f, "[{:?}]" , tag . alloc_id) ?;
165
+ write ! ( f, "[{:?}]" , alloc_id) ?;
169
166
}
170
167
// Print Stacked Borrows tag.
171
- write ! ( f, "{:?}" , tag . sb) ?;
168
+ write ! ( f, "{:?}" , sb) ?;
172
169
}
173
170
Tag :: Wildcard => {
174
171
write ! ( f, "[Wildcard]" ) ?;
@@ -180,7 +177,7 @@ impl Provenance for Tag {
180
177
181
178
fn get_alloc_id ( self ) -> Option < AllocId > {
182
179
match self {
183
- Tag :: Concrete ( concrete ) => Some ( concrete . alloc_id ) ,
180
+ Tag :: Concrete { alloc_id , .. } => Some ( alloc_id) ,
184
181
Tag :: Wildcard => None ,
185
182
}
186
183
}
@@ -489,7 +486,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
489
486
type AllocExtra = AllocExtra ;
490
487
491
488
type PointerTag = Tag ;
492
- type TagExtra = SbTag ;
489
+ type TagExtra = SbTagExtra ;
493
490
494
491
type MemoryMap =
495
492
MonoHashMap < AllocId , ( MemoryKind < MiriMemoryKind > , Allocation < Tag , Self :: AllocExtra > ) > ;
@@ -649,7 +646,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
649
646
let alloc: Allocation < Tag , Self :: AllocExtra > = alloc. convert_tag_add_extra (
650
647
& ecx. tcx ,
651
648
AllocExtra {
652
- stacked_borrows : stacks,
649
+ stacked_borrows : stacks. map ( RefCell :: new ) ,
653
650
data_race : race_alloc,
654
651
weak_memory : buffer_alloc,
655
652
} ,
@@ -682,7 +679,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
682
679
SbTag :: Untagged
683
680
} ;
684
681
Pointer :: new (
685
- Tag :: Concrete ( ConcreteTag { alloc_id : ptr. provenance , sb : sb_tag } ) ,
682
+ Tag :: Concrete { alloc_id : ptr. provenance , sb : sb_tag } ,
686
683
Size :: from_bytes ( absolute_addr) ,
687
684
)
688
685
}
@@ -708,8 +705,9 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
708
705
ptr : Pointer < Self :: PointerTag > ,
709
706
) -> InterpResult < ' tcx > {
710
707
match ptr. provenance {
711
- Tag :: Concrete ( concrete) =>
712
- intptrcast:: GlobalStateInner :: expose_addr ( ecx, concrete. alloc_id ) ,
708
+ Tag :: Concrete { alloc_id, sb } => {
709
+ intptrcast:: GlobalStateInner :: expose_ptr ( ecx, alloc_id, sb) ;
710
+ }
713
711
Tag :: Wildcard => {
714
712
// No need to do anything for wildcard pointers as
715
713
// their provenances have already been previously exposed.
@@ -728,8 +726,8 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
728
726
729
727
rel. map ( |( alloc_id, size) | {
730
728
let sb = match ptr. provenance {
731
- Tag :: Concrete ( ConcreteTag { sb, .. } ) => sb ,
732
- Tag :: Wildcard => SbTag :: Untagged ,
729
+ Tag :: Concrete { sb, .. } => SbTagExtra :: Concrete ( sb ) ,
730
+ Tag :: Wildcard => SbTagExtra :: Wildcard ,
733
731
} ;
734
732
( alloc_id, size, sb)
735
733
} )
@@ -747,7 +745,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
747
745
data_race. read ( alloc_id, range, machine. data_race . as_ref ( ) . unwrap ( ) ) ?;
748
746
}
749
747
if let Some ( stacked_borrows) = & alloc_extra. stacked_borrows {
750
- stacked_borrows. memory_read (
748
+ stacked_borrows. borrow_mut ( ) . memory_read (
751
749
alloc_id,
752
750
tag,
753
751
range,
@@ -773,7 +771,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
773
771
data_race. write ( alloc_id, range, machine. data_race . as_mut ( ) . unwrap ( ) ) ?;
774
772
}
775
773
if let Some ( stacked_borrows) = & mut alloc_extra. stacked_borrows {
776
- stacked_borrows. memory_written (
774
+ stacked_borrows. get_mut ( ) . memory_written (
777
775
alloc_id,
778
776
tag,
779
777
range,
@@ -802,7 +800,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
802
800
data_race. deallocate ( alloc_id, range, machine. data_race . as_mut ( ) . unwrap ( ) ) ?;
803
801
}
804
802
if let Some ( stacked_borrows) = & mut alloc_extra. stacked_borrows {
805
- stacked_borrows. memory_deallocated (
803
+ stacked_borrows. get_mut ( ) . memory_deallocated (
806
804
alloc_id,
807
805
tag,
808
806
range,
0 commit comments