* 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/trunk@32671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
71ff558ed0
commit
da5b7f9229
@ -1,3 +1,9 @@
|
|||||||
|
Mon Jul 25 23:51:01 2011 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
|
* 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]
|
||||||
|
|
||||||
Mon Jul 25 23:39:33 2011 NAKAMURA Usaku <usa@ruby-lang.org>
|
Mon Jul 25 23:39:33 2011 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* test/rake/test_rake_directory_task.rb (TestRakeDirectoryTask#
|
* test/rake/test_rake_directory_task.rb (TestRakeDirectoryTask#
|
||||||
|
10
proc.c
10
proc.c
@ -19,6 +19,7 @@ struct METHOD {
|
|||||||
VALUE rclass;
|
VALUE rclass;
|
||||||
ID id;
|
ID id;
|
||||||
rb_method_entry_t *me;
|
rb_method_entry_t *me;
|
||||||
|
struct unlinked_method_entry_list_entry *ume;
|
||||||
};
|
};
|
||||||
|
|
||||||
VALUE rb_cUnboundMethod;
|
VALUE rb_cUnboundMethod;
|
||||||
@ -868,7 +869,10 @@ static void
|
|||||||
bm_free(void *ptr)
|
bm_free(void *ptr)
|
||||||
{
|
{
|
||||||
struct METHOD *data = 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);
|
xfree(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -977,6 +981,7 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
|
|||||||
data->me = ALLOC(rb_method_entry_t);
|
data->me = ALLOC(rb_method_entry_t);
|
||||||
*data->me = *me;
|
*data->me = *me;
|
||||||
data->me->def->alias_count++;
|
data->me->def->alias_count++;
|
||||||
|
data->ume = ALLOC(struct unlinked_method_entry_list_entry);
|
||||||
|
|
||||||
OBJ_INFECT(method, klass);
|
OBJ_INFECT(method, klass);
|
||||||
|
|
||||||
@ -1085,6 +1090,7 @@ method_unbind(VALUE obj)
|
|||||||
*data->me = *orig->me;
|
*data->me = *orig->me;
|
||||||
if (orig->me->def) orig->me->def->alias_count++;
|
if (orig->me->def) orig->me->def->alias_count++;
|
||||||
data->rclass = orig->rclass;
|
data->rclass = orig->rclass;
|
||||||
|
data->ume = ALLOC(struct unlinked_method_entry_list_entry);
|
||||||
OBJ_INFECT(method, obj);
|
OBJ_INFECT(method, obj);
|
||||||
|
|
||||||
return method;
|
return method;
|
||||||
@ -1423,6 +1429,7 @@ method_clone(VALUE self)
|
|||||||
data->me = ALLOC(rb_method_entry_t);
|
data->me = ALLOC(rb_method_entry_t);
|
||||||
*data->me = *orig->me;
|
*data->me = *orig->me;
|
||||||
if (data->me->def) data->me->def->alias_count++;
|
if (data->me->def) data->me->def->alias_count++;
|
||||||
|
data->ume = ALLOC(struct unlinked_method_entry_list_entry);
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
@ -1589,6 +1596,7 @@ umethod_bind(VALUE method, VALUE recv)
|
|||||||
if (bound->me->def) bound->me->def->alias_count++;
|
if (bound->me->def) bound->me->def->alias_count++;
|
||||||
bound->recv = recv;
|
bound->recv = recv;
|
||||||
bound->rclass = CLASS_OF(recv);
|
bound->rclass = CLASS_OF(recv);
|
||||||
|
data->ume = ALLOC(struct unlinked_method_entry_list_entry);
|
||||||
|
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user