[ruby/mmtk] Add mmtk_worker_count to GC.config

https://github.com/ruby/mmtk/commit/836a9059cb
This commit is contained in:
Peter Zhu 2025-01-14 15:59:35 -05:00 committed by git
parent 56242ba495
commit f1e32914eb
4 changed files with 23 additions and 3 deletions

View File

@ -630,8 +630,11 @@ rb_gc_impl_stress_get(void *objspace_ptr)
VALUE
rb_gc_impl_config_get(void *objspace_ptr)
{
// TODO
return rb_hash_new();
VALUE hash = rb_hash_new();
rb_hash_aset(hash, ID2SYM(rb_intern_const("mmtk_worker_count")), RB_ULONG2NUM(mmtk_worker_count()));
return hash;
}
void

View File

@ -145,6 +145,8 @@ MMTk_Address mmtk_starting_heap_address(void);
MMTk_Address mmtk_last_heap_address(void);
size_t mmtk_worker_count(void);
bool mmtk_is_mmtk_object(MMTk_Address addr);
#endif /* MMTK_H */
#endif /* MMTK_H */

View File

@ -328,6 +328,11 @@ pub extern "C" fn mmtk_last_heap_address() -> Address {
memory_manager::last_heap_address()
}
#[no_mangle]
pub extern "C" fn mmtk_worker_count() -> usize {
memory_manager::num_of_workers(mmtk())
}
// =============== Miscellaneous ===============
#[no_mangle]

View File

@ -2,6 +2,16 @@
require_relative "helper"
module MMTk
class TestConfiguration < TestCase
def test_MMTK_THREADS
assert_separately([{ "MMTK_THREADS" => "5" }], <<~RUBY)
assert_equal(5, GC.config[:mmtk_worker_count])
RUBY
assert_separately([{ "MMTK_THREADS" => "1" }], <<~RUBY)
assert_equal(1, GC.config[:mmtk_worker_count])
RUBY
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(