ruby-changes:42374
From: ko1 <ko1@a...>
Date: Thu, 31 Mar 2016 16:02:46 +0900 (JST)
Subject: [ruby-changes:42374] ko1:r54448 (trunk): * gc.c (gc_verify_heap_page): check the number of zombies.
ko1 2016-03-31 16:02:40 +0900 (Thu, 31 Mar 2016) New Revision: 54448 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54448 Log: * gc.c (gc_verify_heap_page): check the number of zombies. * gc.c (gc_verify_heap_pages): check also tomb heap. Modified files: trunk/ChangeLog trunk/gc.c Index: ChangeLog =================================================================== --- ChangeLog (revision 54447) +++ ChangeLog (revision 54448) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Mar 31 15:59:17 2016 Koichi Sasada <ko1@a...> + + * gc.c (gc_verify_heap_page): check the number of zombies. + + * gc.c (gc_verify_heap_pages): check also tomb heap. + Thu Mar 31 15:48:18 2016 Koichi Sasada <ko1@a...> * gc.c (gc_page_sweep): return free slots count. Index: gc.c =================================================================== --- gc.c (revision 54447) +++ gc.c (revision 54448) @@ -5068,9 +5068,13 @@ gc_verify_heap_page(rb_objspace_t *objsp https://github.com/ruby/ruby/blob/trunk/gc.c#L5068 unsigned int has_remembered_shady = FALSE; unsigned int has_remembered_old = FALSE; int rememberd_old_objects = 0; + int free_objects = 0; + int zombie_objects = 0; for (i=0; i<page->total_slots; i++) { VALUE obj = (VALUE)&page->start[i]; + if (RBASIC(obj) == 0) free_objects++; + if (BUILTIN_TYPE(obj) == T_ZOMBIE) zombie_objects++; if (RVALUE_PAGE_UNCOLLECTIBLE(page, obj) && RVALUE_PAGE_WB_UNPROTECTED(page, obj)) has_remembered_shady = TRUE; if (RVALUE_PAGE_MARKING(page, obj)) { has_remembered_old = TRUE; @@ -5080,7 +5084,7 @@ gc_verify_heap_page(rb_objspace_t *objsp https://github.com/ruby/ruby/blob/trunk/gc.c#L5084 if (!is_incremental_marking(objspace) && page->flags.has_remembered_objects == FALSE && has_remembered_old == TRUE) { - + for (i=0; i<page->total_slots; i++) { VALUE obj = (VALUE)&page->start[i]; if (RVALUE_PAGE_MARKING(page, obj)) { @@ -5096,6 +5100,16 @@ gc_verify_heap_page(rb_objspace_t *objsp https://github.com/ruby/ruby/blob/trunk/gc.c#L5100 page, obj ? obj_info(obj) : ""); } + if (0) { + /* free_slots may not equal to free_objects */ + if (page->free_slots != free_objects) { + rb_bug("page %p's free_slots should be %d, but %d\n", page, (int)page->free_slots, free_objects); + } + } + if (page->final_slots != zombie_objects) { + rb_bug("page %p's final_slots should be %d, but %d\n", page, (int)page->final_slots, zombie_objects); + } + return rememberd_old_objects; #else return 0; @@ -5103,20 +5117,29 @@ gc_verify_heap_page(rb_objspace_t *objsp https://github.com/ruby/ruby/blob/trunk/gc.c#L5117 } static int -gc_verify_heap_pages(rb_objspace_t *objspace) +gc_verify_heap_pages_(rb_objspace_t *objspace, struct heap_page *page) { int rememberd_old_objects = 0; - struct heap_page *page = heap_eden->pages; while (page) { - if (page->flags.has_remembered_objects == FALSE) - rememberd_old_objects += gc_verify_heap_page(objspace, page, Qfalse); + if (page->flags.has_remembered_objects == FALSE) { + rememberd_old_objects += gc_verify_heap_page(objspace, page, Qfalse); + } page = page->next; } return rememberd_old_objects; } +static int +gc_verify_heap_pages(rb_objspace_t *objspace) +{ + int rememberd_old_objects = 0; + rememberd_old_objects = gc_verify_heap_pages_(objspace, heap_eden->pages); + rememberd_old_objects = gc_verify_heap_pages_(objspace, heap_tomb->pages); + return rememberd_old_objects; +} + /* * call-seq: * GC.verify_internal_consistency -> nil -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/