Skip to content

Commit c61e6c8

Browse files
authored
Force fixed heap size when using NoGC (#1264)
The dynamic heap size trigger needs GC to adjust the heap size, but NoGC can't do GC. So it doesn't make sense to use dynamic heap size with NoGC. Currently, if the user selects the NoGC plan and the dynamic heap size trigger, it will trigger GC at the minimum heap size and then panic immediately. With this change, MMTk will give a warning and use fixed heap size trigger instead, using the maximum heap size specified in the dynamic trigger as the heap size.
1 parent 2f6f078 commit c61e6c8

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/util/heap/gc_trigger.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,19 @@ impl<VM: VMBinding> GCTrigger<VM> {
4040
GCTriggerSelector::FixedHeapSize(size) => Box::new(FixedHeapSizeTrigger {
4141
total_pages: conversions::bytes_to_pages_up(size),
4242
}),
43-
GCTriggerSelector::DynamicHeapSize(min, max) => Box::new(MemBalancerTrigger::new(
44-
conversions::bytes_to_pages_up(min),
45-
conversions::bytes_to_pages_up(max),
46-
)),
43+
GCTriggerSelector::DynamicHeapSize(min, max) => 'dynamic_heap_size: {
44+
let min_pages = conversions::bytes_to_pages_up(min);
45+
let max_pages = conversions::bytes_to_pages_up(max);
46+
47+
if *options.plan == crate::util::options::PlanSelector::NoGC {
48+
warn!("Cannot use dynamic heap size with NoGC. Using fixed heap size trigger instead.");
49+
break 'dynamic_heap_size Box::new(FixedHeapSizeTrigger {
50+
total_pages: max_pages,
51+
});
52+
}
53+
54+
Box::new(MemBalancerTrigger::new(min_pages, max_pages))
55+
}
4756
GCTriggerSelector::Delegated => {
4857
<VM::VMCollection as crate::vm::Collection<VM>>::create_gc_trigger()
4958
}

0 commit comments

Comments
 (0)