Skip to content

Commit 81f20be

Browse files
committed
rename AllocationMap → RangeObjectMap
1 parent e6d3d98 commit 81f20be

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

src/concurrency/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
mod allocation_map;
1+
mod range_object_map;
22
pub mod data_race;
33
pub mod weak_memory;

src/concurrency/allocation_map.rs renamed to src/concurrency/range_object_map.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
//! Implements a map from allocation ranges to data.
2-
//! This is somewhat similar to RangeMap, but the ranges
3-
//! and data are discrete and non-splittable. An allocation in the
4-
//! map will always have the same range until explicitly removed
1+
//! Implements a map from allocation ranges to data. This is somewhat similar to RangeMap, but the
2+
//! ranges and data are discrete and non-splittable -- they represent distinct "objects". An
3+
//! allocation in the map will always have the same range until explicitly removed
54
65
use rustc_target::abi::Size;
76
use std::ops::{Index, IndexMut, Range};
@@ -20,7 +19,7 @@ struct Elem<T> {
2019
type Position = usize;
2120

2221
#[derive(Clone, Debug)]
23-
pub struct AllocationMap<T> {
22+
pub struct RangeObjectMap<T> {
2423
v: Vec<Elem<T>>,
2524
}
2625

@@ -34,7 +33,7 @@ pub enum AccessType {
3433
ImperfectlyOverlapping(Range<Position>),
3534
}
3635

37-
impl<T> AllocationMap<T> {
36+
impl<T> RangeObjectMap<T> {
3837
pub fn new() -> Self {
3938
Self { v: Vec::new() }
4039
}
@@ -135,15 +134,15 @@ impl<T> AllocationMap<T> {
135134
}
136135
}
137136

138-
impl<T> Index<Position> for AllocationMap<T> {
137+
impl<T> Index<Position> for RangeObjectMap<T> {
139138
type Output = T;
140139

141140
fn index(&self, pos: Position) -> &Self::Output {
142141
&self.v[pos].data
143142
}
144143
}
145144

146-
impl<T> IndexMut<Position> for AllocationMap<T> {
145+
impl<T> IndexMut<Position> for RangeObjectMap<T> {
147146
fn index_mut(&mut self, pos: Position) -> &mut Self::Output {
148147
&mut self.v[pos].data
149148
}
@@ -159,7 +158,7 @@ mod tests {
159158
fn empty_map() {
160159
// FIXME: make Size::from_bytes const
161160
let four = Size::from_bytes(4);
162-
let map = AllocationMap::<()>::new();
161+
let map = RangeObjectMap::<()>::new();
163162

164163
// Correctly tells where we should insert the first element (at position 0)
165164
assert_eq!(map.find_offset(Size::from_bytes(3)), Err(0));
@@ -173,7 +172,7 @@ mod tests {
173172
fn no_overlapping_inserts() {
174173
let four = Size::from_bytes(4);
175174

176-
let mut map = AllocationMap::<&str>::new();
175+
let mut map = RangeObjectMap::<&str>::new();
177176

178177
// |_|_|_|_|#|#|#|#|_|_|_|_|...
179178
// 0 1 2 3 4 5 6 7 8 9 a b c d
@@ -187,7 +186,7 @@ mod tests {
187186
fn boundaries() {
188187
let four = Size::from_bytes(4);
189188

190-
let mut map = AllocationMap::<&str>::new();
189+
let mut map = RangeObjectMap::<&str>::new();
191190

192191
// |#|#|#|#|_|_|...
193192
// 0 1 2 3 4 5
@@ -215,7 +214,7 @@ mod tests {
215214
fn perfectly_overlapping() {
216215
let four = Size::from_bytes(4);
217216

218-
let mut map = AllocationMap::<&str>::new();
217+
let mut map = RangeObjectMap::<&str>::new();
219218

220219
// |#|#|#|#|_|_|...
221220
// 0 1 2 3 4 5
@@ -241,7 +240,7 @@ mod tests {
241240
fn straddling() {
242241
let four = Size::from_bytes(4);
243242

244-
let mut map = AllocationMap::<&str>::new();
243+
let mut map = RangeObjectMap::<&str>::new();
245244

246245
// |_|_|_|_|#|#|#|#|_|_|_|_|...
247246
// 0 1 2 3 4 5 6 7 8 9 a b c d

src/concurrency/weak_memory.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ use rustc_data_structures::fx::FxHashMap;
8585
use crate::{AtomicReadOp, AtomicRwOp, AtomicWriteOp, Tag, VClock, VTimestamp, VectorIdx};
8686

8787
use super::{
88-
allocation_map::{AccessType, AllocationMap},
88+
range_object_map::{AccessType, RangeObjectMap},
8989
data_race::{GlobalState, ThreadClockSet},
9090
};
9191

@@ -101,7 +101,7 @@ const STORE_BUFFER_LIMIT: usize = 128;
101101
pub struct StoreBufferAlloc {
102102
/// Store buffer of each atomic object in this allocation
103103
// Behind a RefCell because we need to allocate/remove on read access
104-
store_buffers: RefCell<AllocationMap<StoreBuffer>>,
104+
store_buffers: RefCell<RangeObjectMap<StoreBuffer>>,
105105
}
106106

107107
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -134,7 +134,7 @@ struct StoreElement {
134134

135135
impl StoreBufferAlloc {
136136
pub fn new_allocation() -> Self {
137-
Self { store_buffers: RefCell::new(AllocationMap::new()) }
137+
Self { store_buffers: RefCell::new(RangeObjectMap::new()) }
138138
}
139139

140140
/// Checks if the range imperfectly overlaps with existing buffers

0 commit comments

Comments
 (0)