about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-08-13 13:51:08 +0200
committerRalf Jung <post@ralfj.de>2024-08-13 13:51:08 +0200
commit10cb5aa9349fe99e3c208346eccc09d5ce90b8ba (patch)
tree20573fe8d0a9478e2ad23d422160a517b9feb92f
parenta25ec22901e387d076eac487608a172d3b37390e (diff)
downloadrust-10cb5aa9349fe99e3c208346eccc09d5ce90b8ba.tar.gz
rust-10cb5aa9349fe99e3c208346eccc09d5ce90b8ba.zip
borrow_tracker: update comments regarding protectors
-rw-r--r--src/tools/miri/src/borrow_tracker/mod.rs1
-rw-r--r--src/tools/miri/src/borrow_tracker/stacked_borrows/item.rs9
2 files changed, 6 insertions, 4 deletions
diff --git a/src/tools/miri/src/borrow_tracker/mod.rs b/src/tools/miri/src/borrow_tracker/mod.rs
index ac4f6979a08..b632c0d3a62 100644
--- a/src/tools/miri/src/borrow_tracker/mod.rs
+++ b/src/tools/miri/src/borrow_tracker/mod.rs
@@ -96,7 +96,6 @@ pub struct GlobalStateInner {
     /// Next unused call ID (for protectors).
     next_call_id: CallId,
     /// All currently protected tags.
-    /// An item is protected if its tag is in this set, *and* it has the "protected" bit set.
     /// We add tags to this when they are created with a protector in `reborrow`, and
     /// we remove tags from this when the call which is protecting them returns, in
     /// `GlobalStateInner::end_call`. See `Stack::item_invalidated` for more details.
diff --git a/src/tools/miri/src/borrow_tracker/stacked_borrows/item.rs b/src/tools/miri/src/borrow_tracker/stacked_borrows/item.rs
index b9a52e4966c..13846710615 100644
--- a/src/tools/miri/src/borrow_tracker/stacked_borrows/item.rs
+++ b/src/tools/miri/src/borrow_tracker/stacked_borrows/item.rs
@@ -7,9 +7,12 @@ use crate::borrow_tracker::BorTag;
 pub struct Item(u64);
 
 // An Item contains 3 bitfields:
-// * Bits 0-61 store a BorTag
-// * Bits 61-63 store a Permission
-// * Bit 64 stores a flag which indicates if we have a protector
+// * Bits 0-61 store a BorTag.
+// * Bits 61-63 store a Permission.
+// * Bit 64 stores a flag which indicates if we might have a protector.
+//   This is purely an optimization: if the bit is set, the tag *might* be
+//   in `protected_tags`, but if the bit is not set then the tag is definitely
+//   not in `protected_tags`.
 const TAG_MASK: u64 = u64::MAX >> 3;
 const PERM_MASK: u64 = 0x3 << 61;
 const PROTECTED_MASK: u64 = 0x1 << 63;