<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>93370</bug_id>
          
          <creation_ts>2012-08-07 07:36:01 -0700</creation_ts>
          <short_desc>reimplement fastMod w/o (soon to be) private skia macros</short_desc>
          <delta_ts>2012-08-07 15:09:25 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Mike Reed">reed</reporter>
          <assigned_to name="Mike Reed">reed</assigned_to>
          <cc>enne</cc>
    
    <cc>jamesr</cc>
    
    <cc>schenney</cc>
    
    <cc>senorblanco</cc>
    
    <cc>webkit.review.bot</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>689131</commentid>
    <comment_count>0</comment_count>
    <who name="Mike Reed">reed</who>
    <bug_when>2012-08-07 07:36:01 -0700</bug_when>
    <thetext>reimplement fastMod w/o (soon to be) private skia macros</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>689133</commentid>
    <comment_count>1</comment_count>
      <attachid>156939</attachid>
    <who name="Mike Reed">reed</who>
    <bug_when>2012-08-07 07:37:55 -0700</bug_when>
    <thetext>Created attachment 156939
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>689218</commentid>
    <comment_count>2</comment_count>
      <attachid>156939</attachid>
    <who name="Adrienne Walker">enne</who>
    <bug_when>2012-08-07 11:25:07 -0700</bug_when>
    <thetext>Comment on attachment 156939
Patch

R=me.  Those look functionally equivalent to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>689240</commentid>
    <comment_count>3</comment_count>
      <attachid>156939</attachid>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2012-08-07 11:45:03 -0700</bug_when>
    <thetext>Comment on attachment 156939
Patch

Clearing flags on attachment: 156939

Committed r124901: &lt;http://trac.webkit.org/changeset/124901&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>689241</commentid>
    <comment_count>4</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2012-08-07 11:45:07 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>689346</commentid>
    <comment_count>5</comment_count>
      <attachid>156939</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2012-08-07 13:51:21 -0700</bug_when>
    <thetext>Comment on attachment 156939
Patch

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

&gt; Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp:76
&gt; +        value = -value;

This won’t work if value is MIN_INT. I assume that’s OK since the old code already worked like that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>689446</commentid>
    <comment_count>6</comment_count>
      <attachid>156939</attachid>
    <who name="Allan Sandfeld Jensen">allan.jensen</who>
    <bug_when>2012-08-07 14:58:50 -0700</bug_when>
    <thetext>Comment on attachment 156939
Patch

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

&gt; Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp:72
&gt;  inline int fastMod(int value, int max)

Considering this a slow workaround for a something poorly defined in the C++ standard, I find the name fastMod a bit confusing. Have you considered a rename? I know this function is not from your patch, but since your patch makes it even slower it just makes the name weirder.

Also do you actually have any examples of actual C++ implementations where (a % x) != -(-a % x). I thought this issue would be resolved by now. C++11 defined it to what all sane implementation already did, which is the same this function tries to return.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>689459</commentid>
    <comment_count>7</comment_count>
    <who name="Mike Reed">reed</who>
    <bug_when>2012-08-07 15:09:25 -0700</bug_when>
    <thetext>I think fastMod came from the &gt;= check, so that we don&apos;t call % at all if value &lt; max

Good question if there are any real differences in how negatives are handled w.r.t. %. I haven&apos;t looked in a long while.

Not sure the new one is slower actually. On architectures that have conditional instructions like ARM (and modern x86s), 

if (x &lt; 0)
    x = -x;

Can be two instructions w/ zero branches, as opposed to 2 or 3 for the extract/apply pattern. I haven&apos;t timed this particular use case tho.

However, I agree that fastMod does not actually capture the whole intent: safeIntegerMod might be a better name.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>156939</attachid>
            <date>2012-08-07 07:37:55 -0700</date>
            <delta_ts>2012-08-07 14:58:50 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-93370-20120807103730.patch</filename>
            <type>text/plain</type>
            <size>1703</size>
            <attacher name="Mike Reed">reed</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBTb3VyY2UvV2Vi
Q29yZS9DaGFuZ2VMb2cJKHJldmlzaW9uIDEyNDg4NykKKysrIFNvdXJjZS9XZWJDb3JlL0NoYW5n
ZUxvZwkod29ya2luZyBjb3B5KQpAQCAtMSwzICsxLDE3IEBACisyMDEyLTA4LTA3ICBNaWtlIFJl
ZWQgIDxyZWVkQGdvb2dsZS5jb20+CisKKyAgICAgICAgcmVpbXBsZW1lbnQgZmFzdE1vZCB3L28g
KHNvb24gdG8gYmUp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vcmUvcGxhdGZvcm0vZ3JhcGhpY3Mvc2tpYS9HcmFwaGlj
c0NvbnRleHRTa2lhLmNwcAkod29ya2luZyBjb3B5KQpAQCAtNjgsMTQgKzY4LDE5IEBAIG5hbWVz
cGFjZSBXZWJDb3JlIHsKIAogbmFtZXNwYWNlIHsKIAorLy8gUmV0dXJuIHZhbHVlICUgbWF4LCBi
dXQgYWNjb3VudCBmb3IgdmFsdWUgcG9zc2libHkgYmVpbmcgbmVnYXRpdmUuCiBpbmxpbmUgaW50
IGZhc3RNb2QoaW50IHZhbHVlLCBpbnQgbWF4KQogewotICAgIGludCBzaWduID0gU2tFeHRyYWN0
U2lnbih2YWx1ZSk7Ci0KLSAgICB2YWx1ZSA9IFNrQXBwbHlTaWduKHZhbHVlLCBzaWduKTsKKyAg
ICBib29sIGlzTmVnID0gZmFsc2U7CisgICAgaWYgKHZhbHVlIDwgMCkgeworICAgICAgICB2YWx1
ZSA9IC12YWx1ZTsKKyAgICAgICAgaXNOZWcgPSB0cnVlOworICAgIH0KICAgICBpZiAodmFsdWUg
Pj0gbWF4KQogICAgICAgICB2YWx1ZSAlPSBtYXg7Ci0gICAgcmV0dXJuIFNrQXBwbHlTaWduKHZh
bHVlLCBzaWduKTsKKyAgICBpZiAoaXNOZWcpCisgICAgICAgIHZhbHVlID0gLXZhbHVlOworICAg
IHJldHVybiB2YWx1ZTsKIH0KIAogaW5saW5lIGZsb2F0IHNxdWFyZShmbG9hdCBuKQo=
</data>

          </attachment>
      

    </bug>

</bugzilla>