Skip to content

Commit

Permalink
Optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-blaeser committed Jan 27, 2023
1 parent 58e58ca commit 008f2b8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions rts/motoko-rts/src/gc/incremental/partitioned_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ impl Partition {
self.dynamic_size
}

pub fn marked_size(&self) -> usize {
self.marked_size
}

pub fn free_size(&self) -> usize {
self.end_address() - self.dynamic_space_end()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ impl<'a, M: Memory + 'a> EvacuationIncrement<'a, M> {
pub unsafe fn evacuate_partition(&mut self, partition: &Partition) {
debug_assert!(!partition.is_free());
debug_assert!(!partition.has_large_content());
if partition.marked_size() == 0 {
return;
}
let mut iterator = PartitionIterator::load_from(partition, &self.state, &mut self.time);
while iterator.current_object().is_some() && !self.time.is_over() {
let object = iterator.current_object().unwrap();
Expand All @@ -92,7 +95,12 @@ impl<'a, M: Memory + 'a> EvacuationIncrement<'a, M> {
(*original).forward = new_address;
debug_assert!(!copy.is_forwarded());
debug_assert!(original.is_forwarded());
debug_assert!(copy.is_marked()); // Necessary to ensure field updates in the copy.
// The mark bit is necessary to ensure field updates in the copy.
debug_assert!(copy.is_marked());
// However, updating the marked size statistics of target partition
// can be skipped, since that partition will not be considered for
// evacuation during the current GC run.

self.time.advance(size.as_usize());

#[cfg(debug_assertions)]
Expand Down

0 comments on commit 008f2b8

Please sign in to comment.