src/hb-dsalgs.hh        |   11 ++------
 src/hb-private.hh       |   66 +++++++++++++++++++++++++++---------------------
 src/hb-static.cc        |    4 +-
 test/api/test-ot-math.c |    4 +-
 4 files changed, 46 insertions(+), 39 deletions(-)

New commits:
commit f3a74c16ecafdca135a647ebe85117c35c1ef585
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Wed Jul 11 17:23:53 2018 +0200

    Make hb_vector_t 8 bytes smaller

diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh
index 953310bc..fc7d1f0a 100644
--- a/src/hb-dsalgs.hh
+++ b/src/hb-dsalgs.hh
@@ -450,8 +450,7 @@ template <typename Type, unsigned int StaticSize=8>
 struct hb_vector_t
 {
   unsigned int len;
-  unsigned int allocated;
-  bool successful;
+  unsigned int allocated; /* == 0 means allocation failed. */
   Type *arrayZ;
   Type static_array[StaticSize];
 
@@ -459,7 +458,6 @@ struct hb_vector_t
   {
     len = 0;
     allocated = ARRAY_LENGTH (static_array);
-    successful = true;
     arrayZ = static_array;
   }
 
@@ -492,7 +490,7 @@ struct hb_vector_t
   /* Allocate for size but don't adjust len. */
   inline bool alloc (unsigned int size)
   {
-    if (unlikely (!successful))
+    if (unlikely (!allocated))
       return false;
 
     if (likely (size <= allocated))
@@ -521,7 +519,7 @@ struct hb_vector_t
 
     if (unlikely (!new_array))
     {
-      successful = false;
+      allocated = 0;
       return false;
     }
 
commit 44999f8b758374015f5d48c83f9adcb464607c2f
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Wed Jul 11 17:00:59 2018 +0200

    Align NullPool and CrapPool to HB_VECTOR_SIZE

diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh
index 6a8ddaa9..953310bc 100644
--- a/src/hb-dsalgs.hh
+++ b/src/hb-dsalgs.hh
@@ -854,8 +854,7 @@ struct hb_vector_size_t
   union {
     elt_t v[byte_size / sizeof (elt_t)];
 #if HB_VECTOR_SIZE
-    typedef unsigned long vec_t __attribute__((vector_size (HB_VECTOR_SIZE / 
8)));
-    vec_t vec[byte_size / sizeof (vec_t)];
+    hb_vector_size_impl_t vec[byte_size / sizeof (hb_vector_size_impl_t)];
 #endif
   } u;
 };
diff --git a/src/hb-private.hh b/src/hb-private.hh
index ae733872..74b9e274 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -334,6 +334,39 @@ static_assert ((sizeof (hb_var_int_t) == 4), "");
   TypeName(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
  */
@@ -341,18 +374,18 @@ static_assert ((sizeof (hb_var_int_t) == 4), "");
 /* Global nul-content Null pool.  Enlarge as necessary. */
 
 #define HB_NULL_POOL_SIZE 264
-static_assert (HB_NULL_POOL_SIZE % sizeof (void *) == 0, "Align 
HB_NULL_POOL_SIZE.");
 
 #ifdef HB_NO_VISIBILITY
 static
 #else
 extern HB_INTERNAL
 #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
 = {}
 #endif
 ;
+
 /* Generic nul-content Null objects. */
 template <typename Type>
 static inline Type const & Null (void) {
@@ -385,11 +418,12 @@ static
 #else
 extern HB_INTERNAL
 #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
 = {}
 #endif
 ;
+
 /* CRAP pool: Common Region for Access Protection. */
 template <typename Type>
 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)
 #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. */
 
 struct hb_options_t
diff --git a/src/hb-static.cc b/src/hb-static.cc
index e26e5c80..ee17cd34 100644
--- a/src/hb-static.cc
+++ b/src/hb-static.cc
@@ -27,6 +27,6 @@
 #include "hb-private.hh"
 
 #ifndef HB_NO_VISIBILITY
-void * const _hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
-/*thread_local*/ void * _hb_CrapPool[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*/ 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
commit 20a318d06acaabdee0090339dfa621aab46f1441
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Wed Jul 11 17:00:13 2018 +0200

    Fix return type of alignof() fallback

diff --git a/src/hb-private.hh b/src/hb-private.hh
index ff339df4..ae733872 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -95,7 +95,7 @@ struct _hb_alignof
     char c;
     T t;
   };
-  static constexpr unsigned int value = offsetof (s, t);
+  static constexpr size_t value = offsetof (s, t);
 };
 
 #if __cplusplus < 201103L
commit 58cb4d9f73f1292454e3673d5e7ae5a58a566522
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Wed Jul 11 16:44:21 2018 +0200

    Minor

diff --git a/test/api/test-ot-math.c b/test/api/test-ot-math.c
index 0ca5566d..d071c889 100644
--- a/test/api/test-ot-math.c
+++ b/test/api/test-ot-math.c
@@ -396,8 +396,8 @@ test_get_min_connector_overlap (void)
   initFreeType();
 
   openFont("fonts/MathTestFontEmpty.otf");
-  g_assert_cmpint(hb_ot_math_get_min_connector_overlap(hb_font, FALSE), ==, 
0); // MathVariants not available
-  g_assert_cmpint(hb_ot_math_get_min_connector_overlap(hb_font, TRUE), ==, 0); 
// MathVariants not available
+  g_assert_cmpint(hb_ot_math_get_min_connector_overlap(hb_font, 
HB_DIRECTION_LTR), ==, 0); // MathVariants not available
+  g_assert_cmpint(hb_ot_math_get_min_connector_overlap(hb_font, 
HB_DIRECTION_TTB), ==, 0); // MathVariants not available
   closeFont();
 
   openFont("fonts/MathTestFontPartial1.otf");
_______________________________________________
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/harfbuzz

Reply via email to