diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-28 16:25:23 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-28 16:25:23 +0000 |
commit | e5054226b4f9ddedb97d184698310fa8587a32b4 (patch) | |
tree | ccbfb273ae8d412940e182f04b51396939df88ed /proc.c | |
parent | 43e8a7a3ebb77b270de3c54c0c01d681070953ad (diff) |
* backport r32671 from trunk.
* proc.c: pre-allocate the unlinked_method_entry_list_entry struct to
avoid memory allocation during GC. based on a patch from Eric Wong.
[ruby-core:38498]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@32729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -19,6 +19,7 @@ struct METHOD { VALUE rclass; ID id; rb_method_entry_t *me; + struct unlinked_method_entry_list_entry *ume; }; VALUE rb_cUnboundMethod; @@ -867,7 +868,10 @@ static void bm_free(void *ptr) { struct METHOD *data = ptr; - rb_unlink_method_entry(data->me); + struct unlinked_method_entry_list_entry *ume = data->ume; + ume->me = data->me; + ume->next = GET_VM()->unlinked_method_entry_list; + GET_VM()->unlinked_method_entry_list = ume; xfree(ptr); } @@ -976,6 +980,7 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope) data->me = ALLOC(rb_method_entry_t); *data->me = *me; data->me->def->alias_count++; + data->ume = ALLOC(struct unlinked_method_entry_list_entry); OBJ_INFECT(method, klass); @@ -1084,6 +1089,7 @@ method_unbind(VALUE obj) *data->me = *orig->me; if (orig->me->def) orig->me->def->alias_count++; data->rclass = orig->rclass; + data->ume = ALLOC(struct unlinked_method_entry_list_entry); OBJ_INFECT(method, obj); return method; @@ -1383,6 +1389,7 @@ method_clone(VALUE self) data->me = ALLOC(rb_method_entry_t); *data->me = *orig->me; if (data->me->def) data->me->def->alias_count++; + data->ume = ALLOC(struct unlinked_method_entry_list_entry); return clone; } @@ -1549,6 +1556,7 @@ umethod_bind(VALUE method, VALUE recv) if (bound->me->def) bound->me->def->alias_count++; bound->recv = recv; bound->rclass = CLASS_OF(recv); + data->ume = ALLOC(struct unlinked_method_entry_list_entry); return method; } |