Changeset 243950 in webkit
- Timestamp:
- Apr 5, 2019, 3:08:26 PM (7 years ago)
- Location:
- tags/Safari-608.1.15/Source/JavaScriptCore
- Files:
-
- 9 edited
-
ChangeLog (modified) (1 diff)
-
runtime/RegExp.cpp (modified) (2 diffs)
-
runtime/RegExpInlines.h (modified) (1 diff)
-
yarr/YarrInterpreter.cpp (modified) (2 diffs)
-
yarr/YarrJIT.cpp (modified) (23 diffs)
-
yarr/YarrPattern.cpp (modified) (10 diffs)
-
yarr/YarrPattern.h (modified) (6 diffs)
-
yarr/create_regex_tables (modified) (2 diffs)
-
yarr/generateYarrUnicodePropertyTables.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tags/Safari-608.1.15/Source/JavaScriptCore/ChangeLog
r243949 r243950 1 2019-04-05 Kocsen Chung <kocsen_chung@apple.com> 2 3 Revert r243642. rdar://problem/49654398 4 1 5 2019-04-05 Kocsen Chung <kocsen_chung@apple.com> 2 6 -
tags/Safari-608.1.15/Source/JavaScriptCore/runtime/RegExp.cpp
r243642 r243950 386 386 interpreterOffsetVector[j] = -1; 387 387 388 interpreterResult = Yarr::interpret(m_regExpBytecode.get(), s, startOffset, reinterpret_cast<unsigned*>(interpreterOffsetVector));388 interpreterResult = Yarr::interpret(m_regExpBytecode.get(), s, startOffset, interpreterOffsetVector); 389 389 390 390 if (jitResult != interpreterResult) … … 403 403 404 404 if (jitResult != interpreterResult) { 405 dataLogF(" JIT result = %d, interpreted result = %d\n", jitResult, interpreterResult);405 dataLogF(" JIT result = %d, blah interpreted result = %d\n", jitResult, interpreterResult); 406 406 differences--; 407 407 } else { -
tags/Safari-608.1.15/Source/JavaScriptCore/runtime/RegExpInlines.h
r243642 r243950 182 182 183 183 #if ENABLE(YARR_JIT_DEBUG) 184 if (m_state == JITCode) { 185 byteCodeCompileIfNecessary(&vm); 186 matchCompareWithInterpreter(s, startOffset, offsetVector, result); 187 } 184 matchCompareWithInterpreter(s, startOffset, offsetVector, result); 188 185 #endif 189 186 } else -
tags/Safari-608.1.15/Source/JavaScriptCore/yarr/YarrInterpreter.cpp
r243642 r243950 429 429 return invert ? !match : match; 430 430 } 431 432 bool checkCharacterClassDontAdvanceInputForNonBMP(CharacterClass* characterClass, unsigned negativeInputOffset)433 {434 int readCharacter = characterClass->hasOnlyNonBMPCharacters() ? input.readSurrogatePairChecked(negativeInputOffset) : input.readChecked(negativeInputOffset);435 return testCharacterClass(characterClass, readCharacter);436 }437 431 438 432 bool tryConsumeBackReference(int matchBegin, int matchEnd, unsigned negativeInputOffset) … … 565 559 case QuantifierFixedCount: { 566 560 if (unicode) { 567 CharacterClass* charClass = term.atom.characterClass;568 561 backTrack->begin = input.getPos(); 569 562 unsigned matchAmount = 0; 570 563 for (matchAmount = 0; matchAmount < term.atom.quantityMaxCount; ++matchAmount) { 571 if (term.invert()) { 572 if (!checkCharacterClass(charClass, term.invert(), term.inputPosition - matchAmount)) { 573 input.setPos(backTrack->begin); 574 return false; 575 } 576 } else { 577 unsigned matchOffset = matchAmount * (charClass->hasOnlyNonBMPCharacters() ? 2 : 1); 578 if (!checkCharacterClassDontAdvanceInputForNonBMP(charClass, term.inputPosition - matchOffset)) { 579 input.setPos(backTrack->begin); 580 return false; 581 } 564 if (!checkCharacterClass(term.atom.characterClass, term.invert(), term.inputPosition - matchAmount)) { 565 input.setPos(backTrack->begin); 566 return false; 582 567 } 583 568 } -
tags/Safari-608.1.15/Source/JavaScriptCore/yarr/YarrJIT.cpp
r243949 r243950 73 73 static const RegisterID initialStart = ARM64Registers::x11; 74 74 static const RegisterID supplementaryPlanesBase = ARM64Registers::x12; 75 static const RegisterID leadingSurrogateTag= ARM64Registers::x13;76 static const RegisterID trailingSurrogateTag = ARM64Registers::x14;77 static const RegisterID endOfStringAddress= ARM64Registers::x15;75 static const RegisterID surrogateTagMask = ARM64Registers::x13; 76 static const RegisterID leadingSurrogateTag = ARM64Registers::x14; 77 static const RegisterID trailingSurrogateTag = ARM64Registers::x15; 78 78 79 79 static const RegisterID returnRegister = ARM64Registers::x0; 80 80 static const RegisterID returnRegister2 = ARM64Registers::x1; 81 81 82 const TrustedImm32 surrogateTagMask = TrustedImm32(0xfffffc00);83 82 #define HAVE_INITIAL_START_REG 84 83 #define JIT_UNICODE_EXPRESSIONS … … 145 144 static const RegisterID regUnicodeInputAndTrail = X86Registers::r13; 146 145 static const RegisterID leadingSurrogateTag = X86Registers::r14; 147 static const RegisterID endOfStringAddress= X86Registers::r15;146 static const RegisterID trailingSurrogateTag = X86Registers::r15; 148 147 149 148 static const RegisterID returnRegister = X86Registers::eax; … … 151 150 152 151 const TrustedImm32 supplementaryPlanesBase = TrustedImm32(0x10000); 153 const TrustedImm32 trailingSurrogateTag = TrustedImm32(0xdc00);154 152 const TrustedImm32 surrogateTagMask = TrustedImm32(0xfffffc00); 155 153 #define HAVE_INITIAL_START_REG … … 322 320 if ((term.type == PatternTerm::TypeCharacterClass) 323 321 && (term.quantityType == QuantifierFixedCount) 324 && (!m_decodeSurrogatePairs || ( term.characterClass->hasOneCharacterSize()&& !term.m_invert))322 && (!m_decodeSurrogatePairs || (!term.characterClass->m_hasNonBMPCharacters && !term.m_invert)) 325 323 && (nextTerm.type == PatternTerm::TypePatternCharacter) 326 324 && (nextTerm.quantityType == QuantifierFixedCount)) { … … 386 384 return; 387 385 } 388 389 386 JumpList unicodeFail; 390 387 if (charClass->m_matchesUnicode.size() || charClass->m_rangesUnicode.size()) { … … 451 448 unicodeFail.link(this); 452 449 } 453 454 #ifdef JIT_UNICODE_EXPRESSIONS455 void advanceIndexAfterCharacterClassTermMatch(const PatternTerm* term, JumpList& failures, const RegisterID character)456 {457 ASSERT(term->type == PatternTerm::TypeCharacterClass);458 459 if (term->characterClass->hasOneCharacterSize() && !term->invert())460 add32(TrustedImm32(term->characterClass->hasNonBMPCharacters() ? 2 : 1), index);461 else {462 add32(TrustedImm32(1), index);463 failures.append(atEndOfInput());464 Jump isBMPChar = branch32(LessThan, character, supplementaryPlanesBase);465 add32(TrustedImm32(1), index);466 isBMPChar.link(this);467 }468 }469 #endif470 450 471 451 // Jumps if input not available; will have (incorrectly) incremented already! … … 541 521 542 522 JumpList notUnicode; 543 544 523 load16Unaligned(regUnicodeInputAndTrail, resultReg); 545 524 and32(surrogateTagMask, resultReg, regT2); 546 525 notUnicode.append(branch32(NotEqual, regT2, leadingSurrogateTag)); 547 526 addPtr(TrustedImm32(2), regUnicodeInputAndTrail); 548 notUnicode.append(branchPtr(AboveOrEqual, regUnicodeInputAndTrail, endOfStringAddress)); 527 getEffectiveAddress(BaseIndex(input, length, TimesTwo), regT2); 528 notUnicode.append(branch32(AboveOrEqual, regUnicodeInputAndTrail, regT2)); 549 529 load16Unaligned(Address(regUnicodeInputAndTrail), regUnicodeInputAndTrail); 550 530 and32(surrogateTagMask, regUnicodeInputAndTrail, regT2); … … 1755 1735 } 1756 1736 #ifdef JIT_UNICODE_EXPRESSIONS 1757 if (m_decodeSurrogatePairs && (!term->characterClass->hasOneCharacterSize() || term->invert())) {1737 if (m_decodeSurrogatePairs) { 1758 1738 Jump isBMPChar = branch32(LessThan, character, supplementaryPlanesBase); 1759 1739 add32(TrustedImm32(1), index); … … 1789 1769 1790 1770 move(index, countRegister); 1791 1792 Checked<unsigned> scaledMaxCount = term->quantityMaxCount; 1793 1794 #ifdef JIT_UNICODE_EXPRESSIONS 1795 if (m_decodeSurrogatePairs && term->characterClass->hasOnlyNonBMPCharacters() && !term->invert()) 1796 scaledMaxCount *= 2; 1797 #endif 1798 sub32(Imm32(scaledMaxCount.unsafeGet()), countRegister); 1771 sub32(Imm32(term->quantityMaxCount.unsafeGet()), countRegister); 1799 1772 1800 1773 Label loop(this); 1801 1774 JumpList matchDest; 1802 readCharacter(m_checkedOffset - term->inputPosition - scaledMaxCount, character, countRegister);1775 readCharacter(m_checkedOffset - term->inputPosition - term->quantityMaxCount, character, countRegister); 1803 1776 // If we are matching the "any character" builtin class we only need to read the 1804 1777 // character and don't need to match as it will always succeed. … … 1814 1787 } 1815 1788 1789 add32(TrustedImm32(1), countRegister); 1816 1790 #ifdef JIT_UNICODE_EXPRESSIONS 1817 1791 if (m_decodeSurrogatePairs) { 1818 if (term->characterClass->hasOneCharacterSize() && !term->invert()) 1819 add32(TrustedImm32(term->characterClass->hasNonBMPCharacters() ? 2 : 1), countRegister); 1820 else { 1821 add32(TrustedImm32(1), countRegister); 1822 Jump isBMPChar = branch32(LessThan, character, supplementaryPlanesBase); 1823 op.m_jumps.append(atEndOfInput()); 1824 add32(TrustedImm32(1), countRegister); 1825 add32(TrustedImm32(1), index); 1826 isBMPChar.link(this); 1827 } 1828 } else 1829 #endif 1792 Jump isBMPChar = branch32(LessThan, character, supplementaryPlanesBase); 1793 op.m_jumps.append(atEndOfInput()); 1830 1794 add32(TrustedImm32(1), countRegister); 1795 add32(TrustedImm32(1), index); 1796 isBMPChar.link(this); 1797 } 1798 #endif 1831 1799 branch32(NotEqual, countRegister, index).linkTo(loop, this); 1832 1800 } … … 1844 1812 const RegisterID countRegister = regT1; 1845 1813 1846 if (m_decodeSurrogatePairs && (!term->characterClass->hasOneCharacterSize() || term->invert()))1814 if (m_decodeSurrogatePairs) 1847 1815 storeToFrame(index, term->frameLocation + BackTrackInfoCharacterClass::beginIndex()); 1848 1816 move(TrustedImm32(0), countRegister); … … 1858 1826 JumpList matchDest; 1859 1827 readCharacter(m_checkedOffset - term->inputPosition, character); 1860 // If we are matching the "any character" builtin class for non-unicode patterns,1861 // we only need to read thecharacter and don't need to match as it will always succeed.1828 // If we are matching the "any character" builtin class we only need to read the 1829 // character and don't need to match as it will always succeed. 1862 1830 if (!term->characterClass->m_anyCharacter) { 1863 1831 matchCharacterClass(character, matchDest, term->characterClass); … … 1867 1835 } 1868 1836 1837 add32(TrustedImm32(1), index); 1869 1838 #ifdef JIT_UNICODE_EXPRESSIONS 1870 if (m_decodeSurrogatePairs) 1871 advanceIndexAfterCharacterClassTermMatch(term, failures, character); 1872 else 1873 #endif 1839 if (m_decodeSurrogatePairs) { 1840 failures.append(atEndOfInput()); 1841 Jump isBMPChar = branch32(LessThan, character, supplementaryPlanesBase); 1874 1842 add32(TrustedImm32(1), index); 1843 isBMPChar.link(this); 1844 } 1845 #endif 1875 1846 add32(TrustedImm32(1), countRegister); 1876 1847 … … 1898 1869 m_backtrackingState.append(branchTest32(Zero, countRegister)); 1899 1870 sub32(TrustedImm32(1), countRegister); 1900 storeToFrame(countRegister, term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex());1901 1902 1871 if (!m_decodeSurrogatePairs) 1903 1872 sub32(TrustedImm32(1), index); 1904 else if (term->characterClass->hasOneCharacterSize() && !term->invert())1905 sub32(TrustedImm32(term->characterClass->hasNonBMPCharacters() ? 2 : 1), index);1906 1873 else { 1874 const RegisterID character = regT0; 1875 1876 loadFromFrame(term->frameLocation + BackTrackInfoCharacterClass::beginIndex(), index); 1907 1877 // Rematch one less 1908 const RegisterID character = regT0; 1909 1910 loadFromFrame(term->frameLocation + BackTrackInfoCharacterClass::beginIndex(), index); 1878 storeToFrame(countRegister, term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex()); 1911 1879 1912 1880 Label rematchLoop(this); … … 1938 1906 move(TrustedImm32(0), countRegister); 1939 1907 op.m_reentry = label(); 1940 if (m_decodeSurrogatePairs) { 1941 if (!term->characterClass->hasOneCharacterSize() || term->invert()) 1942 storeToFrame(index, term->frameLocation + BackTrackInfoCharacterClass::beginIndex()); 1943 storeToFrame(countRegister, term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex()); 1944 } 1908 if (m_decodeSurrogatePairs) 1909 storeToFrame(index, term->frameLocation + BackTrackInfoCharacterClass::beginIndex()); 1910 storeToFrame(countRegister, term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex()); 1945 1911 } 1946 1912 … … 1957 1923 m_backtrackingState.link(this); 1958 1924 1959 if (m_decodeSurrogatePairs) { 1960 if (!term->characterClass->hasOneCharacterSize() || term->invert()) 1961 loadFromFrame(term->frameLocation + BackTrackInfoCharacterClass::beginIndex(), index); 1962 loadFromFrame(term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex(), countRegister); 1963 } 1925 if (m_decodeSurrogatePairs) 1926 loadFromFrame(term->frameLocation + BackTrackInfoCharacterClass::beginIndex(), index); 1927 loadFromFrame(term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex(), countRegister); 1964 1928 1965 1929 nonGreedyFailures.append(atEndOfInput()); … … 1968 1932 JumpList matchDest; 1969 1933 readCharacter(m_checkedOffset - term->inputPosition, character); 1970 // If we are matching the "any character" builtin class for non-unicode patterns,1971 // we only need to read thecharacter and don't need to match as it will always succeed.1934 // If we are matching the "any character" builtin class we only need to read the 1935 // character and don't need to match as it will always succeed. 1972 1936 if (term->invert() || !term->characterClass->m_anyCharacter) { 1973 1937 matchCharacterClass(character, matchDest, term->characterClass); … … 1981 1945 } 1982 1946 1947 add32(TrustedImm32(1), index); 1983 1948 #ifdef JIT_UNICODE_EXPRESSIONS 1984 if (m_decodeSurrogatePairs) 1985 advanceIndexAfterCharacterClassTermMatch(term, nonGreedyFailures, character); 1986 else 1987 #endif 1949 if (m_decodeSurrogatePairs) { 1950 nonGreedyFailures.append(atEndOfInput()); 1951 Jump isBMPChar = branch32(LessThan, character, supplementaryPlanesBase); 1988 1952 add32(TrustedImm32(1), index); 1953 isBMPChar.link(this); 1954 } 1955 #endif 1989 1956 add32(TrustedImm32(1), countRegister); 1990 1957 … … 3734 3701 3735 3702 move(TrustedImm32(0xd800), leadingSurrogateTag); 3703 move(TrustedImm32(0xdc00), trailingSurrogateTag); 3736 3704 } 3737 3705 // The ABI doesn't guarantee the upper bits are zero on unsigned arguments, so clear them ourselves. … … 3767 3735 pushPair(framePointerRegister, linkRegister); 3768 3736 move(TrustedImm32(0x10000), supplementaryPlanesBase); 3737 move(TrustedImm32(0xfffffc00), surrogateTagMask); 3769 3738 move(TrustedImm32(0xd800), leadingSurrogateTag); 3770 3739 move(TrustedImm32(0xdc00), trailingSurrogateTag); … … 3847 3816 , m_decodeSurrogatePairs(m_charSize == Char16 && m_pattern.unicode()) 3848 3817 , m_unicodeIgnoreCase(m_pattern.unicode() && m_pattern.ignoreCase()) 3849 , m_fixedSizedAlternative(false)3850 3818 , m_canonicalMode(m_pattern.unicode() ? CanonicalMode::Unicode : CanonicalMode::UCS2) 3851 3819 #if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS) … … 3901 3869 generateFailReturn(); 3902 3870 hasInput.link(this); 3903 3904 #ifdef JIT_UNICODE_EXPRESSIONS3905 if (m_decodeSurrogatePairs)3906 getEffectiveAddress(BaseIndex(input, length, TimesTwo), endOfStringAddress);3907 #endif3908 3871 3909 3872 #if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS) … … 4201 4164 bool m_decodeSurrogatePairs; 4202 4165 bool m_unicodeIgnoreCase; 4203 bool m_fixedSizedAlternative;4204 4166 CanonicalMode m_canonicalMode; 4205 4167 #if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS) -
tags/Safari-608.1.15/Source/JavaScriptCore/yarr/YarrPattern.cpp
r243642 r243950 46 46 CharacterClassConstructor(bool isCaseInsensitive, CanonicalMode canonicalMode) 47 47 : m_isCaseInsensitive(isCaseInsensitive) 48 , m_hasNonBMPCharacters(false) 48 49 , m_anyCharacter(false) 49 , m_characterWidths(CharacterClassWidths::Unknown)50 50 , m_canonicalMode(canonicalMode) 51 51 { … … 58 58 m_matchesUnicode.clear(); 59 59 m_rangesUnicode.clear(); 60 m_hasNonBMPCharacters = false; 60 61 m_anyCharacter = false; 61 m_characterWidths = CharacterClassWidths::Unknown;62 62 } 63 63 … … 247 247 characterClass->m_matchesUnicode.swap(m_matchesUnicode); 248 248 characterClass->m_rangesUnicode.swap(m_rangesUnicode); 249 characterClass->m_hasNonBMPCharacters = hasNonBMPCharacters(); 249 250 characterClass->m_anyCharacter = anyCharacter(); 250 characterClass->m_characterWidths = characterWidths(); 251 251 252 m_hasNonBMPCharacters = false; 252 253 m_anyCharacter = false; 253 m_characterWidths = CharacterClassWidths::Unknown;254 254 255 255 return characterClass; … … 267 267 unsigned range = matches.size(); 268 268 269 m_characterWidths |= (U_IS_BMP(ch) ? CharacterClassWidths::HasBMPChars : CharacterClassWidths::HasNonBMPChars); 269 if (!U_IS_BMP(ch)) 270 m_hasNonBMPCharacters = true; 270 271 271 272 // binary chop, find position to insert char. … … 316 317 size_t end = ranges.size(); 317 318 318 if (U_IS_BMP(lo))319 m_characterWidths |= CharacterClassWidths::HasBMPChars;320 319 if (!U_IS_BMP(hi)) 321 m_ characterWidths |= CharacterClassWidths::HasNonBMPChars;320 m_hasNonBMPCharacters = true; 322 321 323 322 // Simple linear scan - I doubt there are that many ranges anyway... … … 410 409 bool hasNonBMPCharacters() 411 410 { 412 return m_characterWidths & CharacterClassWidths::HasNonBMPChars; 413 } 414 415 CharacterClassWidths characterWidths() 416 { 417 return m_characterWidths; 411 return m_hasNonBMPCharacters; 418 412 } 419 413 … … 424 418 425 419 bool m_isCaseInsensitive : 1; 420 bool m_hasNonBMPCharacters : 1; 426 421 bool m_anyCharacter : 1; 427 CharacterClassWidths m_characterWidths;428 429 422 CanonicalMode m_canonicalMode; 430 423 … … 844 837 term.frameLocation = currentCallFrameSize; 845 838 currentCallFrameSize += YarrStackSpaceForBackTrackInfoCharacterClass; 846 if (term.characterClass->hasOneCharacterSize() && !term.invert()) { 847 Checked<unsigned, RecordOverflow> tempCount = term.quantityMaxCount; 848 tempCount *= term.characterClass->hasNonBMPCharacters() ? 2 : 1; 849 if (tempCount.hasOverflowed()) 850 return ErrorCode::OffsetTooLarge; 851 currentInputPosition += tempCount; 852 } else { 853 currentInputPosition += term.quantityMaxCount; 854 alternative->m_hasFixedSize = false; 855 } 839 currentInputPosition += term.quantityMaxCount; 840 alternative->m_hasFixedSize = false; 856 841 } else 857 842 currentInputPosition += term.quantityMaxCount; … … 1334 1319 case TypeCharacterClass: 1335 1320 out.print("character class "); 1336 out.printf("inputPosition %u ", inputPosition);1337 1321 dumpCharacterClass(out, thisPattern, characterClass); 1338 1322 dumpQuantifier(out); … … 1478 1462 characterClass->m_ranges.append(CharacterRange(0x00, 0x7f)); 1479 1463 characterClass->m_rangesUnicode.append(CharacterRange(0x0080, 0x10ffff)); 1480 characterClass->m_ characterWidths = CharacterClassWidths::HasBothBMPAndNonBMP;1464 characterClass->m_hasNonBMPCharacters = true; 1481 1465 characterClass->m_anyCharacter = true; 1482 1466 return characterClass; -
tags/Safari-608.1.15/Source/JavaScriptCore/yarr/YarrPattern.h
r243642 r243950 53 53 }; 54 54 55 enum struct CharacterClassWidths : unsigned char {56 Unknown = 0x0,57 HasBMPChars = 0x1,58 HasNonBMPChars = 0x2,59 HasBothBMPAndNonBMP = HasBMPChars | HasNonBMPChars60 };61 62 inline CharacterClassWidths operator|(CharacterClassWidths lhs, CharacterClassWidths rhs)63 {64 return static_cast<CharacterClassWidths>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs));65 }66 67 inline bool operator&(CharacterClassWidths lhs, CharacterClassWidths rhs)68 {69 return static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs);70 }71 72 inline CharacterClassWidths& operator|=(CharacterClassWidths& lhs, CharacterClassWidths rhs)73 {74 lhs = lhs | rhs;75 return lhs;76 }77 78 55 struct CharacterClass { 79 56 WTF_MAKE_FAST_ALLOCATED; … … 84 61 CharacterClass() 85 62 : m_table(0) 86 , m_ characterWidths(CharacterClassWidths::Unknown)63 , m_hasNonBMPCharacters(false) 87 64 , m_anyCharacter(false) 88 65 { … … 90 67 CharacterClass(const char* table, bool inverted) 91 68 : m_table(table) 92 , m_characterWidths(CharacterClassWidths::Unknown)93 69 , m_tableInverted(inverted) 70 , m_hasNonBMPCharacters(false) 94 71 , m_anyCharacter(false) 95 72 { 96 73 } 97 CharacterClass(std::initializer_list<UChar32> matches, std::initializer_list<CharacterRange> ranges, std::initializer_list<UChar32> matchesUnicode, std::initializer_list<CharacterRange> rangesUnicode , CharacterClassWidths widths)74 CharacterClass(std::initializer_list<UChar32> matches, std::initializer_list<CharacterRange> ranges, std::initializer_list<UChar32> matchesUnicode, std::initializer_list<CharacterRange> rangesUnicode) 98 75 : m_matches(matches) 99 76 , m_ranges(ranges) … … 101 78 , m_rangesUnicode(rangesUnicode) 102 79 , m_table(0) 103 , m_characterWidths(widths)104 80 , m_tableInverted(false) 81 , m_hasNonBMPCharacters(false) 105 82 , m_anyCharacter(false) 106 83 { 107 84 } 108 85 109 bool hasNonBMPCharacters() { return m_characterWidths & CharacterClassWidths::HasNonBMPChars; }110 111 bool hasOneCharacterSize() { return m_characterWidths == CharacterClassWidths::HasBMPChars || m_characterWidths == CharacterClassWidths::HasNonBMPChars; }112 bool hasOnlyNonBMPCharacters() { return m_characterWidths == CharacterClassWidths::HasNonBMPChars; }113 114 86 Vector<UChar32> m_matches; 115 87 Vector<CharacterRange> m_ranges; … … 118 90 119 91 const char* m_table; 120 CharacterClassWidths m_characterWidths;121 92 bool m_tableInverted : 1; 93 bool m_hasNonBMPCharacters : 1; 122 94 bool m_anyCharacter : 1; 123 95 }; … … 249 221 } 250 222 251 bool invert() const223 bool invert() 252 224 { 253 225 return m_invert; -
tags/Safari-608.1.15/Source/JavaScriptCore/yarr/create_regex_tables
r243642 r243950 101 101 else: 102 102 function += (" auto characterClass = std::make_unique<CharacterClass>();\n") 103 hasBMPCharacters = False104 103 hasNonBMPCharacters = False 105 104 for (min, max) in ranges: 106 if min < 0x10000:107 hasBMPCharacters = True108 if max >= 0x10000:109 hasNonBMPCharacters = True110 105 if (min == max): 111 106 if (min > 127): … … 118 113 else: 119 114 function += (" characterClass->m_ranges.append(CharacterRange(0x%02x, 0x%02x));\n" % (min, max)) 120 function += (" characterClass->m_characterWidths = CharacterClassWidths::%s;\n" % (("Unknown", "HasBMPChars", "HasNonBMPChars", "HasBothBMPAndNonBMP")[int(hasNonBMPCharacters) * 2 + int(hasBMPCharacters)])) 115 if max >= 0x10000: 116 hasNonBMPCharacters = True 117 function += (" characterClass->m_hasNonBMPCharacters = %s;\n" % ("true" if hasNonBMPCharacters else "false")) 121 118 function += (" return characterClass;\n") 122 119 function += ("}\n\n") -
tags/Safari-608.1.15/Source/JavaScriptCore/yarr/generateYarrUnicodePropertyTables.py
r243642 r243950 36 36 37 37 header = """/* 38 * Copyright (C) 2017-201 9Apple Inc. All rights reserved.38 * Copyright (C) 2017-2018 Apple Inc. All rights reserved. 39 39 * 40 40 * Redistribution and use in source and binary forms, with or without … … 226 226 self.aliases = [] 227 227 self.index = len(PropertyData.allPropertyData) 228 self.hasBMPCharacters = False229 228 self.hasNonBMPCharacters = False 230 229 self.matches = [] … … 251 250 252 251 def addMatch(self, codePoint): 253 if codePoint <= MaxBMP: 254 self.hasBMPCharacters = True 255 else: 252 if codePoint > MaxBMP: 256 253 self.hasNonBMPCharacters = True 257 254 if codePoint <= lastASCIICodePoint: … … 285 282 286 283 def addRange(self, lowCodePoint, highCodePoint): 287 if lowCodePoint <= MaxBMP:288 self.hasBMPCharacters = True289 284 if highCodePoint > MaxBMP: 290 285 self.hasNonBMPCharacters = True … … 542 537 file.write(" std::initializer_list<CharacterRange>(") 543 538 self.dumpMatchData(file, 4, self.unicodeRanges, lambda file, range: (file.write("{{{0:0=#6x}, {1:0=#6x}}}".format(range[0], range[1])))) 544 file.write(") ,\n")545 546 file.write(" CharacterClassWidths::{});\n".format(("Unknown", "HasBMPChars", "HasNonBMPChars", "HasBothBMPAndNonBMP")[int(self.hasNonBMPCharacters) * 2 + int(self.hasBMPCharacters)]))539 file.write("));\n") 540 541 file.write(" characterClass->m_hasNonBMPCharacters = {};\n".format(("false", "true")[self.hasNonBMPCharacters])) 547 542 file.write(" return characterClass;\n}\n\n") 548 543
Note:
See TracChangeset
for help on using the changeset viewer.