1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* import a github pull request

https://github.com/ruby/ruby/pull/1050
  by Kazuho Oku <kazuho@natadeco.co>.
  This pull request has the following commits.
* gc.c: reduce # of args to 6 (max. of register args on x86-64) so
  that the `newobj_of_slowpass` can be called via TCO.
* gc.c (newobj_of), string.c (str_duplicate): for performance,
  the hot functions must be inlined.
* gc.c: for performance, preceding arguments of `.*newobj_of.*`
  must be same, so that the arg registers can be reused in case of
  TCO.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2015-10-10 06:34:24 +00:00
parent 1331f80a1e
commit e8ba0b7b04
3 changed files with 25 additions and 8 deletions

View file

@ -1,3 +1,21 @@
Sat Oct 10 15:28:45 2015 Koichi Sasada <ko1@atdot.net>
* import a github pull request
https://github.com/ruby/ruby/pull/1050
by Kazuho Oku <kazuho@natadeco.co>.
This pull request has the following commits.
* gc.c: reduce # of args to 6 (max. of register args on x86-64) so
that the `newobj_of_slowpass` can be called via TCO.
* gc.c (newobj_of), string.c (str_duplicate): for performance,
the hot functions must be inlined.
* gc.c: for performance, preceding arguments of `.*newobj_of.*`
must be same, so that the arg registers can be reused in case of
TCO.
Sat Oct 10 08:52:21 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/socket/udpsocket.c (udp_connect, udp_bind, udp_send): fix

13
gc.c
View file

@ -1784,10 +1784,10 @@ newobj_of_init(rb_objspace_t *objspace, VALUE klass, VALUE flags, VALUE v1, VALU
return obj;
}
NOINLINE(static VALUE newobj_of_slowpass(rb_objspace_t *objspace, VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, int hook_needed));
NOINLINE(static VALUE newobj_of_slowpass(VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, rb_objspace_t *objspace));
static VALUE
newobj_of_slowpass(rb_objspace_t *objspace, VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, int hook_needed)
newobj_of_slowpass(VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, rb_objspace_t *objspace)
{
VALUE obj;
@ -1806,15 +1806,14 @@ newobj_of_slowpass(rb_objspace_t *objspace, VALUE klass, VALUE flags, VALUE v1,
}
obj = heap_get_freeobj(objspace, heap_eden);
return newobj_of_init(objspace, klass, flags, v1, v2, v3, obj, hook_needed);
return newobj_of_init(objspace, klass, flags, v1, v2, v3, obj, gc_event_hook_needed_p(objspace, RUBY_INTERNAL_EVENT_NEWOBJ));
}
static VALUE
static inline VALUE
newobj_of(VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3)
{
rb_objspace_t *objspace = &rb_objspace;
VALUE obj;
int hook_needed = gc_event_hook_needed_p(objspace, RUBY_INTERNAL_EVENT_NEWOBJ);
#if GC_DEBUG_STRESS_TO_CLASS
if (UNLIKELY(stress_to_class)) {
@ -1826,12 +1825,12 @@ newobj_of(VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3)
}
#endif
if (LIKELY(!(during_gc || ruby_gc_stressful) && hook_needed == FALSE &&
if (LIKELY(!(during_gc || ruby_gc_stressful) && gc_event_hook_needed_p(objspace, RUBY_INTERNAL_EVENT_NEWOBJ) == FALSE &&
(obj = heap_get_freeobj_head(objspace, heap_eden)) != Qfalse)) {
return newobj_of_init(objspace, klass, flags, v1, v2, v3, obj, FALSE);
}
else {
return newobj_of_slowpass(objspace, klass, flags, v1, v2, v3, hook_needed);
return newobj_of_slowpass(klass, flags, v1, v2, v3, objspace);
}
}

View file

@ -1233,7 +1233,7 @@ str_replace(VALUE str, VALUE str2)
return str;
}
static VALUE
static inline VALUE
str_duplicate(VALUE klass, VALUE str)
{
enum {embed_size = RSTRING_EMBED_LEN_MAX + 1};