mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 14:31:10 +01:00
[aat] Force-inline the state-machine transition functions (#6198)
The subtables' transition functions are called once per transition from the drive loop, but are big enough that the compiler declines to inline them, leaving a call plus prologue in the hottest loop of AAT shaping. Force them inline via HB_AAT_TRANSITION_INLINE, defined away under HB_OPTIMIZE_SIZE. Measured on the AAT corpus (clang -O3, instructions/cycles vs main): Lucida Grande -10.3%/-5.2%, Menlo -6.6%, GeezaPro -5.6%/-4.4%, Devanagari Sangam -5.6%/-2.2%. The ligature machine's transition alone carries most of the Menlo/Lucida win. Code size: +16KB text (+0.65%). Outputs byte-identical on the AAT corpus plus PingFang over a CJK sample. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
29c1b91df1
commit
b04cd416f3
3 files changed
+17
No files matched your search
@@ -49,6 +49,17 @@ struct ankr;
|
||||
|
||||
using hb_aat_class_cache_t = hb_ot_layout_mapping_cache_t;
|
||||
|
||||
/* The state-machine subtables' transition functions are called once per
|
||||
* transition from the drive loop, but are big enough that the compiler
|
||||
* declines to inline them, leaving a call in the hottest loop of AAT
|
||||
* shaping. Forcing them inline is worth 3-10% instructions on
|
||||
* morx/kerx-heavy fonts, for about 16KB of code. */
|
||||
#ifndef HB_OPTIMIZE_SIZE
|
||||
#define HB_AAT_TRANSITION_INLINE HB_ALWAYS_INLINE
|
||||
#else
|
||||
#define HB_AAT_TRANSITION_INLINE
|
||||
#endif
|
||||
|
||||
struct hb_aat_scratch_t
|
||||
{
|
||||
hb_aat_scratch_t () = default;
|
||||
|
||||
@@ -258,6 +258,7 @@ struct KerxSubTableFormat1
|
||||
depth (0),
|
||||
crossStream (table->header.coverage & table->header.CrossStream) {}
|
||||
|
||||
HB_AAT_TRANSITION_INLINE
|
||||
void transition (hb_buffer_t *buffer,
|
||||
StateTableDriver<Types, EntryData, Flags> *driver,
|
||||
const Entry<EntryData> &entry)
|
||||
@@ -551,6 +552,7 @@ struct KerxSubTableFormat4
|
||||
mark_set (false),
|
||||
mark (0) {}
|
||||
|
||||
HB_AAT_TRANSITION_INLINE
|
||||
void transition (hb_buffer_t *buffer,
|
||||
StateTableDriver<Types, EntryData, Flags> *driver,
|
||||
const Entry<EntryData> &entry)
|
||||
|
||||
@@ -84,6 +84,7 @@ struct RearrangementSubtable
|
||||
table (table_),
|
||||
start (0), end (0) {}
|
||||
|
||||
HB_AAT_TRANSITION_INLINE
|
||||
void transition (hb_buffer_t *buffer,
|
||||
StateTableDriver<Types, EntryData, Flags> *driver,
|
||||
const Entry<EntryData> &entry)
|
||||
@@ -243,6 +244,7 @@ struct ContextualSubtable
|
||||
mark (0),
|
||||
subs (table+table->substitutionTables) {}
|
||||
|
||||
HB_AAT_TRANSITION_INLINE
|
||||
void transition (hb_buffer_t *buffer,
|
||||
StateTableDriver<Types, EntryData, Flags> *driver,
|
||||
const Entry<EntryData> &entry)
|
||||
@@ -490,6 +492,7 @@ struct LigatureSubtable
|
||||
ligature (table+table->ligature),
|
||||
match_length (0) {}
|
||||
|
||||
HB_AAT_TRANSITION_INLINE
|
||||
void transition (hb_buffer_t *buffer,
|
||||
StateTableDriver<Types, EntryData, Flags> *driver,
|
||||
const Entry<EntryData> &entry)
|
||||
@@ -787,6 +790,7 @@ struct InsertionSubtable
|
||||
mark (0),
|
||||
insertionAction (table+table->insertionAction) {}
|
||||
|
||||
HB_AAT_TRANSITION_INLINE
|
||||
void transition (hb_buffer_t *buffer,
|
||||
StateTableDriver<Types, EntryData, Flags> *driver,
|
||||
const Entry<EntryData> &entry)
|
||||
|
||||
Reference in new issue
Block a user