Skip to content

Commit c320cf3

Browse files
authored
Skip iterating through unallocated memory for MonotonePageResource (#1189)
1 parent 160b770 commit c320cf3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/util/heap/monotonepageresource.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,13 @@ impl<VM: VMBinding> MonotonePageResource<VM> {
350350
} else {
351351
let start = self.discontiguous_start;
352352
self.discontiguous_start = self.pr.vm_map().get_next_contiguous_region(start);
353-
let size = self.pr.vm_map().get_contiguous_region_size(start);
353+
// If the current cursor is within the current discontiguous region (i.e. chunk),
354+
// then return the size till the cursor
355+
let size = if self.pr.cursor().chunk_index() == start.chunk_index() {
356+
self.pr.cursor() - start
357+
} else {
358+
self.pr.vm_map().get_contiguous_region_size(start)
359+
};
354360
Some((start, size))
355361
}
356362
}

0 commit comments

Comments
 (0)