Bug 85751 - Shrink TextRun object size
Summary: Shrink TextRun object size
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Rob Buis
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-06 15:13 PDT by Rob Buis
Modified: 2012-05-07 04:12 PDT (History)
3 users (show)

See Also:


Attachments
Patch (3.10 KB, patch)
2012-05-06 15:18 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (3.71 KB, patch)
2012-05-06 16:08 PDT, Rob Buis
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rob Buis 2012-05-06 15:13:23 PDT
TextRun does not do a very good job of bit packing. Since most of the time this is an auto var, no big deal, but for SVG it is a member var of SVGTextMetricsBuilder, and thus RenderSVGText. It also is a member var in
Comment 1 Rob Buis 2012-05-06 15:18:24 PDT
Created attachment 140440 [details]
Patch
Comment 2 Eric Seidel (no email) 2012-05-06 15:49:01 PDT
Comment on attachment 140440 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=140440&action=review

> Source/WebCore/platform/graphics/TextRun.h:170
> +    ExpansionBehavior m_expansionBehavior : 2;

bitfield enums will fail on MSVC (since they're signed).

> Source/WebCore/platform/graphics/TextRun.h:172
> +    TextDirection m_direction : 1;

Similar problem.
Comment 3 Eric Seidel (no email) 2012-05-06 15:49:21 PDT
Also, if we're going to shrink the size of this, we should keep it small with a COMPILE_ASSERT.
Comment 4 Rob Buis 2012-05-06 16:08:25 PDT
Created attachment 140442 [details]
Patch
Comment 5 Eric Seidel (no email) 2012-05-06 16:12:36 PDT
Comment on attachment 140442 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=140442&action=review

> Source/WebCore/platform/graphics/TextRun.h:170
> +    ExpansionBehavior m_expansionBehavior : 2;

Same problem as before.  MSVC will make the enum signed, and thus you'll have one fewer bit than you think you do. :)  I thought we had helper macros for this?
Comment 6 Rob Buis 2012-05-06 16:14:53 PDT
Hi Eric,

(In reply to comment #5)
> (From update of attachment 140442 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=140442&action=review
> 
> > Source/WebCore/platform/graphics/TextRun.h:170
> > +    ExpansionBehavior m_expansionBehavior : 2;
> 
> Same problem as before.  MSVC will make the enum signed, and thus you'll have one fewer bit than you think you do. :)  I thought we had helper macros for this?

It is an unsigned in disguise!

typedef unsigned ExpansionBehavior;
Comment 7 Darin Adler 2012-05-06 18:09:52 PDT
Comment on attachment 140442 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=140442&action=review

Can we add some compile time assertions to check if this is packed right, like we normally do in cases like this?

>>> Source/WebCore/platform/graphics/TextRun.h:170
>>> +    ExpansionBehavior m_expansionBehavior : 2;
>> 
>> Same problem as before.  MSVC will make the enum signed, and thus you'll have one fewer bit than you think you do. :)  I thought we had helper macros for this?
> 
> It is an unsigned in disguise!
> 
> typedef unsigned ExpansionBehavior;

Why not be explicit about it, given the likelihood of confusion?
Comment 8 Rob Buis 2012-05-06 19:32:36 PDT
Hi Darin,

(In reply to comment #7)
> (From update of attachment 140442 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=140442&action=review
> 
> Can we add some compile time assertions to check if this is packed right, like we normally do in cases like this?

Good idea, did that before landing.

> >>> Source/WebCore/platform/graphics/TextRun.h:170
> >>> +    ExpansionBehavior m_expansionBehavior : 2;
> >> 
> >> Same problem as before.  MSVC will make the enum signed, and thus you'll have one fewer bit than you think you do. :)  I thought we had helper macros for this?
> > 
> > It is an unsigned in disguise!
> > 
> > typedef unsigned ExpansionBehavior;
> 
> Why not be explicit about it, given the likelihood of confusion?

I tried but unfortunately this would mean changing a lot of files that use this ExpansionBehavior. Let me know if you want a follow-up bug for that.
Cheers,

Rob.
Comment 9 Raphael Kubo da Costa (:rakuco) 2012-05-06 19:52:47 PDT
Build fix for r116260 landed in r116262.
Comment 10 Rob Buis 2012-05-07 04:11:43 PDT
(In reply to comment #9)
> Build fix for r116260 landed in r116262.

Thanks!
Comment 11 Rob Buis 2012-05-07 04:12:09 PDT
Landed in r116260.