Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to get the plan name at runtime #583

Closed
chrisseaton opened this issue May 2, 2022 · 4 comments
Closed

Provide a way to get the plan name at runtime #583

chrisseaton opened this issue May 2, 2022 · 4 comments
Labels
A-interface Area: Interface/API

Comments

@chrisseaton
Copy link

Ruby has a way to print various configuration options (which JIT it's using etc.) We'd like to be able to print out which GC is being used, so the plan name. We think we'd like a method get_name on Plan for example, but we're not very experienced with the architecture of MMTk.

@qinsoon
Copy link
Member

qinsoon commented May 2, 2022

That should be possible with the current public API. Plan is an option:

// The plan to use. This needs to be initialized before creating an MMTk instance (currently by setting env vars)
plan: PlanSelector [env_var: true, command_line: false] [always_valid] = PlanSelector::NoGC,

You can store it as a string somewhere, and create a C function to get it.

lazy_static!{
    // Get the plan option from from the MMTk instance. Dereference it to get a PlanSelector.
    // Debug print it into a String, and then into a CString
    static ref MMTK_PLAN_STR: CString = CString::new(format!("{:?}", *SINGLETON.get_options().plan)).unwrap();
}

#[no_mangle]
pub extern "C" fn get_plan() -> *const c_char {
    MMTK_PLAN_STR.as_ptr()
}

@qinsoon qinsoon added the A-interface Area: Interface/API label May 2, 2022
@chrisseaton
Copy link
Author

@wks could you please add a extern char *mmtk_plan_name(void) function that I can use from Ruby?

@wks
Copy link
Collaborator

wks commented Jul 14, 2022

Sure. I'll work on that.

@wks
Copy link
Collaborator

wks commented Jul 14, 2022

@chrisseaton Instead of adding it to mmtk-core, I added a C API in the mmtk-ruby repository, because mmtk-core doesn't expose C API. All public Rust functions are callable from the binding, and the binding can make wrappers in whatever language relevant for that VM. The commit is: mmtk/mmtk-ruby@7c08f3d

I also added a method in the Ruby VM so that we can query the plan name in Ruby. Please have a look and see if my code has any problems. mmtk/ruby#6

@qinsoon qinsoon closed this as completed Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-interface Area: Interface/API
Projects
None yet
Development

No branches or pull requests

3 participants