Skip to content

Commit 2b132cf

Browse files
authored
Fix un-cleared VO bits for contiguous monotone PR (#1071)
Fixed a bug that when using a generational plan, if mutators allocated less than one chunk of memory into the nursery between GCs, some VO bits will not be cleared. This PR also ensures the field `MonotonePageResourceSync::current_chunk` grows monotonically during GC when the space is contiguous. Fixes: #1070
1 parent 33c736e commit 2b132cf

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

src/policy/copyspace.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ use crate::policy::space::{CommonSpace, Space};
77
use crate::scheduler::GCWorker;
88
use crate::util::alloc::allocator::AllocatorContext;
99
use crate::util::copy::*;
10-
#[cfg(feature = "vo_bit")]
11-
use crate::util::heap::layout::vm_layout::BYTES_IN_CHUNK;
1210
use crate::util::heap::{MonotonePageResource, PageResource};
1311
use crate::util::metadata::{extract_side_metadata, MetadataSpec};
1412
use crate::util::object_forwarding;
@@ -189,19 +187,8 @@ impl<VM: VMBinding> CopySpace<VM> {
189187

190188
#[cfg(feature = "vo_bit")]
191189
unsafe fn reset_vo_bit(&self) {
192-
let current_chunk = self.pr.get_current_chunk();
193-
if self.common.contiguous {
194-
// If we have allocated something into this space, we need to clear its VO bit.
195-
if current_chunk != self.common.start {
196-
crate::util::metadata::vo_bit::bzero_vo_bit(
197-
self.common.start,
198-
current_chunk + BYTES_IN_CHUNK - self.common.start,
199-
);
200-
}
201-
} else {
202-
for (start, size) in self.pr.iterate_allocated_regions() {
203-
crate::util::metadata::vo_bit::bzero_vo_bit(start, size);
204-
}
190+
for (start, size) in self.pr.iterate_allocated_regions() {
191+
crate::util::metadata::vo_bit::bzero_vo_bit(start, size);
205192
}
206193
}
207194

src/util/heap/monotonepageresource.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ impl<VM: VMBinding> PageResource<VM> for MonotonePageResource<VM> {
140140

141141
/* In a contiguous space we can bump along into the next chunk, so preserve the currentChunk invariant */
142142
if self.common().contiguous && chunk_align_down(sync.cursor) != sync.current_chunk {
143+
debug_assert!(
144+
chunk_align_down(sync.cursor) > sync.current_chunk,
145+
"Not monotonic. chunk_align_down(sync.cursor): {}, sync.current_chunk: {}",
146+
chunk_align_down(sync.cursor),
147+
sync.current_chunk,
148+
);
143149
sync.current_chunk = chunk_align_down(sync.cursor);
144150
}
145151
self.commit_pages(reserved_pages, required_pages, tls);
@@ -310,6 +316,7 @@ impl<VM: VMBinding> MonotonePageResource<VM> {
310316
MonotonePageResourceConditional::Contiguous { start: _start, .. } => _start,
311317
_ => unreachable!(),
312318
};
319+
guard.current_chunk = guard.cursor;
313320
} else if !guard.cursor.is_zero() {
314321
let bytes = guard.cursor - guard.current_chunk;
315322
self.release_pages_extent(guard.current_chunk, bytes);

0 commit comments

Comments
 (0)