diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-22 00:59:54 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-22 00:59:54 +0000 |
commit | 018cccb00b44a33fbad6d9f6aeb5d7ff8aa2a545 (patch) | |
tree | 76a9000795c11cf56e4f1b1ea4f895b430e60ad2 | |
parent | e210d969de592099124c5509e566525521e29490 (diff) | |
download | ruby-018cccb00b44a33fbad6d9f6aeb5d7ff8aa2a545.tar.gz |
gc.c: expand sorted pages
* gc.c (heap_page_allocate): expand sorted pages before inserting
allocated new page. [Bug #12670]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | KNOWNBUGS.rb | 10 | ||||
-rw-r--r-- | gc.c | 50 | ||||
-rw-r--r-- | test/-ext-/typeddata/test_typeddata.rb | 2 |
3 files changed, 31 insertions, 31 deletions
diff --git a/KNOWNBUGS.rb b/KNOWNBUGS.rb index 2eb472c9ad..35a8e75876 100644 --- a/KNOWNBUGS.rb +++ b/KNOWNBUGS.rb @@ -5,13 +5,3 @@ # This test file includes tests which point out known bugs. # So all tests will cause failure. # - -assert_normal_exit("#{<<-";END;"}", timeout: 5) -begin - require "-test-/typeddata" -rescue LoadError -else - n = 1 << 20 - Bug::TypedData.make(n) -end -;END; @@ -1371,6 +1371,29 @@ rb_objspace_free(rb_objspace_t *objspace) } static void +heap_pages_expand_sorted_to(rb_objspace_t *objspace, size_t next_length) +{ + struct heap_page **sorted; + size_t size = next_length * sizeof(struct heap_page *); + + gc_report(3, objspace, "heap_pages_expand_sorted: next_length: %d, size: %d\n", (int)next_length, (int)size); + + if (heap_pages_sorted_length > 0) { + sorted = (struct heap_page **)realloc(heap_pages_sorted, size); + if (sorted) heap_pages_sorted = sorted; + } + else { + sorted = heap_pages_sorted = (struct heap_page **)malloc(size); + } + + if (sorted == 0) { + rb_memerror(); + } + + heap_pages_sorted_length = next_length; +} + +static void heap_pages_expand_sorted(rb_objspace_t *objspace) { size_t next_length = heap_allocatable_pages; @@ -1378,24 +1401,7 @@ heap_pages_expand_sorted(rb_objspace_t *objspace) next_length += heap_tomb->total_pages; if (next_length > heap_pages_sorted_length) { - struct heap_page **sorted; - size_t size = next_length * sizeof(struct heap_page *); - - gc_report(3, objspace, "heap_pages_expand_sorted: next_length: %d, size: %d\n", (int)next_length, (int)size); - - if (heap_pages_sorted_length > 0) { - sorted = (struct heap_page **)realloc(heap_pages_sorted, size); - if (sorted) heap_pages_sorted = sorted; - } - else { - sorted = heap_pages_sorted = (struct heap_page **)malloc(size); - } - - if (sorted == 0) { - rb_memerror(); - } - - heap_pages_sorted_length = next_length; + heap_pages_expand_sorted_to(objspace, next_length); } } @@ -1533,6 +1539,9 @@ heap_page_allocate(rb_objspace_t *objspace) rb_bug("same heap page is allocated: %p at %"PRIuVALUE, (void *)page_body, (VALUE)mid); } } + if (heap_allocated_pages >= heap_pages_sorted_length) { + heap_pages_expand_sorted_to(objspace, heap_allocated_pages + 1); + } if (hi < heap_allocated_pages) { MEMMOVE(&heap_pages_sorted[hi+1], &heap_pages_sorted[hi], struct heap_page_header*, heap_allocated_pages - hi); } @@ -1542,7 +1551,10 @@ heap_page_allocate(rb_objspace_t *objspace) heap_allocated_pages++; objspace->profile.total_allocated_pages++; - if (RGENGC_CHECK_MODE) assert(heap_allocated_pages <= heap_pages_sorted_length); + if (heap_allocated_pages > heap_pages_sorted_length) { + rb_bug("heap_page_allocate: allocated(%"PRIdSIZE") > sorted(%"PRIdSIZE")", + heap_allocated_pages, heap_pages_sorted_length); + } if (heap_pages_lomem == 0 || heap_pages_lomem > start) heap_pages_lomem = start; if (heap_pages_himem < end) heap_pages_himem = end; diff --git a/test/-ext-/typeddata/test_typeddata.rb b/test/-ext-/typeddata/test_typeddata.rb index 167045a9ac..e32b030a35 100644 --- a/test/-ext-/typeddata/test_typeddata.rb +++ b/test/-ext-/typeddata/test_typeddata.rb @@ -19,8 +19,6 @@ class Test_TypedData < Test::Unit::TestCase end def test_deferred_free - skip 'not solved' - assert_ruby_status([], "#{<<-"begin;"}\n#{<<-"end;"}") require "-test-/typeddata" begin; |