Skip to content

Commit

Permalink
Fix get_available_pages() for SemiSpace (#721)
Browse files Browse the repository at this point in the history
Closes #615.
  • Loading branch information
k-sareen authored Dec 22, 2022
1 parent 9edb453 commit 4bb37f8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/plan/generational/copying/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl<VM: VMBinding> Plan for GenCopy<VM> {

/// Return the number of pages available for allocation. Assuming all future allocations goes to nursery.
fn get_available_pages(&self) -> usize {
// super.get_pages_avail() / 2 to reserve pages for copying
// super.get_available_pages() / 2 to reserve pages for copying
(self
.get_total_pages()
.saturating_sub(self.get_reserved_pages()))
Expand Down
4 changes: 2 additions & 2 deletions src/plan/generational/immix/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ impl<VM: VMBinding> Plan for GenImmix<VM> {
self.gen.get_used_pages() + self.immix.reserved_pages()
}

/// Return the number of pages avilable for allocation. Assuming all future allocations goes to nursery.
/// Return the number of pages available for allocation. Assuming all future allocations goes to nursery.
fn get_available_pages(&self) -> usize {
// super.get_pages_avail() / 2 to reserve pages for copying
// super.get_available_pages() / 2 to reserve pages for copying
(self
.get_total_pages()
.saturating_sub(self.get_reserved_pages()))
Expand Down
7 changes: 7 additions & 0 deletions src/plan/semispace/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ impl<VM: VMBinding> Plan for SemiSpace<VM> {
self.tospace().reserved_pages() + self.common.get_used_pages()
}

fn get_available_pages(&self) -> usize {
(self
.get_total_pages()
.saturating_sub(self.get_reserved_pages()))
>> 1
}

fn base(&self) -> &BasePlan<VM> {
&self.common.base
}
Expand Down

0 comments on commit 4bb37f8

Please sign in to comment.