Commit Graph

82 Commits

Author SHA1 Message Date
Behdad Esfahbod f18b9fbf65 [set] Implement iteration using bitop intrinsics 2018-02-16 18:14:41 -08:00
Behdad Esfahbod d25c3e69e9 [set] Readjust parameters 2018-02-16 17:45:09 -08:00
Behdad Esfahbod e1f1f96577 [set] Tune size again
Switch from a 128+64 hierarchy, to 32+32. New page size is 1024.
This should make set iteration faster, without affecting other op
performances much.
2018-02-14 15:44:48 -08:00
Behdad Esfahbod 694eaf6367 [set] Add backwards iterator
New API:
- hb_set_previous()
- hb_set_previous_range()
2018-02-14 01:00:10 -08:00
Behdad Esfahbod fe3bc524bd [set] Allow starting iteration from a non-member of the set 2018-02-13 23:51:45 -08:00
Behdad Esfahbod c479a59988 [subset] Assemble font 2018-02-07 21:26:04 -06:00
Behdad Esfahbod 34ac3548b7 [set] Respect stride
Ouch!
2018-02-07 18:07:45 -06:00
Behdad Esfahbod c9e12a2b9b Fix set initializer 2018-01-13 17:05:12 +00:00
Behdad Esfahbod 2fe5f885b6 [set] Handle nil set in add_range() / add_sorted_array()
Fixes https://github.com/harfbuzz/harfbuzz/issues/657
2017-12-19 14:48:26 -05:00
Behdad Esfahbod 493a005d95 [set] In add_sorted_array(), bail if data is not sorted 2017-12-16 11:49:39 -05:00
Behdad Esfahbod a7bd6d7a4c [collect_glyphs] Bail if input data looks like garbage
Specificaly, when a range or sorted array has unexpected order, we take that as
font data being garbage and bail out.  This fixes significant slowdown on a bad
version of Chandas font which has a 600KB GPOS with garbage inside.

Later on, I like to add a maximum-work counter for collect_glyphs to protect
against malicious fonts as well.

Fixes https://bugs.chromium.org/p/chromium/issues/detail?id=794896
2017-12-16 11:39:32 -05:00
Behdad Esfahbod 1ce7d6e215 [set] Optimize add_array() / add_sorted_array()
Does page lookup as needed.
2017-12-16 11:39:11 -05:00
Behdad Esfahbod 81f27df4d9 More work towards improving collect_glyphs() against bad input
The three "XXXXX"'s should be switched to false.  Doing that separately for ease
of bisecting...
2017-12-16 06:12:06 -08:00
Behdad Esfahbod 5d02572034 [set] Add add_sorted_array()
Not optimized to use sortedness yet.  Also start putting in place infra
to faster reject bad data.

A version of Chandas.ttf found on some Chrome bots has 660kb of GPOS,
mostly junk.  That is causing 48 million of set->add() calls in
collect_glyphs(), which is insane.

In the upcoming commits, I'll be speeding that up by optimizing
add_sorted_array(), while also reducing work by rejecting out-of-sort
arrays quickly and propagate the rejection.

Part of https://bugs.chromium.org/p/chromium/issues/detail?id=794896
2017-12-14 19:35:47 -08:00
Behdad Esfahbod 9d6511a734 [set] Reduce number of preallocated pages from 8 to 1
Now that pagesize is 8192, this feels better.
2017-12-14 19:07:17 -08:00
Behdad Esfahbod 9daa88cd79 Minor 2017-12-14 19:07:17 -08:00
Behdad Esfahbod f424a34223 [set] Change pagesize from 512 bits to 8192 bits
Fixes perf regression on some heavy fonts in Chrome's FT+HB
interaction.

See:
https://bugs.chromium.org/p/chromium/issues/detail?id=782220

More work to be done:
https://bugs.chromium.org/p/chromium/issues/detail?id=794896
2017-12-14 13:30:38 -08:00
Behdad Esfahbod 0fe62c1f33 [set] Add add_array()
To be used to optimize adding a whole bunch of (sorted) items at the same time,
as in CoverageFormat1.
2017-12-14 10:39:00 -08:00
Behdad Esfahbod eeb26d21d4 [set] Actually commit fixes mentioned in previous commit! 2017-12-02 15:22:04 -08:00
Behdad Esfahbod 0744149cda [set] Protect against bad input in hb_set_add_range() 2017-12-02 15:06:15 -08:00
Behdad Esfahbod 9d0194b3a8 [set] Optimize add_range() some more
It's as good as it gets, and seems to be on par with previous set implementation
in my benchmark.

Would be great if someone can double-check my bitops.
2017-12-01 13:56:06 -08:00
Behdad Esfahbod 438c325a25 [set] Optimize add_range()
With new set implementation, this became really costy.  Optimize it.
There's more to be done, but this shaves off most of the fat.

