diff --git a/ChangeLog b/ChangeLog index 67eb03be25..f22e9f086a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Nov 27 15:55:52 2013 Aman Gupta + + * gc.c (Init_GC): Add new GC::INTERNAL_CONSTANTS for information about + GC heap/page/slot sizing. + * test/ruby/test_gc.rb (class TestGc): test for above. + Wed Nov 27 15:21:17 2013 Aman Gupta * gc.c (gc_page_sweep): Fix compile warning from last commit. diff --git a/gc.c b/gc.c index 12ef935849..0adf549334 100644 --- a/gc.c +++ b/gc.c @@ -6984,6 +6984,7 @@ Init_GC(void) { VALUE rb_mObjSpace; VALUE rb_mProfiler; + VALUE gc_constants; rb_mGC = rb_define_module("GC"); rb_define_singleton_method(rb_mGC, "start", rb_gc_start, 0); @@ -6995,6 +6996,14 @@ Init_GC(void) rb_define_singleton_method(rb_mGC, "stat", gc_stat, -1); rb_define_method(rb_mGC, "garbage_collect", rb_gc_start, 0); + gc_constants = rb_hash_new(); + rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_SIZE")), SIZET2NUM(sizeof(RVALUE))); + rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_OBJ_LIMIT")), SIZET2NUM(HEAP_OBJ_LIMIT)); + rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_BITMAP_SIZE")), SIZET2NUM(HEAP_BITMAP_SIZE)); + rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_BITMAP_PLANES")), SIZET2NUM(HEAP_BITMAP_PLANES)); + OBJ_FREEZE(gc_constants); + rb_define_const(rb_mGC, "INTERNAL_CONSTANTS", gc_constants); + rb_mProfiler = rb_define_module_under(rb_mGC, "Profiler"); rb_define_singleton_method(rb_mProfiler, "enabled?", gc_profile_enable_get, 0); rb_define_singleton_method(rb_mProfiler, "enable", gc_profile_enable, 0); diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index da4a0b585d..ce7c5c3927 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -212,4 +212,9 @@ class TestGc < Test::Unit::TestCase assert base_length < GC.stat[:heap_eden_page_length] eom end + + def test_gc_internals + assert_not_nil GC::INTERNAL_CONSTANTS[:HEAP_OBJ_LIMIT] + assert_not_nil GC::INTERNAL_CONSTANTS[:RVALUE_SIZE] + end end