<?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>101421</bug_id>
          
          <creation_ts>2012-11-06 19:12:56 -0800</creation_ts>
          <short_desc>StringBuilder::append(UChar) with an 8 bit quantity shouldn&apos;t change the contents to 16 bits</short_desc>
          <delta_ts>2012-11-08 11:09:35 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</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="Michael Saboff">msaboff</reporter>
          <assigned_to name="Michael Saboff">msaboff</assigned_to>
          <cc>benjamin</cc>
    
    <cc>ojan</cc>
    
    <cc>webkit.review.bot</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>760297</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Saboff">msaboff</who>
    <bug_when>2012-11-06 19:12:56 -0800</bug_when>
    <thetext>StringBuilder objects keep track of whether or not the contents are all 8 bit in m_is8Bit.  If appendChar(UChar) is called, m_is8Bit is set to false.

An improvement is to look at the argument to StringBuilder::append(UChar) when m_is8Bit is true and see if the value can fit in 8 bits.  If so, keep m_is8Bit true and append the character to the 8 bit buffer.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>760396</commentid>
    <comment_count>1</comment_count>
      <attachid>172720</attachid>
    <who name="Michael Saboff">msaboff</who>
    <bug_when>2012-11-06 22:14:07 -0800</bug_when>
    <thetext>Created attachment 172720
Patch

This appears to be a progression on most of the Parser performance tests.  Here is a comparison of the arithmetic average of 8 test runs for the parser tests:

Test                 Baseline        With Patch   Change
html-parser         2026.46ms      1989.21ms      +2.8%
html5-full-render   4274.28ms      4176.83ms      +2.3%
innerHTML-setter     263.14runs/s   269.21runs/s  +2.3%
simple-url            48.47runs/s    51.14runs/s  +5.5%
textarea-parsing      82.73runs/s    83.00runs/s  +0.3%
tiny-inner-HTML        5.08runs/s     5.07runs/s  -0.2%
url-parser           111.32runs/r   117.61runs/s  +5.7%
xml-parser             7.07runs/s     7.20runs/s  +1.8%</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>760418</commentid>
    <comment_count>2</comment_count>
      <attachid>172720</attachid>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2012-11-06 23:13:48 -0800</bug_when>
    <thetext>Comment on attachment 172720
Patch

Clearing flags on attachment: 172720

Committed r133726: &lt;http://trac.webkit.org/changeset/133726&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>760419</commentid>
    <comment_count>3</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2012-11-06 23:13:51 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>760746</commentid>
    <comment_count>4</comment_count>
      <attachid>172720</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2012-11-07 08:48:56 -0800</bug_when>
    <thetext>Comment on attachment 172720
Patch

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

&gt; Source/WTF/wtf/text/StringBuilder.cpp:251
&gt; +        if (length == 1 &amp;&amp; !(*characters &amp; ~0xff)) {
&gt; +            // Append as 8 bit character
&gt; +            LChar lChar = static_cast&lt;LChar&gt;(*characters);
&gt; +            append(&amp;lChar, 1);
&gt; +            return;
&gt; +        }

It seems a little strange to have the 1-character special case here instead of in the append(UChar) function.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>760821</commentid>
    <comment_count>5</comment_count>
      <attachid>172720</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2012-11-07 10:08:49 -0800</bug_when>
    <thetext>Comment on attachment 172720
Patch

Now that I have some time to think about it, I realize I would have done this differently. I would have left the StringBuilder::append(const UChar, unsigned) function alone. And I would have added this to the start of append(UChar c):

    if (!(c &amp; ~0xff)) {
        append(static_cast&lt;LChar&gt;(c));
        return;
    }

