Skip to content

Commit

Permalink
Fix un-cleared VO bits for contiguous monotone PR (#1071)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wks authored Jan 16, 2024
1 parent 33c736e commit 2b132cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/policy/copyspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ use crate::policy::space::{CommonSpace, Space};
use crate::scheduler::GCWorker;
use crate::util::alloc::allocator::AllocatorContext;
use crate::util::copy::*;
#[cfg(feature = "vo_bit")]
use crate::util::heap::layout::vm_layout::BYTES_IN_CHUNK;
use crate::util::heap::{MonotonePageResource, PageResource};
use crate::util::metadata::{extract_side_metadata, MetadataSpec};
use crate::util::object_forwarding;
Expand Down Expand Up @@ -189,19 +187,8 @@ impl<VM: VMBinding> CopySpace<VM> {

#[cfg(feature = "vo_bit")]
unsafe fn reset_vo_bit(&self) {
let current_chunk = self.pr.get_current_chunk();
if self.common.contiguous {
// If we have allocated something into this space, we need to clear its VO bit.
if current_chunk != self.common.start {
crate::util::metadata::vo_bit::bzero_vo_bit(
self.common.start,
current_chunk + BYTES_IN_CHUNK - self.common.start,
);
}
} else {
for (start, size) in self.pr.iterate_allocated_regions() {
crate::util::metadata::vo_bit::bzero_vo_bit(start, size);
}
for (start, size) in self.pr.iterate_allocated_regions() {
crate::util::metadata::vo_bit::bzero_vo_bit(start, size);
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/util/heap/monotonepageresource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ impl<VM: VMBinding> PageResource<VM> for MonotonePageResource<VM> {

/* In a contiguous space we can bump along into the next chunk, so preserve the currentChunk invariant */
if self.common().contiguous && chunk_align_down(sync.cursor) != sync.current_chunk {
debug_assert!(
chunk_align_down(sync.cursor) > sync.current_chunk,
"Not monotonic. chunk_align_down(sync.cursor): {}, sync.current_chunk: {}",
chunk_align_down(sync.cursor),
sync.current_chunk,
);
sync.current_chunk = chunk_align_down(sync.cursor);
}
self.commit_pages(reserved_pages, required_pages, tls);
Expand Down Expand Up @@ -310,6 +316,7 @@ impl<VM: VMBinding> MonotonePageResource<VM> {
MonotonePageResourceConditional::Contiguous { start: _start, .. } => _start,
_ => unreachable!(),
};
guard.current_chunk = guard.cursor;
} else if !guard.cursor.is_zero() {
let bytes = guard.cursor - guard.current_chunk;
self.release_pages_extent(guard.current_chunk, bytes);
Expand Down

0 comments on commit 2b132cf

Please sign in to comment.