From 60653a7adbbd8143d187b3edf33cb7a2dddadf74 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 18 Jun 2019 13:01:11 -0700 Subject: [PATCH] Remove HB_VECTOR_SIZE It was cumbersome to get it to work reliably, for dubious performance gain, mostly in the subsetter maybe... Life is easier without. It was disabled forever anyway. --- src/hb-algs.hh | 36 +++++++++--------------------------- src/hb-null.hh | 4 ++-- src/hb-static.cc | 4 ++-- src/hb.hh | 32 -------------------------------- 4 files changed, 13 insertions(+), 63 deletions(-) diff --git a/src/hb-algs.hh b/src/hb-algs.hh index fe78d94c9..4a537baf3 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -994,13 +994,12 @@ HB_FUNCOBJ (hb_neg); /* Compiler-assisted vectorization. */ /* Type behaving similar to vectorized vars defined using __attribute__((vector_size(...))), - * using vectorized operations if HB_VECTOR_SIZE is set to **bit** numbers (eg 128). - * Define that to 0 to disable. */ + * basically a fixed-size bitset. */ template struct hb_vector_size_t { - elt_t& operator [] (unsigned int i) { return u.v[i]; } - const elt_t& operator [] (unsigned int i) const { return u.v[i]; } + elt_t& operator [] (unsigned int i) { return v[i]; } + const elt_t& operator [] (unsigned int i) const { return v[i]; } void clear (unsigned char v = 0) { memset (this, v, sizeof (*this)); } @@ -1008,28 +1007,16 @@ struct hb_vector_size_t hb_vector_size_t process (const Op& op) const { hb_vector_size_t r; -#if HB_VECTOR_SIZE - if (HB_VECTOR_SIZE && 0 == (byte_size * 8) % HB_VECTOR_SIZE) - for (unsigned int i = 0; i < ARRAY_LENGTH (u.vec); i++) - r.u.vec[i] = op (u.vec[i]); - else -#endif - for (unsigned int i = 0; i < ARRAY_LENGTH (u.v); i++) - r.u.v[i] = op (u.v[i]); + for (unsigned int i = 0; i < ARRAY_LENGTH (v); i++) + r.v[i] = op (v[i]); return r; } template hb_vector_size_t process (const Op& op, const hb_vector_size_t &o) const { hb_vector_size_t r; -#if HB_VECTOR_SIZE - if (HB_VECTOR_SIZE && 0 == (byte_size * 8) % HB_VECTOR_SIZE) - for (unsigned int i = 0; i < ARRAY_LENGTH (u.vec); i++) - r.u.vec[i] = op (u.vec[i], o.u.vec[i]); - else -#endif - for (unsigned int i = 0; i < ARRAY_LENGTH (u.v); i++) - r.u.v[i] = op (u.v[i], o.u.v[i]); + for (unsigned int i = 0; i < ARRAY_LENGTH (v); i++) + r.v[i] = op (v[i], o.v[i]); return r; } hb_vector_size_t operator | (const hb_vector_size_t &o) const @@ -1042,13 +1029,8 @@ struct hb_vector_size_t { return process (hb_bitwise_neg); } private: - static_assert (byte_size / sizeof (elt_t) * sizeof (elt_t) == byte_size, ""); - union { - elt_t v[byte_size / sizeof (elt_t)]; -#if HB_VECTOR_SIZE - hb_vector_size_impl_t vec[byte_size / sizeof (hb_vector_size_impl_t)]; -#endif - } u; + static_assert (0 == byte_size % sizeof (elt_t), ""); + elt_t v[byte_size / sizeof (elt_t)]; }; diff --git a/src/hb-null.hh b/src/hb-null.hh index 674b4dffc..d4578205e 100644 --- a/src/hb-null.hh +++ b/src/hb-null.hh @@ -74,7 +74,7 @@ using hb_static_size = _hb_static_size; */ extern HB_INTERNAL -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)]; +uint64_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (uint64_t) - 1) / sizeof (uint64_t)]; /* Generic nul-content Null objects. */ template @@ -128,7 +128,7 @@ struct NullHelper * causing bad memory access. So, races there are not actually introducing incorrectness * in the code. Has ~12kb binary size overhead to have it, also clang build fails with it. */ extern HB_INTERNAL -/*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)]; +/*thread_local*/ uint64_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (uint64_t) - 1) / sizeof (uint64_t)]; /* CRAP pool: Common Region for Access Protection. */ template diff --git a/src/hb-static.cc b/src/hb-static.cc index 6b89183ca..08a2f2136 100644 --- a/src/hb-static.cc +++ b/src/hb-static.cc @@ -39,8 +39,8 @@ #ifndef HB_NO_VISIBILITY #include "hb-ot-name-language-static.hh" -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*/ hb_vector_size_impl_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {}; +uint64_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (uint64_t) - 1) / sizeof (uint64_t)] = {}; +/*thread_local*/ uint64_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (uint64_t) - 1) / sizeof (uint64_t)] = {}; DEFINE_NULL_NAMESPACE_BYTES (OT, Index) = {0xFF,0xFF}; DEFINE_NULL_NAMESPACE_BYTES (OT, LangSys) = {0x00,0x00, 0xFF,0xFF, 0x00,0x00}; diff --git a/src/hb.hh b/src/hb.hh index a63d629bd..3145574d9 100644 --- a/src/hb.hh +++ b/src/hb.hh @@ -435,38 +435,6 @@ static_assert ((sizeof (hb_var_int_t) == 4), ""); void operator=(const TypeName&) = delete -/* - * 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 - */ -#ifndef HB_VECTOR_SIZE -# define HB_VECTOR_SIZE 0 -#endif - -/* The `vector_size' attribute was introduced in gcc 3.1. */ -#ifndef 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 - - /* Flags */ /* Enable bitwise ops on enums marked as flags_t */