I wonder whether that version of the patch would have better or worse performance than the one you landed?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>761105</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Saboff">msaboff</who>
    <bug_when>2012-11-07 15:28:18 -0800</bug_when>
    <thetext>(In reply to comment #5)
&gt; (From update of attachment 172720 [details])
&gt; Now that I have some time to think about it, I realize I would have done this differently. I would have left the StringBuilder::append(const UChar, unsigned) function alone. And I would have added this to the start of append(UChar c):
&gt; 
&gt;     if (!(c &amp; ~0xff)) {
&gt;         append(static_cast&lt;LChar&gt;(c));
&gt;         return;
&gt;     }
&gt; 
&gt; I wonder whether that version of the patch would have better or worse performance than the one you landed?

I&apos;ll try that out, measure performance and report.  I suspect that it will be pretty close to equal.  The reason I went the way I did was to reduce bloat due to a larger inlined function.  Therefore I&apos;ll also check object size differences as well.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>761939</commentid>
    <comment_count>7</comment_count>
    <who name="Ojan Vafai">ojan</who>
    <bug_when>2012-11-08 10:30:35 -0800</bug_when>
    <thetext>It&apos;s hard to tell with all the noise, but it also looks like this was a ~11% improvement in setting style.

http://build.chromium.org/f/chromium/perf/mac-release-10.6-webkit-latest/dromaeo_jslibstyleprototype/report.html?rev=166663&amp;graph=jslib_style_prototype_Prototype___setStyle__&amp;trace=score&amp;history=50</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>761985</commentid>
    <comment_count>8</comment_count>
    <who name="Ojan Vafai">ojan</who>
    <bug_when>2012-11-08 11:09:35 -0800</bug_when>
    <thetext>Actually, it&apos;s an improvement on a bunch of the jquery benchmarks:

http://build.chromium.org/f/chromium/perf/mac-release-10.6-webkit-latest/dromaeo_jslibstylejquery/report.html?rev=166613&amp;graph=jslib_style_jquery_jQuery___height___x10&amp;trace=score&amp;history=150

http://build.chromium.org/f/chromium/perf/mac-release-10.6-webkit-latest/dromaeo_jslibstylejquery/report.html?rev=166613&amp;graph=jslib_style_jquery_jQuery___width___x10&amp;trace=score&amp;history=150

http://build.chromium.org/f/chromium/perf/mac-release-10.6-webkit-latest/dromaeo_jslibstylejquery/report.html?rev=166664&amp;graph=jslib_style_jquery_jQuery___css_color__x100&amp;trace=score&amp;history=150

http://build.chromium.org/f/chromium/perf/mac-release-10.6-webkit-latest/dromaeo_jslibstylejquery/report.html?rev=166664&amp;graph=jslib_style_jquery_jQuery____is__visible_&amp;trace=score&amp;history=150

Probably some others too, but I&apos;ll stop there. :)</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>172720</attachid>
            <date>2012-11-06 22:14:07 -0800</date>
            <delta_ts>2012-11-07 10:08:49 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>101421.patch</filename>
            <type>text/plain</type>
            <size>2548</size>
            <attacher name="Michael Saboff">msaboff</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XVEYvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFNvdXJjZS9XVEYvQ2hh
bmdlTG9nCShyZXZpc2lvbiAxMzM3MjApCisrKyBTb3VyY2UvV1RGL0NoYW5nZUxvZwkod29ya2lu
ZyBjb3B5KQpAQCAtMSwzICsxLDE4IEBACisyMDEyLTExLTA2ICBNaWNoYWVsIFNhYm9m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aWxkZXIuaAkod29ya2luZyBjb3B5KQpAQCAt
MTExLDEwICsxMTEsMTggQEAgcHVibGljOgogCiAgICAgdm9pZCBhcHBlbmQoVUNoYXIgYykKICAg
ICB7Ci0gICAgICAgIGlmIChtX2J1ZmZlciAmJiAhbV9pczhCaXQgJiYgbV9sZW5ndGggPCBtX2J1
ZmZlci0+bGVuZ3RoKCkgJiYgbV9zdHJpbmcuaXNOdWxsKCkpCi0gICAgICAgICAgICBtX2J1ZmZl
ckNoYXJhY3RlcnMxNlttX2xlbmd0aCsrXSA9IGM7Ci0gICAgICAgIGVsc2UKLSAgICAgICAgICAg
IGFwcGVuZCgmYywgMSk7CisgICAgICAgIGlmIChtX2J1ZmZlciAmJiBtX2xlbmd0aCA8IG1fYnVm
ZmVyLT5sZW5ndGgoKSAmJiBtX3N0cmluZy5pc051bGwoKSkgeworICAgICAgICAgICAgaWYgKCFt
X2lzOEJpdCkgeworICAgICAgICAgICAgICAgIG1fYnVmZmVyQ2hhcmFjdGVyczE2W21fbGVuZ3Ro
KytdID0gYzsKKyAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICB9CisKKyAgICAg
ICAgICAgIGlmICghKGMgJiB+MHhmZikpIHsKKyAgICAgICAgICAgICAgICBtX2J1ZmZlckNoYXJh
Y3RlcnM4W21fbGVuZ3RoKytdID0gc3RhdGljX2Nhc3Q8TENoYXI+KGMpOworICAgICAgICAgICAg
ICAgIHJldHVybjsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgICAgICBhcHBlbmQoJmMs
IDEpOwogICAgIH0KIAogICAgIHZvaWQgYXBwZW5kKExDaGFyIGMpCg==
</data>

          </attachment>
      

    </bug>

</bugzilla>