Part of fixing https://bugs.chromium.org/p/chromium/issues/detail?id=782220
2017-12-01 13:34:14 -08:00
Jonathan Kew dfd234a97d [set] Fix page_map[] indexing in backward loop.
Fixes https://github.com/behdad/harfbuzz/issues/579.
2017-10-26 12:33:05 -05:00
Jonathan Kew d511cfb557 [set] Bugfix for hb_set_next 2017-10-26 12:30:52 -05:00
Behdad Esfahbod 30a591e3ce [set] Rewrite another way :P 2017-10-23 14:29:20 -04:00
Behdad Esfahbod 8170801d78 [set] Fix crash
Ouch!  That's what happens when one plays with increment/decrement operators!

Fixes https://github.com/behdad/harfbuzz/issues/578
2017-10-23 14:29:14 -04:00
Behdad Esfahbod dd33e4e96b [set] Don't use major()
Fixes https://github.com/behdad/harfbuzz/issues/577
2017-10-23 08:36:40 -04:00
Behdad Esfahbod d0f0ff85b9 [set] Don't use PAGE_SIZE
Fixes https://github.com/behdad/harfbuzz/issues/576
2017-10-23 08:34:30 -04:00
Behdad Esfahbod 8b9d9b71b0 Fix set initialization issues 2017-10-22 17:48:06 -04:00
Behdad Esfahbod ba8b569607 Try fixing build on VC
c:\projects\harfbuzz\src\hb-set-private.hh(151): error C2327: 'hb_set_t::page_t::v': is not a type name, static, or enumerator [C:\projects\harfbuzz\build\harfbuzz.vcxproj]
2017-10-17 11:16:36 -07:00
Behdad Esfahbod a11249ee93 [set] Fix merge logic 2017-10-16 01:33:32 -04:00
Behdad Esfahbod ab8f327eb4 Ouch. 2017-10-15 18:21:35 -04:00
Behdad Esfahbod bb9917913f [set] Disable vectorization
Fixes clang "non-const reference cannot bind to vector element" error.
2017-10-15 18:20:25 -04:00
Behdad Esfahbod 0cf7d957b7 [set] Remove TODO items not worth pursuing 2017-10-15 17:01:31 -04:00
Behdad Esfahbod 10d43658e7 [set] Speed up intersects() 2017-10-15 16:56:05 -04:00
Behdad Esfahbod 7737e87ac4 Properly detect vector_size attribute and use fallback otherwise 2017-10-15 16:21:03 -04:00
Behdad Esfahbod f8a0ec50e2 [set] Add fallback implementation of int-vector type 2017-10-15 16:10:35 -04:00
Behdad Esfahbod deed4a48d1 Faster hb_set_t
Fixes https://github.com/behdad/harfbuzz/pull/23
2017-10-15 16:45:33 -03:00
Behdad Esfahbod a433e60a43 Remove unused hb_frozen_set_t 2017-10-15 14:09:46 +02:00
Behdad Esfahbod 826a1daf2f Move set-digests into their own header file 2017-10-15 14:09:05 +02:00
Behdad Esfahbod dbdbfe3d7b Use nullptr instead of NULL 2017-10-15 12:11:08 +02:00
Behdad Esfahbod c3448e8d21 Use static_assert instead of custom ASSERT_STATIC 2017-10-15 12:02:00 +02:00
Behdad Esfahbod 333173103b Fix sign of shift operators
This one:

  map->mask = (1 << (next_bit + bits_needed)) - (1 << next_bit);

before the fix, the shift was done as an int, causing overflow
if it ever got to 1 << 31.  Sprinkle 'u's around.

Fixes https://bugs.chromium.org/p/chromium/issues/detail?id=634805
2016-08-08 17:28:14 -07:00
Behdad Esfahbod 23e56e088a Fix broken sentence 2015-07-25 17:38:21 +02:00
Behdad Esfahbod 3fe4e92bc5 Minor 2015-04-08 12:49:23 -07:00
Behdad Esfahbod 7b7129c7a9 Add hb_frozen_set_t
I experimented with replacing use of hb_set_digest_t with this new
hb_frozen_set_t, hoping to get a huge speedup for busy lookups
(like kern lookup in Roboto), but I only got 6% speendup in Roboto
and 4% in NotoNastaliqUrduDraft :(.
2015-02-25 15:43:25 -08:00
Behdad Esfahbod cd7ea4f791 Make hb_object_t members private
In preparation for fixing:
https://code.google.com/p/chromium/issues/detail?id=403594
2014-08-14 12:57:02 -04:00
Behdad Esfahbod 2a8c49ade0 Remove unnecessary includes 2013-12-11 20:24:20 -05:00
Behdad Esfahbod 20cbc1f8eb Annotate hb-set a bit; add HB_SET_VALUE_INVALID 2013-09-06 15:31:22 -04:00
Behdad Esfahbod fa3d0a0ce6 Bug 64476 - Typo in hb_set_t.get_min()
Fixes previous commit's test.
2013-05-14 15:30:55 -04:00