Skip to content

Commit 30b69cf

Browse files
committed
remove BorrowTrackerMethod::Off
1 parent c310198 commit 30b69cf

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/borrow_tracker/mod.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ impl VisitTags for FrameExtra {
8080
/// Extra global state, available to the memory access hooks.
8181
#[derive(Debug)]
8282
pub struct GlobalStateInner {
83+
/// Borrow tracker method currently in use (except BorrowTrackerMethod::Off)
84+
pub borrow_tracker_method: BorrowTrackerMethod,
8385
/// Next unused pointer ID (tag).
8486
pub next_ptr_tag: BorTag,
8587
/// Table storing the "base" tag for each allocation.
@@ -163,11 +165,13 @@ pub enum ProtectorKind {
163165
/// Utilities for initialization and ID generation
164166
impl GlobalStateInner {
165167
pub fn new(
168+
borrow_tracker_method: BorrowTrackerMethod,
166169
tracked_pointer_tags: FxHashSet<BorTag>,
167170
tracked_call_ids: FxHashSet<CallId>,
168171
retag_fields: RetagFields,
169172
) -> Self {
170173
GlobalStateInner {
174+
borrow_tracker_method,
171175
next_ptr_tag: BorTag::one(),
172176
base_ptr_tags: FxHashMap::default(),
173177
next_call_id: NonZeroU64::new(1).unwrap(),
@@ -225,21 +229,20 @@ impl GlobalStateInner {
225229

226230
/// Which borrow tracking method to use
227231
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
228-
pub enum Method {
232+
pub enum BorrowTrackerMethod {
229233
/// Stacked Borrows, as implemented in borrow_tracker/stacked
230234
StackedBorrows,
231-
/// Do not track borrows
232-
Off,
233235
}
234236

235-
impl Method {
237+
impl BorrowTrackerMethod {
236238
pub fn is_active(self) -> bool {
237239
!matches!(self, Method::Off)
238240
}
239241

240242
pub fn instanciate_global_state(self, config: &MiriConfig) -> Option<GlobalState> {
241243
self.is_active().then(|| {
242244
RefCell::new(GlobalStateInner::new(
245+
self,
243246
config.tracked_pointer_tags.clone(),
244247
config.tracked_call_ids.clone(),
245248
config.retag_fields,
@@ -256,15 +259,15 @@ impl Method {
256259
machine: &MiriMachine<'_, '_>,
257260
) -> AllocExtra {
258261
match self {
259-
Method::StackedBorrows =>
262+
BorrowTrackerMethod::StackedBorrows =>
260263
AllocExtra::StackedBorrows(Box::new(RefCell::new(Stacks::new_allocation(
261264
id,
262265
alloc.size(),
263266
global.unwrap(),
264267
kind,
265268
machine,
266269
)))),
267-
Method::Off => AllocExtra::None,
270+
BorrowTrackerMethod::Off => AllocExtra::None,
268271
}
269272
}
270273

@@ -305,8 +308,6 @@ impl Method {
305308
pub enum AllocExtra {
306309
/// Data corresponding to Stacked Borrows
307310
StackedBorrows(Box<RefCell<stacked_borrows::AllocExtra>>),
308-
/// No data because borrow tracking is deactivated
309-
None,
310311
}
311312

312313
impl AllocExtra {

0 commit comments

Comments
 (0)