ruby-changes:4726
From: ko1@a...
Date: Sun, 27 Apr 2008 15:28:24 +0900 (JST)
Subject: [ruby-changes:4726] ko1 - Ruby:r16220 (trunk): * gc.c (gc_count): add a GC.count method. This method returns
ko1 2008-04-27 15:28:08 +0900 (Sun, 27 Apr 2008)
New Revision: 16220
Modified files:
trunk/ChangeLog
trunk/doc/NEWS
trunk/gc.c
Log:
* gc.c (gc_count): add a GC.count method. This method returns
a GC invoking count.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16220&r2=16219&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/gc.c?r1=16220&r2=16219&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/doc/NEWS?r1=16220&r2=16219&diff_format=u
Index: doc/NEWS
===================================================================
--- doc/NEWS (revision 16219)
+++ doc/NEWS (revision 16220)
@@ -195,7 +195,8 @@
o Process.exec
* Misc. new methods
o public_send
- o GC.stress, GC.stress=
+ o GC.stress, GC.stress=, GC.count
+ o ObjectSpace.count_objects
o Method#hash, Proc#hash
o __method__ and __callee__
o Symbol#to_proc
Index: ChangeLog
===================================================================
--- ChangeLog (revision 16219)
+++ ChangeLog (revision 16220)
@@ -1,3 +1,8 @@
+Sun Apr 27 15:23:40 2008 Koichi Sasada <ko1@a...>
+
+ * gc.c (gc_count): add a GC.count method. This method returns
+ a GC invoking count.
+
Sun Apr 27 12:20:33 2008 Nobuyoshi Nakada <nobu@r...>
* vm_core.h (rb_vm_t), gc.c (rb_objspace, rb_newobj), vm.c
Index: gc.c
===================================================================
--- gc.c (revision 16219)
+++ gc.c (revision 16220)
@@ -173,6 +173,7 @@
int overflow;
} markstack;
struct gc_list *global_list;
+ unsigned int count;
} rb_objspace_t;
#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
@@ -1673,6 +1674,7 @@
return Qtrue;
}
during_gc++;
+ objspace->count++;
SET_STACK_END;
@@ -2352,6 +2354,22 @@
}
/*
+ * call-seq:
+ * GC.count -> Integer
+ *
+ * Counts objects for each type.
+ *
+ * It returns a number of GC invoke counts.
+ *
+ */
+
+static VALUE
+gc_count(VALUE self)
+{
+ return UINT2NUM((&rb_objspace)->count);
+}
+
+/*
* The <code>GC</code> module provides an interface to Ruby's mark and
* sweep garbage collection mechanism. Some of the underlying methods
* are also available via the <code>ObjectSpace</code> module.
@@ -2368,6 +2386,7 @@
rb_define_singleton_method(rb_mGC, "disable", rb_gc_disable, 0);
rb_define_singleton_method(rb_mGC, "stress", gc_stress_get, 0);
rb_define_singleton_method(rb_mGC, "stress=", gc_stress_set, 1);
+ rb_define_singleton_method(rb_mGC, "count", gc_count, 0);
rb_define_method(rb_mGC, "garbage_collect", rb_gc_start, 0);
rb_mObSpace = rb_define_module("ObjectSpace");
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/