ruby-changes:29072
From: tarui <ko1@a...>
Date: Fri, 7 Jun 2013 11:20:16 +0900 (JST)
Subject: [ruby-changes:29072] tarui:r41124 (trunk): * array.c (ary_new): change order of allocation in order
tarui 2013-06-07 11:20:05 +0900 (Fri, 07 Jun 2013) New Revision: 41124 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41124 Log: * array.c (ary_new): change order of allocation in order to remove FL_OLDGEN operation. Modified files: trunk/ChangeLog trunk/array.c Index: array.c =================================================================== --- array.c (revision 41123) +++ array.c (revision 41124) @@ -392,7 +392,7 @@ empty_ary_alloc(VALUE klass) https://github.com/ruby/ruby/blob/trunk/array.c#L392 static VALUE ary_new(VALUE klass, long capa) { - VALUE ary; + VALUE ary,*ptr; if (capa < 0) { rb_raise(rb_eArgError, "negative array size (or size too big)"); @@ -405,20 +405,16 @@ ary_new(VALUE klass, long capa) https://github.com/ruby/ruby/blob/trunk/array.c#L405 RUBY_DTRACE_ARRAY_CREATE(capa, rb_sourcefile(), rb_sourceline()); } - ary = ary_alloc(klass); if (capa > RARRAY_EMBED_LEN_MAX) { + ptr = ALLOC_N(VALUE, capa); + ary = ary_alloc(klass); FL_UNSET_EMBED(ary); - ARY_SET_PTR(ary, ALLOC_N(VALUE, capa)); + ARY_SET_PTR(ary, ptr); ARY_SET_CAPA(ary, capa); ARY_SET_HEAP_LEN(ary, 0); + } else { + ary = ary_alloc(klass); - /* NOTE: `ary' can be old because the following suquence is possible. - * (1) ary = ary_alloc(); - * (2) GC (for (3)) -> promote ary - * (3) ALLOC_N(VALUE, capa) - * So that force ary as young object. - */ - RBASIC(ary)->flags &= ~FL_OLDGEN; } return ary; Index: ChangeLog =================================================================== --- ChangeLog (revision 41123) +++ ChangeLog (revision 41124) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Jun 7 11:18:35 2013 Masaya Tarui <tarui@r...> + + * array.c (ary_new): change order of allocation in order + to remove FL_OLDGEN operation. + Fri Jun 7 11:16:28 2013 Masaya Tarui <tarui@r...> * tool/rdocbench.rb: add gc total time infomation. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/