See https://dxr.mozilla.org/mozilla-central/rev/2cca333f546f38860f84940d4c72d7470a3410f4/gfx/thebes/gfxTextRun.h#760-762. I propose to reduce the size of gfxTextRun by replacing the AutoTArray<GlyphRun,1> (32 bytes in a 64-bit build) with a union that holds either a single GlyphRun *or* an nsTArray<GlyphRun>, with a flag elsewhere in gfxTextRun to record which is currently present (we have a spare padding byte available for that). There will be a bit of overhead in AddGlyphRun when transitioning from a single glyphrun (stored inline) to two glyphruns (in an array), but that will be essentially equivalent to the work AutoTArray does when its autobuffer oveflows. This should reduce the size of gfxTextRun by 16 bytes, yet have the same allocation behavior as at present: when there's a single GlyphRun, it is stored directly in the textrun with no separate heap allocation, and when there are multiple glyph runs, we have to allocate heap storage for the array (just as the autoarray does when its one-element buffer overflows).
Created attachment 8862944 [details] [diff] [review] Optimize GlyphRun storage strategy in gfxTextRun, to reduce the overall size of the gfxTextRun object
Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
Attachment #8862944 - Flags: review?(jmuizelaar)
Attachment #8862944 - Flags: review?(jmuizelaar) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/dca52e4ed76197ec3e3629e659020c3d5c8d81bb Bug 1360620 - Optimize GlyphRun storage strategy in gfxTextRun, to reduce the overall size of the gfxTextRun object. r=jrmuizel
Pushed by firstname.lastname@example.org: https://hg.mozilla.org/integration/mozilla-inbound/rev/dca52e4ed761 Optimize GlyphRun storage strategy in gfxTextRun, to reduce the overall size of the gfxTextRun object. r=jrmuizel
Status: ASSIGNED → RESOLVED
Last Resolved: 9 months ago
status-firefox55: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in before you can comment on or make changes to this bug.