summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog18
-rw-r--r--gc.c13
-rw-r--r--string.c2
3 files changed, 25 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index ed73f24..cb3ddda 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/gc.c b/gc.c
index 156e622..ae0e6ba 100644
--- a/gc.c
+++ b/gc.c
@@ -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);
}
}
diff --git a/string.c b/string.c
index 13f4ce4..fac0085 100644
--- a/string.c
+++ b/string.c
@@ -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};