Skip to content

Commit 836a905

Browse files
committed
Add mmtk_worker_count to GC.config
1 parent 687f5f6 commit 836a905

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

gc/mmtk/mmtk.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,11 @@ rb_gc_impl_stress_get(void *objspace_ptr)
630630
VALUE
631631
rb_gc_impl_config_get(void *objspace_ptr)
632632
{
633-
// TODO
634-
return rb_hash_new();
633+
VALUE hash = rb_hash_new();
634+
635+
rb_hash_aset(hash, ID2SYM(rb_intern_const("mmtk_worker_count")), RB_ULONG2NUM(mmtk_worker_count()));
636+
637+
return hash;
635638
}
636639

637640
void

gc/mmtk/mmtk.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ MMTk_Address mmtk_starting_heap_address(void);
145145

146146
MMTk_Address mmtk_last_heap_address(void);
147147

148+
size_t mmtk_worker_count(void);
149+
148150
bool mmtk_is_mmtk_object(MMTk_Address addr);
149151

150-
#endif /* MMTK_H */
152+
#endif /* MMTK_H */

gc/mmtk/src/api.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,11 @@ pub extern "C" fn mmtk_last_heap_address() -> Address {
328328
memory_manager::last_heap_address()
329329
}
330330

331+
#[no_mangle]
332+
pub extern "C" fn mmtk_worker_count() -> usize {
333+
memory_manager::num_of_workers(mmtk())
334+
}
335+
331336
// =============== Miscellaneous ===============
332337

333338
#[no_mangle]

test/mmtk/test_configuration.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
require_relative "helper"
33
module MMTk
44
class TestConfiguration < TestCase
5+
def test_MMTK_THREADS
6+
assert_separately([{ "MMTK_THREADS" => "5" }], <<~RUBY)
7+
assert_equal(5, GC.config[:mmtk_worker_count])
8+
RUBY
9+
10+
assert_separately([{ "MMTK_THREADS" => "1" }], <<~RUBY)
11+
assert_equal(1, GC.config[:mmtk_worker_count])
12+
RUBY
13+
end
14+
515
%w(MMTK_THREADS MMTK_HEAP_MIN MMTK_HEAP_MAX MMTK_HEAP_MODE MMTK_PLAN).each do |var|
616
define_method(:"test_invalid_#{var}") do
717
exit_code = assert_in_out_err(

0 commit comments

Comments
 (0)