From 37fa32a6b91438b4af3821a7d6b27c42b07c622f Mon Sep 17 00:00:00 2001 From: Matt Valentine-House Date: Thu, 17 Oct 2024 15:02:26 +0100 Subject: [PATCH] Implement MMTK_PLAN by hand rather than relying on read_env_var_settings, as this appears to introduce regressions when parsing env vars with invalid encodings --- gc/mmtk/src/api.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gc/mmtk/src/api.rs b/gc/mmtk/src/api.rs index e5f0fcfcb3b583..8f9125a1eeadd7 100644 --- a/gc/mmtk/src/api.rs +++ b/gc/mmtk/src/api.rs @@ -1,5 +1,6 @@ use std::sync::atomic::Ordering; use mmtk::util::options::PlanSelector; +use mmtk::Plan; use crate::abi::RawVecOfObjRef; use crate::abi::RubyBindingOptions; @@ -37,15 +38,18 @@ pub extern "C" fn mmtk_is_reachable(object: ObjectReference) -> bool { #[no_mangle] pub extern "C" fn mmtk_builder_default() -> *mut MMTKBuilder { - let mut builder = MMTKBuilder::new(); + let mut builder = MMTKBuilder::new_no_env_vars(); builder.options.no_finalizer.set(true); - // Set the default plan to MarkSweep - let plan_selector = "MarkSweep".parse::().unwrap(); - builder.options.plan.set(plan_selector); + // Parse the env var, if it's not found set the plan name to MarkSweep + let plan_name = std::env::var("MMTK_PLAN") + .unwrap_or(String::from("MarkSweep")); + + // Parse the plan name into a valid MMTK Plan, if the name is not a valid plan use MarkSweep + let plan_selector = plan_name.parse::() + .unwrap_or("MarkSweep".parse::().unwrap()); - // And allow the environment to override it - builder.options.read_env_var_settings(); + builder.options.plan.set(plan_selector); // Between 1MiB and 500MiB builder.options.gc_trigger.set(GCTriggerSelector::DynamicHeapSize(1 << 20, 500 << 20));