aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-27 14:28:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-27 14:28:14 +0000
commit21ddf31e81c8053781e36a05f45e202037369346 (patch)
tree1573ca5006fb98004363ee476c6c16c7205c1f28 /include
parentb47cc629bb3a9f6dd9708645943d35a21a313110 (diff)
downloadruby-21ddf31e81c8053781e36a05f45e202037369346.tar.gz
ruby/ruby.h: optimize rb_integer_type_p
* include/ruby/ruby.h (rb_integer_type_p): turn into macro to help clang based on old gcc to eliminate CSE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include')
-rw-r--r--include/ruby/ruby.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index d72e7784f1..eeae2f6879 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -1480,6 +1480,17 @@ rb_obj_write(VALUE a, VALUE *slot, VALUE b, RB_UNUSED_VAR(const char *filename),
#define RUBY_INTEGER_UNIFICATION 1
#define RB_INTEGER_TYPE_P(obj) rb_integer_type_p(obj)
+#if defined __GNUC__ && !GCC_VERSION_SINCE(4, 3, 0)
+/* clang 3.x (4.2 compatible) can't eliminate CSE of RB_BUILTIN_TYPE
+ * in inline function and caller function */
+#define rb_integer_type_p(obj) \
+ __extension__ ({ \
+ const VALUE integer_type_obj = (obj); \
+ (RB_FIXNUM_P(integer_type_obj) || \
+ (!RB_SPECIAL_CONST_P(integer_type_obj) && \
+ RB_BUILTIN_TYPE(integer_type_obj) == RUBY_T_BIGNUM)); \
+ })
+#else
static inline int
rb_integer_type_p(VALUE obj)
{
@@ -1487,6 +1498,7 @@ rb_integer_type_p(VALUE obj)
(!RB_SPECIAL_CONST_P(obj) &&
RB_BUILTIN_TYPE(obj) == RUBY_T_BIGNUM));
}
+#endif
#if SIZEOF_INT < SIZEOF_LONG
# define RB_INT2NUM(v) RB_INT2FIX((int)(v))