Closed Bug 1290160 Opened 6 years ago Closed 6 years ago

reduce codesize required by gfxPrefs


(Core :: Graphics, defect)

Not set



Tracking Status
firefox51 --- fixed


(Reporter: froydnj, Assigned: froydnj)



(1 file)

Every gfxPrefs::PrefTemplate template declares its own virtual function
overrides for functions declared in gfxPrefs::Pref.  The compiler must
therefore create separate copies of each of these virtual functions when
it instantiates PrefTemplate.  Since several of these virtual functions
only depend on the template parameter T, the type of the pref, many
instantiations of the functions are identical.  The duplicate functions
would normally be merged by identical code folding performed in the
linker, but since these are virtual functions and therefore have their
addresses taken (to be stored in the class's vtable), the linker (at
least for the settings we use for identical code folding) cannot fold
duplicated functions together.

Therefore, we have to do the de-duplication ourselves, by creating an
intermediate templated base class that only depends on the type of the
pref.  With this class, only three copies of each virtual function will
be created (one each for bools, floats, and ints).  We sneak in
GetLiveValue() into this base class for another small codesize win, even
though it's not a virtual function.
An explanation is in the patch's commit message.  The explanation for the
|this->| prefixes everywhere is "Because C++" (specifically how name lookup
works in templates).
Attachment #8775631 - Flags: review?(milan)
I should say: this change reduces codesize by ~32K on x86-64.  Not great, but I think it's worth it.
Comment on attachment 8775631 [details] [diff] [review]
reduce codesize required by gfxPrefs

Review of attachment 8775631 [details] [diff] [review]:

Nice!  Do we have some numbers as to the code size differences?
Attachment #8775631 - Flags: review?(milan) → review+
Pushed by
reduce codesize required by gfxPrefs; r=milan
Pushed by
followup to fix static analysis bustage on a CLOSED TREE; r=me
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
(In reply to Milan Sreckovic [:milan] from comment #3)
> Nice!  Do we have some numbers as to the code size differences?

~32K on x86-64.  Roughly a third of the space taken by gfxPrefs code + data.
You need to log in before you can comment on or make changes to this bug.