aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-27 06:57:14 +0000
committertmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-27 06:57:14 +0000
commit0094b7bb6822fb230cc3475d49faff15674bb886 (patch)
treecb00502ccfef2fa450585e8373ef57d4012325b1
parent23178d10444f256af67c15deb4a5e16811135723 (diff)
downloadruby-0094b7bb6822fb230cc3475d49faff15674bb886.tar.gz
* 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
-rw-r--r--ChangeLog6
-rw-r--r--gc.c9
-rw-r--r--test/ruby/test_gc.rb5
3 files changed, 20 insertions, 0 deletions
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 <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.
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