[前][次][番号順一覧][スレッド一覧]

ruby-changes:34631

From: ko1 <ko1@a...>
Date: Sun, 6 Jul 2014 13:42:43 +0900 (JST)
Subject: [ruby-changes:34631] ko1:r46714 (trunk): * gc.c (rb_gc_register_mark_object): change data structure.

ko1	2014-07-06 13:42:35 +0900 (Sun, 06 Jul 2014)

  New Revision: 46714

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46714

  Log:
    * gc.c (rb_gc_register_mark_object): change data structure.
      From single array, to array of arrays. Each array only has 1024
      entries.
    * vm.c (Init_vm_objects): change default capa from 1 to 128.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
    trunk/vm.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46713)
+++ ChangeLog	(revision 46714)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Jul  6 13:37:27 2014  Koichi Sasada  <ko1@a...>
+
+	* gc.c (rb_gc_register_mark_object): change data structure.
+	  From single array, to array of arrays. Each array only has 1024
+	  entries.
+
+	* vm.c (Init_vm_objects): change default capa from 1 to 128.
+
 Sat Jul  5 05:05:53 2014  Vipul A M  <vipulnsward@g...>
 
 	* lib/irb/locale.rb (IRB::Locale#modifier): fix wrong attr_reader
Index: gc.c
===================================================================
--- gc.c	(revision 46713)
+++ gc.c	(revision 46714)
@@ -5119,10 +5119,21 @@ rb_gc_force_recycle(VALUE p) https://github.com/ruby/ruby/blob/trunk/gc.c#L5119
      */
 }
 
+#ifndef MARK_OBJECT_ARY_BUCKET_SIZE
+#define MARK_OBJECT_ARY_BUCKET_SIZE 1024
+#endif
+
 void
 rb_gc_register_mark_object(VALUE obj)
 {
-    VALUE ary = GET_THREAD()->vm->mark_object_ary;
+    VALUE ary_ary = GET_THREAD()->vm->mark_object_ary;
+    VALUE ary = rb_ary_last(0, 0, ary_ary);
+
+    if (ary == Qnil || RARRAY_LEN(ary) >= MARK_OBJECT_ARY_BUCKET_SIZE) {
+	ary = rb_ary_tmp_new(MARK_OBJECT_ARY_BUCKET_SIZE);
+	rb_ary_push(ary_ary, ary);
+    }
+
     rb_ary_push(ary, obj);
 }
 
Index: vm.c
===================================================================
--- vm.c	(revision 46713)
+++ vm.c	(revision 46714)
@@ -2793,7 +2793,7 @@ Init_vm_objects(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L2793
     vm->defined_module_hash = rb_hash_new();
 
     /* initialize mark object array, hash */
-    vm->mark_object_ary = rb_ary_tmp_new(1);
+    vm->mark_object_ary = rb_ary_tmp_new(128);
 }
 
 /* top self */

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]