Skip to content

Commit 67da9ea

Browse files
committed
Add mmtk_plan to GC.config
1 parent 22ceb28 commit 67da9ea

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

gc/mmtk/mmtk.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ rb_gc_impl_config_get(void *objspace_ptr)
633633
VALUE hash = rb_hash_new();
634634

635635
rb_hash_aset(hash, ID2SYM(rb_intern_const("mmtk_worker_count")), RB_ULONG2NUM(mmtk_worker_count()));
636+
rb_hash_aset(hash, ID2SYM(rb_intern_const("mmtk_plan")), rb_str_new_cstr((const char *)mmtk_plan()));
636637

637638
return hash;
638639
}

gc/mmtk/mmtk.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ MMTk_Address mmtk_last_heap_address(void);
147147

148148
size_t mmtk_worker_count(void);
149149

150+
const uint8_t *mmtk_plan(void);
151+
150152
bool mmtk_is_mmtk_object(MMTk_Address addr);
151153

152154
#endif /* MMTK_H */

gc/mmtk/src/api.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,20 @@ pub extern "C" fn mmtk_worker_count() -> usize {
333333
memory_manager::num_of_workers(mmtk())
334334
}
335335

336+
#[no_mangle]
337+
pub extern "C" fn mmtk_plan() -> *const u8 {
338+
static NO_GC: &[u8] = b"NoGC\0";
339+
static MARK_SWEEP: &[u8] = b"MarkSweep\0";
340+
static IMMIX: &[u8] = b"Immix\0";
341+
342+
match *crate::BINDING.get().unwrap().mmtk.get_options().plan {
343+
PlanSelector::NoGC => NO_GC.as_ptr(),
344+
PlanSelector::MarkSweep => MARK_SWEEP.as_ptr(),
345+
PlanSelector::Immix => IMMIX.as_ptr(),
346+
_ => panic!("Unknown plan")
347+
}
348+
}
349+
336350
// =============== Miscellaneous ===============
337351

338352
#[no_mangle]

test/mmtk/test_configuration.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ def test_MMTK_THREADS
1212
RUBY
1313
end
1414

15+
# TODO: Add NoGC once this is fixed: https://github.com/mmtk/mmtk-core/pull/1263
16+
%w(MarkSweep Immix).each do |plan|
17+
define_method(:"test_MMTK_PLAN_#{plan}") do
18+
assert_separately([{ "MMTK_PLAN" => plan }], <<~RUBY)
19+
assert_equal("#{plan}", GC.config[:mmtk_plan])
20+
RUBY
21+
end
22+
end
23+
1524
%w(MMTK_THREADS MMTK_HEAP_MIN MMTK_HEAP_MAX MMTK_HEAP_MODE MMTK_PLAN).each do |var|
1625
define_method(:"test_invalid_#{var}") do
1726
exit_code = assert_in_out_err(

0 commit comments

Comments
 (0)