__builtin_alloca_with_align for optimal memory access
ALLOCA_N takes type arugment. It is natural that the returned value to be used as an array of type, thus type-aligned. Luckily GCC has a builtin to tell compiler such alignment info. This should generate beter instructions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
39cfa67b4f
commit
df9a70900a
@ -2493,6 +2493,7 @@ AC_CACHE_CHECK([for $1], AS_TR_SH(rb_cv_builtin_$1),
|
||||
AS_IF([test "${AS_TR_SH(rb_cv_builtin_$1)}" != no], [
|
||||
AC_DEFINE(AS_TR_CPP(HAVE_BUILTIN_$1))
|
||||
])])
|
||||
RUBY_CHECK_BUILTIN_FUNC(__builtin_alloca_with_align, [__builtin_alloca_with_align(1, 4096)])
|
||||
RUBY_CHECK_BUILTIN_FUNC(__builtin_assume_aligned, [__builtin_assume_aligned((void*)32, 32)])
|
||||
RUBY_CHECK_BUILTIN_FUNC(__builtin_bswap16, [__builtin_bswap16(0)])
|
||||
RUBY_CHECK_BUILTIN_FUNC(__builtin_bswap32, [__builtin_bswap32(0)])
|
||||
|
@ -1595,7 +1595,15 @@ rb_num2char_inline(VALUE x)
|
||||
#define ZALLOC(type) RB_ZALLOC(type)
|
||||
#define REALLOC_N(var,type,n) RB_REALLOC_N(var,type,n)
|
||||
|
||||
#ifdef HAVE_BUILTIN___BUILTIN_ALLOCA_WITH_ALIGN
|
||||
/* I don't know why but __builtin_alloca_with_align's second argument
|
||||
takes bits rather than bytes. */
|
||||
#define ALLOCA_N(type, n) \
|
||||
(type*)__builtin_alloca_with_align((sizeof(type)*(n)), \
|
||||
sizeof(type) * CHAR_BIT)
|
||||
#else
|
||||
#define ALLOCA_N(type,n) ((type*)alloca(sizeof(type)*(n)))
|
||||
#endif
|
||||
|
||||
void *rb_alloc_tmp_buffer(volatile VALUE *store, long len) RUBY_ATTR_ALLOC_SIZE((2));
|
||||
void *rb_alloc_tmp_buffer_with_count(volatile VALUE *store, size_t len,size_t count) RUBY_ATTR_ALLOC_SIZE((2,3));
|
||||
|
Loading…
x
Reference in New Issue
Block a user