Changeset 249543 in webkit


Ignore:
Timestamp:
Sep 5, 2019 2:13:15 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r247463.
https://bugs.webkit.org/show_bug.cgi?id=201515

JetStream2 code-load related regression (Requested by
yusukesuzuki on #webkit).

Reverted changeset:

"Keyword lookup can use memcmp to get around unaligned load
undefined behavior"
https://bugs.webkit.org/show_bug.cgi?id=199650
https://trac.webkit.org/changeset/247463

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r249538 r249543  
     12019-09-05  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r247463.
     4        https://bugs.webkit.org/show_bug.cgi?id=201515
     5
     6        JetStream2 code-load related regression (Requested by
     7        yusukesuzuki on #webkit).
     8
     9        Reverted changeset:
     10
     11        "Keyword lookup can use memcmp to get around unaligned load
     12        undefined behavior"
     13        https://bugs.webkit.org/show_bug.cgi?id=199650
     14        https://trac.webkit.org/changeset/247463
     15
    1162019-09-05  Tadeu Zagallo  <tzagallo@apple.com>
    217
  • trunk/Source/JavaScriptCore/KeywordLookupGenerator.py

    r249175 r249543  
    138138        self.weight = weight
    139139
    140     def printSubTreeAsC(self, indent):
     140    def printSubTreeAsC(self, typeName, indent):
    141141        str = makePadding(indent)
    142142
    143143        if self.value != None:
    144             print(str + "if (!isIdentPartIncludingEscape(code + %d, m_codeEnd)) {" % (len(self.fullPrefix)))
     144            print(str + "if (!isIdentPartIncludingEscape(code+%d, m_codeEnd)) {" % (len(self.fullPrefix)))
    145145            print(str + "    internalShift<%d>();" % len(self.fullPrefix))
    146146            print(str + "    if (shouldCreateIdentifier)")
     
    156156                k = trie.fullPrefix[baseIndex] + k
    157157            test = [("'%s'" % c) for c in k]
    158             base = "code + %d" % baseIndex
    159             length = __builtins__.str(len(test))
    160             needle = "(std::array<Char, " + length + ">{{" + ", ".join(test) + "}}).data()"
    161             comparison = ("!memcmp(%s, " % (base)) + needle + ", " + length + " * sizeof(Char))"
     158            if len(test) == 1:
     159                comparison = "code[%d] == %s" % (baseIndex, test[0])
     160            else:
     161                base = "code"
     162                if baseIndex > 0:
     163                    base = "code + %d" % baseIndex
     164                comparison = ("COMPARE_%d%sS(%s, " % (len(test), typeName, base)) + ", ".join(test) + ")"
    162165            if itemCount == 0:
    163166                print(str + "if (" + comparison + ") {")
     
    165168                print(str + "} else if (" + comparison + ") {")
    166169
    167             trie.printSubTreeAsC(indent + 4)
     170            trie.printSubTreeAsC(typeName, indent + 4)
    168171            itemCount = itemCount + 1
    169172
     
    187190        print("static const int maxTokenLength = %d;" % (self.maxLength() + 1))
    188191        print("")
    189         print("template <typename Char>")
    190         print("template <bool shouldCreateIdentifier> ALWAYS_INLINE JSTokenType Lexer<Char>::parseKeyword(JSTokenData* data)")
     192        print("template <>")
     193        print("template <bool shouldCreateIdentifier> ALWAYS_INLINE JSTokenType Lexer<UChar>::parseKeyword(JSTokenData* data)")
    191194        print("{")
    192195        print("    ASSERT(m_codeEnd - m_code >= maxTokenLength);")
    193196        print("")
    194         print("    const Char* code = m_code;")
    195         self.printSubTreeAsC(4)
     197        print("    const UChar* code = m_code;")
     198        self.printSubTreeAsC("UCHAR", 4)
     199        print("    return IDENT;")
     200        print("}")
     201        print("")
     202        print("template <>")
     203        print("template <bool shouldCreateIdentifier> ALWAYS_INLINE JSTokenType Lexer<LChar>::parseKeyword(JSTokenData* data)")
     204        print("{")
     205        print("    ASSERT(m_codeEnd - m_code >= maxTokenLength);")
     206        print("")
     207        print("    const LChar* code = m_code;")
     208        self.printSubTreeAsC("CHAR", 4)
    196209        print("    return IDENT;")
    197210        print("}")
     
    206219trie.fillOut()
    207220print("// This file was generated by KeywordLookupGenerator.py.  Do not edit.")
     221print("""
     222#if CPU(NEEDS_ALIGNED_ACCESS)
     223
     224#define COMPARE_2CHARS(address, char1, char2) \\
     225    (((address)[0] == char1) && ((address)[1] == char2))
     226#define COMPARE_4CHARS(address, char1, char2, char3, char4) \\
     227    (COMPARE_2CHARS(address, char1, char2) && COMPARE_2CHARS((address) + 2, char3, char4))
     228#define COMPARE_2UCHARS(address, char1, char2) \\
     229    (((address)[0] == char1) && ((address)[1] == char2))
     230#define COMPARE_4UCHARS(address, char1, char2, char3, char4) \\
     231    (COMPARE_2UCHARS(address, char1, char2) && COMPARE_2UCHARS((address) + 2, char3, char4))
     232
     233#else // CPU(NEEDS_ALIGNED_ACCESS)
     234
     235#if CPU(BIG_ENDIAN)
     236
     237#define CHARPAIR_TOUINT16(a, b) \\
     238    ((((uint16_t)(a)) << 8) + (uint16_t)(b))
     239#define CHARQUAD_TOUINT32(a, b, c, d) \\
     240    ((((uint32_t)(CHARPAIR_TOUINT16(a, b))) << 16) + CHARPAIR_TOUINT16(c, d))
     241#define UCHARPAIR_TOUINT32(a, b) \\
     242    ((((uint32_t)(a)) << 16) + (uint32_t)(b))
     243#define UCHARQUAD_TOUINT64(a, b, c, d) \\
     244    ((((uint64_t)(UCHARQUAD_TOUINT64(a, b))) << 32) + UCHARPAIR_TOUINT32(c, d))
     245
     246#else // CPU(BIG_ENDIAN)
     247
     248#define CHARPAIR_TOUINT16(a, b) \\
     249    ((((uint16_t)(b)) << 8) + (uint16_t)(a))
     250#define CHARQUAD_TOUINT32(a, b, c, d) \\
     251    ((((uint32_t)(CHARPAIR_TOUINT16(c, d))) << 16) + CHARPAIR_TOUINT16(a, b))
     252#define UCHARPAIR_TOUINT32(a, b) \\
     253    ((((uint32_t)(b)) << 16) + (uint32_t)(a))
     254#define UCHARQUAD_TOUINT64(a, b, c, d) \\
     255    ((((uint64_t)(UCHARPAIR_TOUINT32(c, d))) << 32) + UCHARPAIR_TOUINT32(a, b))
     256
     257#endif // CPU(BIG_ENDIAN)
     258
     259
     260#define COMPARE_2CHARS(address, char1, char2) \\
     261    ((reinterpret_cast<const uint16_t*>(address))[0] == CHARPAIR_TOUINT16(char1, char2))
     262#define COMPARE_2UCHARS(address, char1, char2) \\
     263    ((reinterpret_cast<const uint32_t*>(address))[0] == UCHARPAIR_TOUINT32(char1, char2))
     264
     265#if CPU(X86_64)
     266
     267#define COMPARE_4CHARS(address, char1, char2, char3, char4) \\
     268    ((reinterpret_cast<const uint32_t*>(address))[0] == CHARQUAD_TOUINT32(char1, char2, char3, char4))
     269#define COMPARE_4UCHARS(address, char1, char2, char3, char4) \\
     270    ((reinterpret_cast<const uint64_t*>(address))[0] == UCHARQUAD_TOUINT64(char1, char2, char3, char4))
     271
     272#else // CPU(X86_64)
     273
     274#define COMPARE_4CHARS(address, char1, char2, char3, char4) \\
     275    (COMPARE_2CHARS(address, char1, char2) && COMPARE_2CHARS((address) + 2, char3, char4))
     276#define COMPARE_4UCHARS(address, char1, char2, char3, char4) \\
     277    (COMPARE_2UCHARS(address, char1, char2) && COMPARE_2UCHARS((address) + 2, char3, char4))
     278
     279#endif // CPU(X86_64)
     280
     281#endif // CPU(NEEDS_ALIGNED_ACCESS)
     282
     283#define COMPARE_3CHARS(address, char1, char2, char3) \\
     284    (COMPARE_2CHARS(address, char1, char2) && ((address)[2] == (char3)))
     285#define COMPARE_3UCHARS(address, char1, char2, char3) \\
     286    (COMPARE_2UCHARS(address, char1, char2) && ((address)[2] == (char3)))
     287#define COMPARE_5CHARS(address, char1, char2, char3, char4, char5) \\
     288    (COMPARE_4CHARS(address, char1, char2, char3, char4) && ((address)[4] == (char5)))
     289#define COMPARE_5UCHARS(address, char1, char2, char3, char4, char5) \\
     290    (COMPARE_4UCHARS(address, char1, char2, char3, char4) && ((address)[4] == (char5)))
     291#define COMPARE_6CHARS(address, char1, char2, char3, char4, char5, char6) \\
     292    (COMPARE_4CHARS(address, char1, char2, char3, char4) && COMPARE_2CHARS(address + 4, char5, char6))
     293#define COMPARE_6UCHARS(address, char1, char2, char3, char4, char5, char6) \\
     294    (COMPARE_4UCHARS(address, char1, char2, char3, char4) && COMPARE_2UCHARS(address + 4, char5, char6))
     295#define COMPARE_7CHARS(address, char1, char2, char3, char4, char5, char6, char7) \\
     296    (COMPARE_4CHARS(address, char1, char2, char3, char4) && COMPARE_4CHARS(address + 3, char4, char5, char6, char7))
     297#define COMPARE_7UCHARS(address, char1, char2, char3, char4, char5, char6, char7) \\
     298    (COMPARE_4UCHARS(address, char1, char2, char3, char4) && COMPARE_4UCHARS(address + 3, char4, char5, char6, char7))
     299#define COMPARE_8CHARS(address, char1, char2, char3, char4, char5, char6, char7, char8) \\
     300    (COMPARE_4CHARS(address, char1, char2, char3, char4) && COMPARE_4CHARS(address + 4, char5, char6, char7, char8))
     301#define COMPARE_8UCHARS(address, char1, char2, char3, char4, char5, char6, char7, char8) \\
     302    (COMPARE_4UCHARS(address, char1, char2, char3, char4) && COMPARE_4UCHARS(address + 4, char5, char6, char7, char8))
     303""")
    208304
    209305trie.printAsC()
Note: See TracChangeset for help on using the changeset viewer.