Changeset 219182 in webkit


Ignore:
Timestamp:
Jul 5, 2017 7:31:35 PM (7 years ago)
Author:
Yusuke Suzuki
Message:

WTF::StringImpl::copyChars segfaults when built with GCC 7
https://bugs.webkit.org/show_bug.cgi?id=173407

Reviewed by Andreas Kling.

JSTests:

  • stress/string-repeat-copy-chars-crash.js: Added.

(shouldBe):

Source/WTF:

With GCC 7, StringImpl::copyChars() behaves as unexpected.
This function violates strict aliasing rule.

This optimization is originally introduced to improve performance
in SunSpider's string tests in 2008. When running it in my Linux
box, it no longer causes any observable difference. So, we just
remove this optimization.

baseline patched

string-base64 7.7544+-0.1761 7.6138+-0.2071 might be 1.0185x faster
string-fasta 10.5429+-0.2746 ? 10.7500+-0.2669 ? might be 1.0196x slower
string-tagcloud 14.8588+-0.2828 14.8039+-0.3039
string-unpack-code 36.1769+-0.4251 35.3397+-0.5398 might be 1.0237x faster
string-validate-input 8.5182+-0.2206 8.3514+-0.2179 might be 1.0200x faster

  • wtf/text/StringImpl.h:

(WTF::StringImpl::copyChars):

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r219079 r219182  
     12017-07-05  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        WTF::StringImpl::copyChars segfaults when built with GCC 7
     4        https://bugs.webkit.org/show_bug.cgi?id=173407
     5
     6        Reviewed by Andreas Kling.
     7
     8        * stress/string-repeat-copy-chars-crash.js: Added.
     9        (shouldBe):
     10
    1112017-07-03  Saam Barati  <sbarati@apple.com>
    212
  • trunk/Source/WTF/ChangeLog

    r219179 r219182  
     12017-07-05  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        WTF::StringImpl::copyChars segfaults when built with GCC 7
     4        https://bugs.webkit.org/show_bug.cgi?id=173407
     5
     6        Reviewed by Andreas Kling.
     7
     8        With GCC 7, StringImpl::copyChars() behaves as unexpected.
     9        This function violates strict aliasing rule.
     10
     11        This optimization is originally introduced to improve performance
     12        in SunSpider's string tests in 2008. When running it in my Linux
     13        box, it no longer causes any observable difference. So, we just
     14        remove this optimization.
     15
     16                                        baseline                  patched
     17
     18        string-base64                7.7544+-0.1761            7.6138+-0.2071          might be 1.0185x faster
     19        string-fasta                10.5429+-0.2746     ?     10.7500+-0.2669        ? might be 1.0196x slower
     20        string-tagcloud             14.8588+-0.2828           14.8039+-0.3039
     21        string-unpack-code          36.1769+-0.4251           35.3397+-0.5398          might be 1.0237x faster
     22        string-validate-input        8.5182+-0.2206            8.3514+-0.2179          might be 1.0200x faster
     23
     24        * wtf/text/StringImpl.h:
     25        (WTF::StringImpl::copyChars):
     26
    1272017-07-05  Yusuke Suzuki  <utatane.tea@gmail.com>
    228
  • trunk/Source/WTF/wtf/text/StringImpl.h

    r218066 r219182  
    628628            return;
    629629        }
    630 
    631         if (numCharacters <= s_copyCharsInlineCutOff) {
    632             unsigned i = 0;
    633 #if (CPU(X86) || CPU(X86_64))
    634             const unsigned charsPerInt = sizeof(uint32_t) / sizeof(T);
    635 
    636             if (numCharacters > charsPerInt) {
    637                 unsigned stopCount = numCharacters & ~(charsPerInt - 1);
    638 
    639                 const uint32_t* srcCharacters = reinterpret_cast<const uint32_t*>(source);
    640                 uint32_t* destCharacters = reinterpret_cast<uint32_t*>(destination);
    641                 for (unsigned j = 0; i < stopCount; i += charsPerInt, ++j)
    642                     destCharacters[j] = srcCharacters[j];
    643             }
    644 #endif
    645             for (; i < numCharacters; ++i)
    646                 destination[i] = source[i];
    647         } else
    648             memcpy(destination, source, numCharacters * sizeof(T));
     630        memcpy(destination, source, numCharacters * sizeof(T));
    649631    }
    650632
     
    860842    }
    861843
    862     // This number must be at least 2 to avoid sharing empty, null as well as 1 character strings from SmallStrings.
    863     static const unsigned s_copyCharsInlineCutOff = 20;
    864 
    865844    enum class CaseConvertType { Upper, Lower };
    866845    template<CaseConvertType type, typename CharacterType> static Ref<StringImpl> convertASCIICase(StringImpl&, const CharacterType*, unsigned);
Note: See TracChangeset for help on using the changeset viewer.