* 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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tmm1 2013-11-27 06:57:14 +00:00
Родитель 23178d1044
Коммит 0094b7bb68
3 изменённых файлов: 20 добавлений и 0 удалений

Просмотреть файл

@ -1,3 +1,9 @@
Wed Nov 27 15:55:52 2013 Aman Gupta <ruby@tmm1.net>
* 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@tmm1.net>
* gc.c (gc_page_sweep): Fix compile warning from last commit.

9
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);

Просмотреть файл

@ -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