提交 44999f8b 编写于 作者: B Behdad Esfahbod

Align NullPool and CrapPool to HB_VECTOR_SIZE

上级 20a318d0
...@@ -854,8 +854,7 @@ struct hb_vector_size_t ...@@ -854,8 +854,7 @@ struct hb_vector_size_t
union { union {
elt_t v[byte_size / sizeof (elt_t)]; elt_t v[byte_size / sizeof (elt_t)];
#if HB_VECTOR_SIZE #if HB_VECTOR_SIZE
typedef unsigned long vec_t __attribute__((vector_size (HB_VECTOR_SIZE / 8))); hb_vector_size_impl_t vec[byte_size / sizeof (hb_vector_size_impl_t)];
vec_t vec[byte_size / sizeof (vec_t)];
#endif #endif
} u; } u;
}; };
......
...@@ -334,6 +334,39 @@ static_assert ((sizeof (hb_var_int_t) == 4), ""); ...@@ -334,6 +334,39 @@ static_assert ((sizeof (hb_var_int_t) == 4), "");
TypeName(const TypeName&); \ TypeName(const TypeName&); \
void operator=(const TypeName&) void operator=(const TypeName&)
/*
* Compiler-assisted vectorization parameters.
*/
/*
* Disable vectorization for now. To correctly use them, we should
* use posix_memalign() to allocate in hb_vector_t. Otherwise, can
* cause misaligned access.
*
* https://bugs.chromium.org/p/chromium/issues/detail?id=860184
*/
#if !defined(HB_VECTOR_SIZE)
# define HB_VECTOR_SIZE 0
#endif
/* The `vector_size' attribute was introduced in gcc 3.1. */
#if !defined(HB_VECTOR_SIZE)
# if defined( __GNUC__ ) && ( __GNUC__ >= 4 )
# define HB_VECTOR_SIZE 128
# else
# define HB_VECTOR_SIZE 0
# endif
#endif
static_assert (0 == (HB_VECTOR_SIZE & (HB_VECTOR_SIZE - 1)), "HB_VECTOR_SIZE is not power of 2.");
static_assert (0 == (HB_VECTOR_SIZE % 64), "HB_VECTOR_SIZE is not multiple of 64.");
#if HB_VECTOR_SIZE
typedef uint64_t hb_vector_size_impl_t __attribute__((vector_size (HB_VECTOR_SIZE / 8)));
#else
typedef uint64_t hb_vector_size_impl_t;
#endif
/* /*
* Static pools * Static pools
*/ */
...@@ -341,18 +374,18 @@ static_assert ((sizeof (hb_var_int_t) == 4), ""); ...@@ -341,18 +374,18 @@ static_assert ((sizeof (hb_var_int_t) == 4), "");
/* Global nul-content Null pool. Enlarge as necessary. */ /* Global nul-content Null pool. Enlarge as necessary. */
#define HB_NULL_POOL_SIZE 264 #define HB_NULL_POOL_SIZE 264
static_assert (HB_NULL_POOL_SIZE % sizeof (void *) == 0, "Align HB_NULL_POOL_SIZE.");
#ifdef HB_NO_VISIBILITY #ifdef HB_NO_VISIBILITY
static static
#else #else
extern HB_INTERNAL extern HB_INTERNAL
#endif #endif
void * const _hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)]
#ifdef HB_NO_VISIBILITY #ifdef HB_NO_VISIBILITY
= {} = {}
#endif #endif
; ;
/* Generic nul-content Null objects. */ /* Generic nul-content Null objects. */
template <typename Type> template <typename Type>
static inline Type const & Null (void) { static inline Type const & Null (void) {
...@@ -385,11 +418,12 @@ static ...@@ -385,11 +418,12 @@ static
#else #else
extern HB_INTERNAL extern HB_INTERNAL
#endif #endif
/*thread_local*/ void * _hb_CrapPool[HB_NULL_POOL_SIZE / sizeof (void *)] /*thread_local*/ hb_vector_size_impl_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)]
#ifdef HB_NO_VISIBILITY #ifdef HB_NO_VISIBILITY
= {} = {}
#endif #endif
; ;
/* CRAP pool: Common Region for Access Protection. */ /* CRAP pool: Common Region for Access Protection. */
template <typename Type> template <typename Type>
static inline Type& Crap (void) { static inline Type& Crap (void) {
...@@ -503,30 +537,6 @@ hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2, T lo3, T hi3) ...@@ -503,30 +537,6 @@ hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2, T lo3, T hi3)
#define FLAG_RANGE(x,y) (ASSERT_STATIC_EXPR_ZERO ((x) < (y)) + FLAG(y+1) - FLAG(x)) #define FLAG_RANGE(x,y) (ASSERT_STATIC_EXPR_ZERO ((x) < (y)) + FLAG(y+1) - FLAG(x))
/* Compiler-assisted vectorization. */
/*
* Disable vectorization for now. To correctly use them, we should
* use posix_memalign() to allocate them. Otherwise, can cause
* misaligned access.
*
* https://bugs.chromium.org/p/chromium/issues/detail?id=860184
*/
#if !defined(HB_VECTOR_SIZE)
# define HB_VECTOR_SIZE 0
#endif
/* The `vector_size' attribute was introduced in gcc 3.1. */
#if !defined(HB_VECTOR_SIZE)
# if defined( __GNUC__ ) && ( __GNUC__ >= 4 )
# define HB_VECTOR_SIZE 128
# else
# define HB_VECTOR_SIZE 0
# endif
#endif
/* Global runtime options. */ /* Global runtime options. */
struct hb_options_t struct hb_options_t
......
...@@ -27,6 +27,6 @@ ...@@ -27,6 +27,6 @@
#include "hb-private.hh" #include "hb-private.hh"
#ifndef HB_NO_VISIBILITY #ifndef HB_NO_VISIBILITY
void * const _hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {}; hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {};
/*thread_local*/ void * _hb_CrapPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {}; /*thread_local*/ hb_vector_size_impl_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {};
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册