ruby-changes:31798
From: tmm1 <ko1@a...>
Date: Wed, 27 Nov 2013 15:57:21 +0900 (JST)
Subject: [ruby-changes:31798] tmm1:r43877 (trunk): * gc.c (Init_GC): Add new GC::INTERNAL_CONSTANTS for information about
tmm1 2013-11-27 15:57:14 +0900 (Wed, 27 Nov 2013) New Revision: 43877 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43877 Log: * 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. Modified files: trunk/ChangeLog trunk/gc.c trunk/test/ruby/test_gc.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 43876) +++ ChangeLog (revision 43877) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Nov 27 15:55:52 2013 Aman Gupta <ruby@t...> + + * 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 <ruby@t...> * gc.c (gc_page_sweep): Fix compile warning from last commit. Index: gc.c =================================================================== --- gc.c (revision 43876) +++ gc.c (revision 43877) @@ -6984,6 +6984,7 @@ Init_GC(void) https://github.com/ruby/ruby/blob/trunk/gc.c#L6984 { 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) https://github.com/ruby/ruby/blob/trunk/gc.c#L6996 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); Index: test/ruby/test_gc.rb =================================================================== --- test/ruby/test_gc.rb (revision 43876) +++ test/ruby/test_gc.rb (revision 43877) @@ -212,4 +212,9 @@ class TestGc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_gc.rb#L212 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/