Skip to content

Commit 8e09980

Browse files
committed
Merge branch 'lock-block-list-in-release' into use-ms-as-nonmoving
2 parents f4fa7f2 + 7275fc3 commit 8e09980

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ nogc_no_zeroing = ["nogc_lock_free"]
141141
single_worker = []
142142

143143
# To run expensive comprehensive runtime checks, such as checking duplicate edges
144-
extreme_assertions = []
144+
extreme_assertions = ["ms_block_list_sanity"]
145145

146146
# Enable multiple spaces for NoGC, each allocator maps to an individual ImmortalSpace.
147147
nogc_multi_space = []

src/policy/marksweepspace/native_ms/block_list.rs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,15 @@ impl BlockList {
3636
}
3737
}
3838

39-
// fn access_block_list<R: Copy, F: FnOnce() -> R>(&self, access_func: F) -> R {
40-
// #[cfg(feature = "ms_block_list_sanity")]
41-
// let mut sanity_list = self.sanity_list.lock().unwrap();
42-
43-
// let ret = access_func();
44-
45-
// // Verify the block list is the same as the sanity list
46-
// #[cfg(feature = "ms_block_list_sanity")]
47-
// {
48-
// if !sanity_list.iter().map(|b| *b).eq(BlockListIterator { cursor: self.first }) {
49-
// eprintln!("Sanity block list: {:?}", &mut sanity_list as &mut Vec<Block>);
50-
// eprintln!("Actual block list: {:?}", self);
51-
// panic!("Incorrect block list");
52-
// }
53-
// }
54-
55-
// ret
56-
// }
5739
#[cfg(feature = "ms_block_list_sanity")]
5840
fn verify_block_list(&self, sanity_list: &mut Vec<Block>) {
5941
if !sanity_list
6042
.iter()
61-
.map(|b| *b)
43+
.cloned()
6244
.eq(BlockListIterator { cursor: self.first })
6345
{
6446
eprintln!("Sanity block list: {:?}", sanity_list);
65-
eprintln!("First {:?}", sanity_list.get(0));
47+
eprintln!("First {:?}", sanity_list.first());
6648
eprintln!("Actual block list: {:?}", self);
6749
eprintln!("First {:?}", self.first);
6850
eprintln!("Block list {:?}", self as *const _);
@@ -71,6 +53,7 @@ impl BlockList {
7153
}
7254

7355
/// List has no blocks
56+
#[allow(clippy::let_and_return)]
7457
pub fn is_empty(&self) -> bool {
7558
let ret = self.first.is_none();
7659

@@ -296,6 +279,7 @@ impl BlockList {
296279
}
297280

298281
/// Get the size of this block list.
282+
#[allow(clippy::let_and_return)]
299283
pub fn size(&self) -> usize {
300284
let ret = self.size;
301285

src/policy/marksweepspace/native_ms/global.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,15 @@ impl AbandonedBlockLists {
6565
fn move_consumed_to_unswept(&mut self) {
6666
let mut i = 0;
6767
while i < MI_BIN_FULL {
68+
// This is executed during release. We also execute SweepChunk which will access blocks and block lists during release.
69+
// We have to acquire locks before we modify these block lists.
6870
self.consumed[i].lock();
6971
self.unswept[i].lock();
72+
7073
if !self.consumed[i].is_empty() {
7174
self.unswept[i].append(&mut self.consumed[i]);
7275
}
76+
7377
self.unswept[i].unlock();
7478
self.consumed[i].unlock();
7579
i += 1;
@@ -78,6 +82,12 @@ impl AbandonedBlockLists {
7882

7983
fn sweep<VM: VMBinding>(&mut self, space: &MarkSweepSpace<VM>) {
8084
for i in 0..MI_BIN_FULL {
85+
// This is executed during release. We also execute SweepChunk which will access blocks and block lists during release.
86+
// We have to acquire locks before we modify these block lists.
87+
self.available[i].lock();
88+
self.consumed[i].lock();
89+
self.unswept[i].lock();
90+
8191
self.available[i].sweep_blocks(space);
8292
self.consumed[i].sweep_blocks(space);
8393
self.unswept[i].sweep_blocks(space);
@@ -90,6 +100,10 @@ impl AbandonedBlockLists {
90100
self.consumed[i].push(block);
91101
}
92102
}
103+
104+
self.unswept[i].unlock();
105+
self.consumed[i].unlock();
106+
self.available[i].unlock();
93107
}
94108
}
95109
}

0 commit comments

Comments
 (0)