Skip to content

Commit

Permalink
* import a github pull request
Browse files Browse the repository at this point in the history
  ruby#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
  • Loading branch information
ko1 committed Oct 10, 2015
1 parent 1331f80 commit e8ba0b7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
18 changes: 18 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 6 additions & 7 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)) {
Expand All @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion string.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit e8ba0b7

Please sign in to comment.