diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-12 02:15:55 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-12 02:15:55 +0000 |
commit | 7c104f88eb97ba97c2061e6387284f180e4752cf (patch) | |
tree | fa1fd1d6c2b564e839f932621af44b5fd6500d35 | |
parent | 294a1d2270e875c11b7f92176ac954c130d69a8a (diff) | |
download | ruby-7c104f88eb97ba97c2061e6387284f180e4752cf.tar.gz |
* gc.c (assign_heap_slot): put the binary-search routine in order.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | gc.c | 29 |
1 files changed, 14 insertions, 15 deletions
@@ -548,32 +548,31 @@ assign_heap_slot(rb_objspace_t *objspace) if (p == 0) rb_memerror(); + membase = p; + if ((VALUE)p % sizeof(RVALUE) != 0) { + p = (RVALUE*)((VALUE)p + sizeof(RVALUE) - ((VALUE)p % sizeof(RVALUE))); + if ((membase + HEAP_SIZE) < (p + HEAP_SIZE)) { + objs--; + } + } + + lo = 0; hi = heaps_used; while (lo < hi) { + register RVALUE *mid_membase; mid = (lo + hi) / 2; - membase = heaps[mid].membase; - if (membase < p) { + mid_membase = heaps[mid].membase; + if (mid_membase < membase) { lo = mid + 1; } - else if (membase > p) { + else if (mid_membase > membase) { hi = mid; } else { - rb_bug("same heap slot is allocated: %p at %ld", p, mid); - } - } - - membase = p; - - if ((VALUE)p % sizeof(RVALUE) != 0) { - p = (RVALUE*)((VALUE)p + sizeof(RVALUE) - ((VALUE)p % sizeof(RVALUE))); - if ((membase + HEAP_SIZE) < (p + HEAP_SIZE)) { - objs--; + rb_bug("same heap slot is allocated: %p at %ld", membase, mid); } } - - if (hi < heaps_used) { MEMMOVE(&heaps[hi+1], &heaps[hi], struct heaps_slot, heaps_used - hi); } |