Bug 71668 - CSSValue: Devirtualize isFooType().
Summary: CSSValue: Devirtualize isFooType().
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andreas Kling
URL:
Keywords:
: 64863 (view as bug list)
Depends on: 71667
Blocks: 71666
  Show dependency treegraph
 
Reported: 2011-11-07 04:53 PST by Andreas Kling
Modified: 2012-01-08 15:27 PST (History)
4 users (show)

See Also:


Attachments
Patch (depends on 71667) (72.14 KB, patch)
2011-11-07 05:01 PST, Andreas Kling
koivisto: review-
Details | Formatted Diff | Diff
Proposed patch v2 (77.15 KB, patch)
2011-11-07 11:48 PST, Andreas Kling
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Kling 2011-11-07 04:53:20 PST
CSSValue: Devirtualize isFooType().
Comment 1 Andreas Kling 2011-11-07 05:01:18 PST
Created attachment 113847 [details]
Patch (depends on 71667)
Comment 2 Antti Koivisto 2011-11-07 05:44:31 PST
Comment on attachment 113847 [details]
Patch (depends on 71667)

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

> Source/WebCore/css/CSSPrimitiveValueMappings.h:1342
> +    : CSSValue(PrimitiveClass, CSS_PRIMITIVE_VALUE, /* isPrimitive */ true)

Kinda hatin' here...
Comment 3 Andreas Kling 2011-11-07 05:47:10 PST
(In reply to comment #2)
> (From update of attachment 113847 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=113847&action=review
> 
> > Source/WebCore/css/CSSPrimitiveValueMappings.h:1342
> > +    : CSSValue(PrimitiveClass, CSS_PRIMITIVE_VALUE, /* isPrimitive */ true)
> 
> Kinda hatin' here...

Reviewers gonna review. I'll redesign as discussed.
Comment 4 Andreas Kling 2011-11-07 11:48:53 PST
Created attachment 113904 [details]
Proposed patch v2

A little less verbose this time. ;)
Comment 5 Darin Adler 2011-11-07 12:07:13 PST
Comment on attachment 113904 [details]
Proposed patch v2

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

> Source/WebCore/css/CSSImageValue.h:53
> +    CSSImageValue(const String& url);

This single-argument constructor should probably be marked explicit.

> Source/WebCore/css/CSSMutableValue.h:43
> +    CSSMutableValue(ClassType classType)

This single-argument constructor should probably be marked explicit.

> Source/WebCore/css/CSSPrimitiveValue.h:225
> +    CSSPrimitiveValue(int ident);
>      CSSPrimitiveValue(unsigned color); // RGB value
>      CSSPrimitiveValue(const Length&);

We should explore putting the explicit keyword on these single-argument constructors.

> Source/WebCore/css/CSSValue.h:135
> +    CSSValue(ClassType classType)
> +        : m_classType(classType)
> +        , m_isPrimitive(isPrimitiveType(classType))
> +        , m_isMutable(isMutableType(classType))
> +        , m_isList(isListType(classType))
> +        , m_isInitial(isInitialType(classType))
> +        , m_isInherited(isInheritedType(classType))

Another way to do this is to include bits to indicate these properties in the constants that are passed in.

> Source/WebCore/css/CSSValue.h:145
> +               || type == ImageClass
> +               || type == CursorImageClass
> +               || type == FontFamilyClass;

These are indented 7 spaces. Instead should be indented 4 spaces.

> Source/WebCore/css/CSSValueList.h:68
> +    CSSValueList(bool isSpaceSeparated);
> +    CSSValueList(CSSParserValueList*);

Should use explicit here.

> Source/WebCore/svg/SVGColor.h:83
> +    SVGColor(const SVGColorType&);

Should mark this explicit.
Comment 6 Andreas Kling 2011-11-07 13:20:06 PST
Committed r99468: <http://trac.webkit.org/changeset/99468>
Comment 7 Luke Macpherson 2011-11-17 16:25:28 PST
Hi Andreas, what was the rationale for caching m_isPrimitiveValue and m_isList rather than just calculating from m_classType when needed?

Could we just rearrange the ClassType Enum to allow the inline check to be a single comparison?
Comment 8 Andreas Kling 2011-11-21 06:56:34 PST
(In reply to comment #7)
> Hi Andreas, what was the rationale for caching m_isPrimitiveValue and m_isList rather than just calculating from m_classType when needed?
> 
> Could we just rearrange the ClassType Enum to allow the inline check to be a single comparison?

Hi Luke,

The idea was to keep isPrimitiveValue() and isValueList() as cheap as possible as a "speculative optimization" since they are used quite a bit.

If you have an idea for removing the need for them without incurring additional compares, I'm all ears :)
Comment 9 David Barr 2012-01-08 15:27:53 PST
*** Bug 64863 has been marked as a duplicate of this bug. ***