Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/scheduler/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,17 @@ impl<VM: VMBinding> GCWorkerShared<VM> {
let bytes = VM::VMObjectModel::get_current_size(object);
// Get the space index from descriptor
let space_descriptor = VM_MAP.get_descriptor_for_address(object.to_raw_address());
let space_index = space_descriptor.get_index();
debug_assert!(
space_index < MAX_SPACES,
"Space index {} is not in the range of [0, {})",
space_index,
MAX_SPACES
);
// Accumulate the live bytes for the index
live_bytes_per_space[space_index] += bytes;
if space_descriptor != crate::util::heap::space_descriptor::SpaceDescriptor::UNINITIALIZED {
let space_index = space_descriptor.get_index();
debug_assert!(
space_index < MAX_SPACES,
"Space index {} is not in the range of [0, {})",
space_index,
MAX_SPACES
);
// Accumulate the live bytes for the index
live_bytes_per_space[space_index] += bytes;
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/util/heap/layout/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ pub trait VMMap: Sync {

fn is_finalized(&self) -> bool;

/// Get the space descriptor for the given address. Return SpaceDescriptor::UNINITIALIZED if the
/// address is not within the MMTk heap range, or not within MMTk spaces.
fn get_descriptor_for_address(&self, address: Address) -> SpaceDescriptor;

fn add_to_cumulative_committed_pages(&self, pages: usize);
Expand Down
5 changes: 4 additions & 1 deletion src/util/heap/layout/map32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ impl VMMap for Map32 {

fn get_descriptor_for_address(&self, address: Address) -> SpaceDescriptor {
let index = address.chunk_index();
self.descriptor_map[index]
self.descriptor_map
.get(index)
.copied()
.unwrap_or(SpaceDescriptor::UNINITIALIZED)
}

fn add_to_cumulative_committed_pages(&self, pages: usize) {
Expand Down
7 changes: 5 additions & 2 deletions src/util/heap/layout/map64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,11 @@ impl VMMap for Map64 {
}

fn get_descriptor_for_address(&self, address: Address) -> SpaceDescriptor {
let index = Self::space_index(address).unwrap();
self.inner().descriptor_map[index]
if let Some(index) = Self::space_index(address) {
self.inner().descriptor_map[index]
} else {
SpaceDescriptor::UNINITIALIZED
}
}

fn add_to_cumulative_committed_pages(&self, pages: usize) {
Expand Down