Skip to content

Commit 4c37f17

Browse files
committed
also inform sync objcts about deallocation; needs separate AccessKind type
1 parent 6791f74 commit 4c37f17

23 files changed

+140
-47
lines changed

src/borrow_tracker/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ use crate::*;
1111
pub mod stacked_borrows;
1212
pub mod tree_borrows;
1313

14+
/// Indicates which kind of access is being performed.
15+
#[derive(Copy, Clone, Hash, PartialEq, Eq, Debug)]
16+
pub enum AccessKind {
17+
Read,
18+
Write,
19+
}
20+
21+
impl fmt::Display for AccessKind {
22+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
23+
match self {
24+
AccessKind::Read => write!(f, "read access"),
25+
AccessKind::Write => write!(f, "write access"),
26+
}
27+
}
28+
}
29+
1430
/// Tracking pointer provenance
1531
#[derive(Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
1632
pub struct BorTag(NonZero<u64>);

src/borrow_tracker/stacked_borrows/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_data_structures::fx::FxHashSet;
55
use rustc_span::{Span, SpanData};
66
use smallvec::SmallVec;
77

8-
use crate::borrow_tracker::{GlobalStateInner, ProtectorKind};
8+
use crate::borrow_tracker::{AccessKind, GlobalStateInner, ProtectorKind};
99
use crate::*;
1010

1111
/// Error reporting

src/borrow_tracker/stacked_borrows/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub use self::stack::Stack;
2121
use crate::borrow_tracker::stacked_borrows::diagnostics::{
2222
AllocHistory, DiagnosticCx, DiagnosticCxBuilder,
2323
};
24-
use crate::borrow_tracker::{GlobalStateInner, ProtectorKind};
24+
use crate::borrow_tracker::{AccessKind, GlobalStateInner, ProtectorKind};
2525
use crate::concurrency::data_race::{NaReadType, NaWriteType};
2626
use crate::*;
2727

src/borrow_tracker/tree_borrows/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use std::ops::Range;
44
use rustc_data_structures::fx::FxHashMap;
55
use rustc_span::{Span, SpanData};
66

7-
use crate::borrow_tracker::ProtectorKind;
87
use crate::borrow_tracker::tree_borrows::perms::{PermTransition, Permission};
98
use crate::borrow_tracker::tree_borrows::tree::LocationState;
109
use crate::borrow_tracker::tree_borrows::unimap::UniIndex;
10+
use crate::borrow_tracker::{AccessKind, ProtectorKind};
1111
use crate::*;
1212

1313
/// Cause of an access: either a real access or one

src/borrow_tracker/tree_borrows/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_middle::ty::{self, Ty};
55

66
use self::foreign_access_skipping::IdempotentForeignAccess;
77
use self::tree::LocationState;
8-
use crate::borrow_tracker::{GlobalState, GlobalStateInner, ProtectorKind};
8+
use crate::borrow_tracker::{AccessKind, GlobalState, GlobalStateInner, ProtectorKind};
99
use crate::concurrency::data_race::NaReadType;
1010
use crate::*;
1111

src/borrow_tracker/tree_borrows/perms.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::cmp::{Ordering, PartialOrd};
22
use std::fmt;
33

4-
use crate::AccessKind;
4+
use crate::borrow_tracker::AccessKind;
55
use crate::borrow_tracker::tree_borrows::diagnostics::TransitionError;
66
use crate::borrow_tracker::tree_borrows::tree::AccessRelatedness;
77

src/borrow_tracker/tree_borrows/tree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::borrow_tracker::tree_borrows::diagnostics::{
2525
use crate::borrow_tracker::tree_borrows::foreign_access_skipping::IdempotentForeignAccess;
2626
use crate::borrow_tracker::tree_borrows::perms::PermTransition;
2727
use crate::borrow_tracker::tree_borrows::unimap::{UniIndex, UniKeyMap, UniValMap};
28-
use crate::borrow_tracker::{GlobalState, ProtectorKind};
28+
use crate::borrow_tracker::{AccessKind, GlobalState, ProtectorKind};
2929
use crate::*;
3030

3131
mod tests;

src/concurrency/sync.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@ use rustc_data_structures::fx::FxHashMap;
1414
use super::vector_clock::VClock;
1515
use crate::*;
1616

17+
/// Indicates which kind of access is being performed.
18+
#[derive(Copy, Clone, Hash, PartialEq, Eq, Debug)]
19+
pub enum AccessKind {
20+
Read,
21+
Write,
22+
Dealloc,
23+
}
24+
25+
impl fmt::Display for AccessKind {
26+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27+
match self {
28+
AccessKind::Read => write!(f, "read"),
29+
AccessKind::Write => write!(f, "write"),
30+
AccessKind::Dealloc => write!(f, "deallocation"),
31+
}
32+
}
33+
}
34+
1735
/// A trait for the synchronization metadata that can be attached to a memory location.
1836
pub trait SyncObj: Any {
1937
/// Determines whether reads/writes to this object's location are currently permitted.

src/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub enum NonHaltingDiagnostic {
128128
PoppedPointerTag(Item, String),
129129
TrackingAlloc(AllocId, Size, Align),
130130
FreedAlloc(AllocId),
131-
AccessedAlloc(AllocId, AllocRange, AccessKind),
131+
AccessedAlloc(AllocId, AllocRange, borrow_tracker::AccessKind),
132132
RejectedIsolatedOp(String),
133133
ProgressReport {
134134
block_count: u64, // how many basic blocks have been run so far

src/helpers.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::num::NonZero;
22
use std::sync::Mutex;
33
use std::time::Duration;
4-
use std::{cmp, fmt, iter};
4+
use std::{cmp, iter};
55

66
use rand::RngCore;
77
use rustc_abi::{Align, ExternAbi, FieldIdx, FieldsShape, Size, Variants};
@@ -22,22 +22,6 @@ use rustc_symbol_mangling::mangle_internal_symbol;
2222

2323
use crate::*;
2424

25-
/// Indicates which kind of access is being performed.
26-
#[derive(Copy, Clone, Hash, PartialEq, Eq, Debug)]
27-
pub enum AccessKind {
28-
Read,
29-
Write,
30-
}
31-
32-
impl fmt::Display for AccessKind {
33-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
34-
match self {
35-
AccessKind::Read => write!(f, "read access"),
36-
AccessKind::Write => write!(f, "write access"),
37-
}
38-
}
39-
}
40-
4125
/// Gets an instance for a path.
4226
///
4327
/// A `None` namespace indicates we are looking for a module.

0 commit comments

Comments
 (0)