diff options
author | tarui <tarui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-06-07 02:20:05 +0000 |
---|---|---|
committer | tarui <tarui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-06-07 02:20:05 +0000 |
commit | 7185eac56a353b3767c2444564f1446b404d9af4 (patch) | |
tree | 4401e31ea2ed48515612029b0929bc479fc59286 | |
parent | b1bbe884cd5e6554017b5c6b610acf653db23a04 (diff) | |
download | ruby-7185eac56a353b3767c2444564f1446b404d9af4.tar.gz |
* array.c (ary_new): change order of allocation in order
to remove FL_OLDGEN operation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | array.c | 16 |
2 files changed, 11 insertions, 10 deletions
@@ -1,3 +1,8 @@ +Fri Jun 7 11:18:35 2013 Masaya Tarui <tarui@ruby-lang.org> + + * 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@ruby-lang.org> * tool/rdocbench.rb: add gc total time infomation. @@ -392,7 +392,7 @@ empty_ary_alloc(VALUE klass) 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) 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; |