[ruby/mmtk] Add mmtk_plan to GC.config
https://github.com/ruby/mmtk/commit/67da9ea5b8
This commit is contained in:
parent
e5ad894959
commit
ab1565ebe3
@ -633,6 +633,7 @@ rb_gc_impl_config_get(void *objspace_ptr)
|
||||
VALUE hash = rb_hash_new();
|
||||
|
||||
rb_hash_aset(hash, ID2SYM(rb_intern_const("mmtk_worker_count")), RB_ULONG2NUM(mmtk_worker_count()));
|
||||
rb_hash_aset(hash, ID2SYM(rb_intern_const("mmtk_plan")), rb_str_new_cstr((const char *)mmtk_plan()));
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
@ -147,6 +147,8 @@ MMTk_Address mmtk_last_heap_address(void);
|
||||
|
||||
size_t mmtk_worker_count(void);
|
||||
|
||||
const uint8_t *mmtk_plan(void);
|
||||
|
||||
bool mmtk_is_mmtk_object(MMTk_Address addr);
|
||||
|
||||
#endif /* MMTK_H */
|
||||
|
@ -333,6 +333,20 @@ pub extern "C" fn mmtk_worker_count() -> usize {
|
||||
memory_manager::num_of_workers(mmtk())
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn mmtk_plan() -> *const u8 {
|
||||
static NO_GC: &[u8] = b"NoGC\0";
|
||||
static MARK_SWEEP: &[u8] = b"MarkSweep\0";
|
||||
static IMMIX: &[u8] = b"Immix\0";
|
||||
|
||||
match *crate::BINDING.get().unwrap().mmtk.get_options().plan {
|
||||
PlanSelector::NoGC => NO_GC.as_ptr(),
|
||||
PlanSelector::MarkSweep => MARK_SWEEP.as_ptr(),
|
||||
PlanSelector::Immix => IMMIX.as_ptr(),
|
||||
_ => panic!("Unknown plan")
|
||||
}
|
||||
}
|
||||
|
||||
// =============== Miscellaneous ===============
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -12,6 +12,15 @@ module MMTk
|
||||
RUBY
|
||||
end
|
||||
|
||||
# TODO: Add NoGC once this is fixed: https://github.com/mmtk/mmtk-core/pull/1263
|
||||
%w(MarkSweep Immix).each do |plan|
|
||||
define_method(:"test_MMTK_PLAN_#{plan}") do
|
||||
assert_separately([{ "MMTK_PLAN" => plan }], <<~RUBY)
|
||||
assert_equal("#{plan}", GC.config[:mmtk_plan])
|
||||
RUBY
|
||||
end
|
||||
end
|
||||
|
||||
%w(MMTK_THREADS MMTK_HEAP_MIN MMTK_HEAP_MAX MMTK_HEAP_MODE MMTK_PLAN).each do |var|
|
||||
define_method(:"test_invalid_#{var}") do
|
||||
exit_code = assert_in_out_err(
|
||||
|
Loading…
x
Reference in New Issue
Block a user