Skip to content

Commit

Permalink
Implement MMTK_PLAN by hand
Browse files Browse the repository at this point in the history
rather than relying on read_env_var_settings, as this appears to
introduce regressions when parsing env vars with invalid encodings
  • Loading branch information
eightbitraptor committed Oct 17, 2024
1 parent 27ca580 commit 37fa32a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions gc/mmtk/src/api.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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::<PlanSelector>().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::<PlanSelector>()
.unwrap_or("MarkSweep".parse::<PlanSelector>().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));
Expand Down

0 comments on commit 37fa32a

Please sign in to comment.