Bug 68588

Summary: [CG] ImageBufferData::getData has an invariant comparison in the inner part of a loop which doesn't get optimized out
Product: WebKit Reporter: Tim Horton <thorton>
Component: Layout and RenderingAssignee: Tim Horton <thorton>
Status: RESOLVED FIXED    
Severity: Normal CC: simon.fraser, webkit-bug-importer, webkit.review.bot
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
"repro"
none
patch
none
style fix
none
patch none

Description Tim Horton 2011-09-21 17:23:57 PDT
The test of "unmultiplied" inside the inner loop of ImageBufferData::getData is unnecessary; unmultiplied won't change during the course of this calculation.

I would have expected this to be optimized out by the compiler, but this patch provides a consistent and reproducible 1.7x speedup (visible with Instruments) in ImageBufferData::getData in the not-unmultiplied case with the attached test case (requires filters to be turned on).
Comment 1 Radar WebKit Bug Importer 2011-09-21 17:24:24 PDT
<rdar://problem/10164955>
Comment 2 Tim Horton 2011-09-21 17:29:11 PDT
Created attachment 108257 [details]
"repro"
Comment 3 Tim Horton 2011-09-21 17:29:39 PDT
Created attachment 108259 [details]
patch
Comment 4 WebKit Review Bot 2011-09-21 17:32:31 PDT
Attachment 108259 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1

Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp:195:  One line control clauses should not use braces.  [whitespace/braces] [4]
Total errors found: 1 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Tim Horton 2011-09-21 17:35:42 PDT
Created attachment 108260 [details]
style fix
Comment 6 Tim Horton 2011-09-21 17:36:11 PDT
I should note that I was testing this on a release build.
Comment 7 Tim Horton 2011-09-21 18:07:49 PDT
Created attachment 108263 [details]
patch

Mark noted that with this patch, I'm not assigning any data in the case of 0 alpha. Fixed.
Comment 8 Simon Fraser (smfr) 2011-09-21 18:38:51 PDT
Comment on attachment 108263 [details]
patch

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

This code grows more and more unwieldy with each change.

> Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp:195
> +                    reinterpret_cast<uint32_t*>(destRows + x)[0] = reinterpret_cast<uint32_t*>(srcRows + x)[0];

Can this be a memcpy?
Comment 9 WebKit Review Bot 2011-09-21 19:03:36 PDT
Comment on attachment 108263 [details]
patch

Clearing flags on attachment: 108263

Committed r95695: <http://trac.webkit.org/changeset/95695>
Comment 10 WebKit Review Bot 2011-09-21 19:03:41 PDT
All reviewed patches have been landed.  Closing bug.