Diff
Modified: tags/Safari-608.1.15/Source/_javascript_Core/ChangeLog (243949 => 243950)
--- tags/Safari-608.1.15/Source/_javascript_Core/ChangeLog 2019-04-05 22:08:22 UTC (rev 243949)
+++ tags/Safari-608.1.15/Source/_javascript_Core/ChangeLog 2019-04-05 22:08:26 UTC (rev 243950)
@@ -1,5 +1,9 @@
2019-04-05 Kocsen Chung <kocsen_ch...@apple.com>
+ Revert r243642. rdar://problem/49654398
+
+2019-04-05 Kocsen Chung <kocsen_ch...@apple.com>
+
Revert r243839. rdar://problem/49654398
2019-04-03 Yusuke Suzuki <ysuz...@apple.com>
Modified: tags/Safari-608.1.15/Source/_javascript_Core/runtime/RegExp.cpp (243949 => 243950)
--- tags/Safari-608.1.15/Source/_javascript_Core/runtime/RegExp.cpp 2019-04-05 22:08:22 UTC (rev 243949)
+++ tags/Safari-608.1.15/Source/_javascript_Core/runtime/RegExp.cpp 2019-04-05 22:08:26 UTC (rev 243950)
@@ -385,7 +385,7 @@
for (unsigned j = 0, i = 0; i < m_numSubpatterns + 1; j += 2, i++)
interpreterOffsetVector[j] = -1;
- interpreterResult = Yarr::interpret(m_regExpBytecode.get(), s, startOffset, reinterpret_cast<unsigned*>(interpreterOffsetVector));
+ interpreterResult = Yarr::interpret(m_regExpBytecode.get(), s, startOffset, interpreterOffsetVector);
if (jitResult != interpreterResult)
differences++;
@@ -402,7 +402,7 @@
dataLogF((segmentLen < 150) ? "\"%s\"\n" : "\"%148s...\"\n", s.utf8().data() + startOffset);
if (jitResult != interpreterResult) {
- dataLogF(" JIT result = %d, interpreted result = %d\n", jitResult, interpreterResult);
+ dataLogF(" JIT result = %d, blah interpreted result = %d\n", jitResult, interpreterResult);
differences--;
} else {
dataLogF(" Correct result = %d\n", jitResult);
Modified: tags/Safari-608.1.15/Source/_javascript_Core/runtime/RegExpInlines.h (243949 => 243950)
--- tags/Safari-608.1.15/Source/_javascript_Core/runtime/RegExpInlines.h 2019-04-05 22:08:22 UTC (rev 243949)
+++ tags/Safari-608.1.15/Source/_javascript_Core/runtime/RegExpInlines.h 2019-04-05 22:08:26 UTC (rev 243950)
@@ -181,10 +181,7 @@
}
#if ENABLE(YARR_JIT_DEBUG)
- if (m_state == JITCode) {
- byteCodeCompileIfNecessary(&vm);
- matchCompareWithInterpreter(s, startOffset, offsetVector, result);
- }
+ matchCompareWithInterpreter(s, startOffset, offsetVector, result);
#endif
} else
#endif
Modified: tags/Safari-608.1.15/Source/_javascript_Core/yarr/YarrInterpreter.cpp (243949 => 243950)
--- tags/Safari-608.1.15/Source/_javascript_Core/yarr/YarrInterpreter.cpp 2019-04-05 22:08:22 UTC (rev 243949)
+++ tags/Safari-608.1.15/Source/_javascript_Core/yarr/YarrInterpreter.cpp 2019-04-05 22:08:26 UTC (rev 243950)
@@ -428,12 +428,6 @@
bool match = testCharacterClass(characterClass, input.readChecked(negativeInputOffset));
return invert ? !match : match;
}
-
- bool checkCharacterClassDontAdvanceInputForNonBMP(CharacterClass* characterClass, unsigned negativeInputOffset)
- {
- int readCharacter = characterClass->hasOnlyNonBMPCharacters() ? input.readSurrogatePairChecked(negativeInputOffset) : input.readChecked(negativeInputOffset);
- return testCharacterClass(characterClass, readCharacter);
- }
bool tryConsumeBackReference(int matchBegin, int matchEnd, unsigned negativeInputOffset)
{
@@ -564,21 +558,12 @@
switch (term.atom.quantityType) {
case QuantifierFixedCount: {
if (unicode) {
- CharacterClass* charClass = term.atom.characterClass;
backTrack->begin = input.getPos();
unsigned matchAmount = 0;
for (matchAmount = 0; matchAmount < term.atom.quantityMaxCount; ++matchAmount) {
- if (term.invert()) {
- if (!checkCharacterClass(charClass, term.invert(), term.inputPosition - matchAmount)) {
- input.setPos(backTrack->begin);
- return false;
- }
- } else {
- unsigned matchOffset = matchAmount * (charClass->hasOnlyNonBMPCharacters() ? 2 : 1);
- if (!checkCharacterClassDontAdvanceInputForNonBMP(charClass, term.inputPosition - matchOffset)) {
- input.setPos(backTrack->begin);
- return false;
- }
+ if (!checkCharacterClass(term.atom.characterClass, term.invert(), term.inputPosition - matchAmount)) {
+ input.setPos(backTrack->begin);
+ return false;
}
}
Modified: tags/Safari-608.1.15/Source/_javascript_Core/yarr/YarrJIT.cpp (243949 => 243950)
--- tags/Safari-608.1.15/Source/_javascript_Core/yarr/YarrJIT.cpp 2019-04-05 22:08:22 UTC (rev 243949)
+++ tags/Safari-608.1.15/Source/_javascript_Core/yarr/YarrJIT.cpp 2019-04-05 22:08:26 UTC (rev 243950)
@@ -72,14 +72,13 @@
static const RegisterID regUnicodeInputAndTrail = ARM64Registers::x10;
static const RegisterID initialStart = ARM64Registers::x11;
static const RegisterID supplementaryPlanesBase = ARM64Registers::x12;
- static const RegisterID leadingSurrogateTag = ARM64Registers::x13;
- static const RegisterID trailingSurrogateTag = ARM64Registers::x14;
- static const RegisterID endOfStringAddress = ARM64Registers::x15;
+ static const RegisterID surrogateTagMask = ARM64Registers::x13;
+ static const RegisterID leadingSurrogateTag = ARM64Registers::x14;
+ static const RegisterID trailingSurrogateTag = ARM64Registers::x15;
static const RegisterID returnRegister = ARM64Registers::x0;
static const RegisterID returnRegister2 = ARM64Registers::x1;
- const TrustedImm32 surrogateTagMask = TrustedImm32(0xfffffc00);
#define HAVE_INITIAL_START_REG
#define JIT_UNICODE_EXPRESSIONS
#elif CPU(MIPS)
@@ -144,13 +143,12 @@
#endif
static const RegisterID regUnicodeInputAndTrail = X86Registers::r13;
static const RegisterID leadingSurrogateTag = X86Registers::r14;
- static const RegisterID endOfStringAddress = X86Registers::r15;
+ static const RegisterID trailingSurrogateTag = X86Registers::r15;
static const RegisterID returnRegister = X86Registers::eax;
static const RegisterID returnRegister2 = X86Registers::edx;
const TrustedImm32 supplementaryPlanesBase = TrustedImm32(0x10000);
- const TrustedImm32 trailingSurrogateTag = TrustedImm32(0xdc00);
const TrustedImm32 surrogateTagMask = TrustedImm32(0xfffffc00);
#define HAVE_INITIAL_START_REG
#define JIT_UNICODE_EXPRESSIONS
@@ -321,7 +319,7 @@
// We can move BMP only character classes after fixed character terms.
if ((term.type == PatternTerm::TypeCharacterClass)
&& (term.quantityType == QuantifierFixedCount)
- && (!m_decodeSurrogatePairs || (term.characterClass->hasOneCharacterSize() && !term.m_invert))
+ && (!m_decodeSurrogatePairs || (!term.characterClass->m_hasNonBMPCharacters && !term.m_invert))
&& (nextTerm.type == PatternTerm::TypePatternCharacter)
&& (nextTerm.quantityType == QuantifierFixedCount)) {
PatternTerm termCopy = term;
@@ -385,7 +383,6 @@
matchDest.append(branchTest8(charClass->m_tableInverted ? Zero : NonZero, tableEntry));
return;
}
-
JumpList unicodeFail;
if (charClass->m_matchesUnicode.size() || charClass->m_rangesUnicode.size()) {
JumpList isAscii;
@@ -451,23 +448,6 @@
unicodeFail.link(this);
}
-#ifdef JIT_UNICODE_EXPRESSIONS
- void advanceIndexAfterCharacterClassTermMatch(const PatternTerm* term, JumpList& failures, const RegisterID character)
- {
- ASSERT(term->type == PatternTerm::TypeCharacterClass);
-
- if (term->characterClass->hasOneCharacterSize() && !term->invert())
- add32(TrustedImm32(term->characterClass->hasNonBMPCharacters() ? 2 : 1), index);
- else {
- add32(TrustedImm32(1), index);
- failures.append(atEndOfInput());
- Jump isBMPChar = branch32(LessThan, character, supplementaryPlanesBase);
- add32(TrustedImm32(1), index);
- isBMPChar.link(this);
- }
- }
-#endif
-
// Jumps if input not available; will have (incorrectly) incremented already!
Jump jumpIfNoAvailableInput(unsigned countToCheck = 0)
{
@@ -540,12 +520,12 @@
ASSERT(m_charSize == Char16);
JumpList notUnicode;
-
load16Unaligned(regUnicodeInputAndTrail, resultReg);
and32(surrogateTagMask, resultReg, regT2);
notUnicode.append(branch32(NotEqual, regT2, leadingSurrogateTag));
addPtr(TrustedImm32(2), regUnicodeInputAndTrail);
- notUnicode.append(branchPtr(AboveOrEqual, regUnicodeInputAndTrail, endOfStringAddress));
+ getEffectiveAddress(BaseIndex(input, length, TimesTwo), regT2);
+ notUnicode.append(branch32(AboveOrEqual, regUnicodeInputAndTrail, regT2));
load16Unaligned(Address(regUnicodeInputAndTrail), regUnicodeInputAndTrail);
and32(surrogateTagMask, regUnicodeInputAndTrail, regT2);
notUnicode.append(branch32(NotEqual, regT2, trailingSurrogateTag));
@@ -1754,7 +1734,7 @@
}
}
#ifdef JIT_UNICODE_EXPRESSIONS
- if (m_decodeSurrogatePairs && (!term->characterClass->hasOneCharacterSize() || term->invert())) {
+ if (m_decodeSurrogatePairs) {
Jump isBMPChar = branch32(LessThan, character, supplementaryPlanesBase);
add32(TrustedImm32(1), index);
isBMPChar.link(this);
@@ -1788,18 +1768,11 @@
op.m_jumps.append(jumpIfNoAvailableInput());
move(index, countRegister);
+ sub32(Imm32(term->quantityMaxCount.unsafeGet()), countRegister);
- Checked<unsigned> scaledMaxCount = term->quantityMaxCount;
-
-#ifdef JIT_UNICODE_EXPRESSIONS
- if (m_decodeSurrogatePairs && term->characterClass->hasOnlyNonBMPCharacters() && !term->invert())
- scaledMaxCount *= 2;
-#endif
- sub32(Imm32(scaledMaxCount.unsafeGet()), countRegister);
-
Label loop(this);
JumpList matchDest;
- readCharacter(m_checkedOffset - term->inputPosition - scaledMaxCount, character, countRegister);
+ readCharacter(m_checkedOffset - term->inputPosition - term->quantityMaxCount, character, countRegister);
// If we are matching the "any character" builtin class we only need to read the
// character and don't need to match as it will always succeed.
if (term->invert() || !term->characterClass->m_anyCharacter) {
@@ -1813,21 +1786,16 @@
}
}
+ add32(TrustedImm32(1), countRegister);
#ifdef JIT_UNICODE_EXPRESSIONS
if (m_decodeSurrogatePairs) {
- if (term->characterClass->hasOneCharacterSize() && !term->invert())
- add32(TrustedImm32(term->characterClass->hasNonBMPCharacters() ? 2 : 1), countRegister);
- else {
- add32(TrustedImm32(1), countRegister);
- Jump isBMPChar = branch32(LessThan, character, supplementaryPlanesBase);
- op.m_jumps.append(atEndOfInput());
- add32(TrustedImm32(1), countRegister);
- add32(TrustedImm32(1), index);
- isBMPChar.link(this);
- }
- } else
+ Jump isBMPChar = branch32(LessThan, character, supplementaryPlanesBase);
+ op.m_jumps.append(atEndOfInput());
+ add32(TrustedImm32(1), countRegister);
+ add32(TrustedImm32(1), index);
+ isBMPChar.link(this);
+ }
#endif
- add32(TrustedImm32(1), countRegister);
branch32(NotEqual, countRegister, index).linkTo(loop, this);
}
void backtrackCharacterClassFixed(size_t opIndex)
@@ -1843,7 +1811,7 @@
const RegisterID character = regT0;
const RegisterID countRegister = regT1;
- if (m_decodeSurrogatePairs && (!term->characterClass->hasOneCharacterSize() || term->invert()))
+ if (m_decodeSurrogatePairs)
storeToFrame(index, term->frameLocation + BackTrackInfoCharacterClass::beginIndex());
move(TrustedImm32(0), countRegister);
@@ -1857,8 +1825,8 @@
} else {
JumpList matchDest;
readCharacter(m_checkedOffset - term->inputPosition, character);
- // If we are matching the "any character" builtin class for non-unicode patterns,
- // we only need to read the character and don't need to match as it will always succeed.
+ // If we are matching the "any character" builtin class we only need to read the
+ // character and don't need to match as it will always succeed.
if (!term->characterClass->m_anyCharacter) {
matchCharacterClass(character, matchDest, term->characterClass);
failures.append(jump());
@@ -1866,12 +1834,15 @@
matchDest.link(this);
}
+ add32(TrustedImm32(1), index);
#ifdef JIT_UNICODE_EXPRESSIONS
- if (m_decodeSurrogatePairs)
- advanceIndexAfterCharacterClassTermMatch(term, failures, character);
- else
+ if (m_decodeSurrogatePairs) {
+ failures.append(atEndOfInput());
+ Jump isBMPChar = branch32(LessThan, character, supplementaryPlanesBase);
+ add32(TrustedImm32(1), index);
+ isBMPChar.link(this);
+ }
#endif
- add32(TrustedImm32(1), index);
add32(TrustedImm32(1), countRegister);
if (term->quantityMaxCount != quantifyInfinite) {
@@ -1897,17 +1868,14 @@
loadFromFrame(term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex(), countRegister);
m_backtrackingState.append(branchTest32(Zero, countRegister));
sub32(TrustedImm32(1), countRegister);
- storeToFrame(countRegister, term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex());
-
if (!m_decodeSurrogatePairs)
sub32(TrustedImm32(1), index);
- else if (term->characterClass->hasOneCharacterSize() && !term->invert())
- sub32(TrustedImm32(term->characterClass->hasNonBMPCharacters() ? 2 : 1), index);
else {
- // Rematch one less
const RegisterID character = regT0;
loadFromFrame(term->frameLocation + BackTrackInfoCharacterClass::beginIndex(), index);
+ // Rematch one less
+ storeToFrame(countRegister, term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex());
Label rematchLoop(this);
readCharacter(m_checkedOffset - term->inputPosition, character);
@@ -1937,11 +1905,9 @@
move(TrustedImm32(0), countRegister);
op.m_reentry = label();
- if (m_decodeSurrogatePairs) {
- if (!term->characterClass->hasOneCharacterSize() || term->invert())
- storeToFrame(index, term->frameLocation + BackTrackInfoCharacterClass::beginIndex());
- storeToFrame(countRegister, term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex());
- }
+ if (m_decodeSurrogatePairs)
+ storeToFrame(index, term->frameLocation + BackTrackInfoCharacterClass::beginIndex());
+ storeToFrame(countRegister, term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex());
}
void backtrackCharacterClassNonGreedy(size_t opIndex)
@@ -1956,11 +1922,9 @@
m_backtrackingState.link(this);
- if (m_decodeSurrogatePairs) {
- if (!term->characterClass->hasOneCharacterSize() || term->invert())
- loadFromFrame(term->frameLocation + BackTrackInfoCharacterClass::beginIndex(), index);
- loadFromFrame(term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex(), countRegister);
- }
+ if (m_decodeSurrogatePairs)
+ loadFromFrame(term->frameLocation + BackTrackInfoCharacterClass::beginIndex(), index);
+ loadFromFrame(term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex(), countRegister);
nonGreedyFailures.append(atEndOfInput());
nonGreedyFailures.append(branch32(Equal, countRegister, Imm32(term->quantityMaxCount.unsafeGet())));
@@ -1967,8 +1931,8 @@
JumpList matchDest;
readCharacter(m_checkedOffset - term->inputPosition, character);
- // If we are matching the "any character" builtin class for non-unicode patterns,
- // we only need to read the character and don't need to match as it will always succeed.
+ // If we are matching the "any character" builtin class we only need to read the
+ // character and don't need to match as it will always succeed.
if (term->invert() || !term->characterClass->m_anyCharacter) {
matchCharacterClass(character, matchDest, term->characterClass);
@@ -1980,12 +1944,15 @@
}
}
+ add32(TrustedImm32(1), index);
#ifdef JIT_UNICODE_EXPRESSIONS
- if (m_decodeSurrogatePairs)
- advanceIndexAfterCharacterClassTermMatch(term, nonGreedyFailures, character);
- else
+ if (m_decodeSurrogatePairs) {
+ nonGreedyFailures.append(atEndOfInput());
+ Jump isBMPChar = branch32(LessThan, character, supplementaryPlanesBase);
+ add32(TrustedImm32(1), index);
+ isBMPChar.link(this);
+ }
#endif
- add32(TrustedImm32(1), index);
add32(TrustedImm32(1), countRegister);
jump(op.m_reentry);
@@ -3733,6 +3700,7 @@
push(X86Registers::r15);
move(TrustedImm32(0xd800), leadingSurrogateTag);
+ move(TrustedImm32(0xdc00), trailingSurrogateTag);
}
// The ABI doesn't guarantee the upper bits are zero on unsigned arguments, so clear them ourselves.
zeroExtend32ToPtr(index, index);
@@ -3766,6 +3734,7 @@
if (m_decodeSurrogatePairs) {
pushPair(framePointerRegister, linkRegister);
move(TrustedImm32(0x10000), supplementaryPlanesBase);
+ move(TrustedImm32(0xfffffc00), surrogateTagMask);
move(TrustedImm32(0xd800), leadingSurrogateTag);
move(TrustedImm32(0xdc00), trailingSurrogateTag);
}
@@ -3846,7 +3815,6 @@
, m_charSize(charSize)
, m_decodeSurrogatePairs(m_charSize == Char16 && m_pattern.unicode())
, m_unicodeIgnoreCase(m_pattern.unicode() && m_pattern.ignoreCase())
- , m_fixedSizedAlternative(false)
, m_canonicalMode(m_pattern.unicode() ? CanonicalMode::Unicode : CanonicalMode::UCS2)
#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
, m_containsNestedSubpatterns(false)
@@ -3901,11 +3869,6 @@
generateFailReturn();
hasInput.link(this);
-#ifdef JIT_UNICODE_EXPRESSIONS
- if (m_decodeSurrogatePairs)
- getEffectiveAddress(BaseIndex(input, length, TimesTwo), endOfStringAddress);
-#endif
-
#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
if (m_containsNestedSubpatterns)
move(TrustedImm32(matchLimit), remainingMatchCount);
@@ -4200,7 +4163,6 @@
bool m_decodeSurrogatePairs;
bool m_unicodeIgnoreCase;
- bool m_fixedSizedAlternative;
CanonicalMode m_canonicalMode;
#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
bool m_containsNestedSubpatterns;
Modified: tags/Safari-608.1.15/Source/_javascript_Core/yarr/YarrPattern.cpp (243949 => 243950)
--- tags/Safari-608.1.15/Source/_javascript_Core/yarr/YarrPattern.cpp 2019-04-05 22:08:22 UTC (rev 243949)
+++ tags/Safari-608.1.15/Source/_javascript_Core/yarr/YarrPattern.cpp 2019-04-05 22:08:26 UTC (rev 243950)
@@ -45,8 +45,8 @@
public:
CharacterClassConstructor(bool isCaseInsensitive, CanonicalMode canonicalMode)
: m_isCaseInsensitive(isCaseInsensitive)
+ , m_hasNonBMPCharacters(false)
, m_anyCharacter(false)
- , m_characterWidths(CharacterClassWidths::Unknown)
, m_canonicalMode(canonicalMode)
{
}
@@ -57,8 +57,8 @@
m_ranges.clear();
m_matchesUnicode.clear();
m_rangesUnicode.clear();
+ m_hasNonBMPCharacters = false;
m_anyCharacter = false;
- m_characterWidths = CharacterClassWidths::Unknown;
}
void append(const CharacterClass* other)
@@ -246,11 +246,11 @@
characterClass->m_ranges.swap(m_ranges);
characterClass->m_matchesUnicode.swap(m_matchesUnicode);
characterClass->m_rangesUnicode.swap(m_rangesUnicode);
+ characterClass->m_hasNonBMPCharacters = hasNonBMPCharacters();
characterClass->m_anyCharacter = anyCharacter();
- characterClass->m_characterWidths = characterWidths();
+ m_hasNonBMPCharacters = false;
m_anyCharacter = false;
- m_characterWidths = CharacterClassWidths::Unknown;
return characterClass;
}
@@ -266,7 +266,8 @@
unsigned pos = 0;
unsigned range = matches.size();
- m_characterWidths |= (U_IS_BMP(ch) ? CharacterClassWidths::HasBMPChars : CharacterClassWidths::HasNonBMPChars);
+ if (!U_IS_BMP(ch))
+ m_hasNonBMPCharacters = true;
// binary chop, find position to insert char.
while (range) {
@@ -315,10 +316,8 @@
{
size_t end = ranges.size();
- if (U_IS_BMP(lo))
- m_characterWidths |= CharacterClassWidths::HasBMPChars;
if (!U_IS_BMP(hi))
- m_characterWidths |= CharacterClassWidths::HasNonBMPChars;
+ m_hasNonBMPCharacters = true;
// Simple linear scan - I doubt there are that many ranges anyway...
// feel free to fix this with something faster (eg binary chop).
@@ -409,14 +408,9 @@
bool hasNonBMPCharacters()
{
- return m_characterWidths & CharacterClassWidths::HasNonBMPChars;
+ return m_hasNonBMPCharacters;
}
- CharacterClassWidths characterWidths()
- {
- return m_characterWidths;
- }
-
bool anyCharacter()
{
return m_anyCharacter;
@@ -423,9 +417,8 @@
}
bool m_isCaseInsensitive : 1;
+ bool m_hasNonBMPCharacters : 1;
bool m_anyCharacter : 1;
- CharacterClassWidths m_characterWidths;
-
CanonicalMode m_canonicalMode;
Vector<UChar32> m_matches;
@@ -843,16 +836,8 @@
} else if (m_pattern.unicode()) {
term.frameLocation = currentCallFrameSize;
currentCallFrameSize += YarrStackSpaceForBackTrackInfoCharacterClass;
- if (term.characterClass->hasOneCharacterSize() && !term.invert()) {
- Checked<unsigned, RecordOverflow> tempCount = term.quantityMaxCount;
- tempCount *= term.characterClass->hasNonBMPCharacters() ? 2 : 1;
- if (tempCount.hasOverflowed())
- return ErrorCode::OffsetTooLarge;
- currentInputPosition += tempCount;
- } else {
- currentInputPosition += term.quantityMaxCount;
- alternative->m_hasFixedSize = false;
- }
+ currentInputPosition += term.quantityMaxCount;
+ alternative->m_hasFixedSize = false;
} else
currentInputPosition += term.quantityMaxCount;
break;
@@ -1333,7 +1318,6 @@
break;
case TypeCharacterClass:
out.print("character class ");
- out.printf("inputPosition %u ", inputPosition);
dumpCharacterClass(out, thisPattern, characterClass);
dumpQuantifier(out);
if (quantityType != QuantifierFixedCount || thisPattern->unicode())
@@ -1477,7 +1461,7 @@
auto characterClass = std::make_unique<CharacterClass>();
characterClass->m_ranges.append(CharacterRange(0x00, 0x7f));
characterClass->m_rangesUnicode.append(CharacterRange(0x0080, 0x10ffff));
- characterClass->m_characterWidths = CharacterClassWidths::HasBothBMPAndNonBMP;
+ characterClass->m_hasNonBMPCharacters = true;
characterClass->m_anyCharacter = true;
return characterClass;
}
Modified: tags/Safari-608.1.15/Source/_javascript_Core/yarr/YarrPattern.h (243949 => 243950)
--- tags/Safari-608.1.15/Source/_javascript_Core/yarr/YarrPattern.h 2019-04-05 22:08:22 UTC (rev 243949)
+++ tags/Safari-608.1.15/Source/_javascript_Core/yarr/YarrPattern.h 2019-04-05 22:08:26 UTC (rev 243950)
@@ -52,29 +52,6 @@
}
};
-enum struct CharacterClassWidths : unsigned char {
- Unknown = 0x0,
- HasBMPChars = 0x1,
- HasNonBMPChars = 0x2,
- HasBothBMPAndNonBMP = HasBMPChars | HasNonBMPChars
-};
-
-inline CharacterClassWidths operator|(CharacterClassWidths lhs, CharacterClassWidths rhs)
-{
- return static_cast<CharacterClassWidths>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs));
-}
-
-inline bool operator&(CharacterClassWidths lhs, CharacterClassWidths rhs)
-{
- return static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs);
-}
-
-inline CharacterClassWidths& operator|=(CharacterClassWidths& lhs, CharacterClassWidths rhs)
-{
- lhs = lhs | rhs;
- return lhs;
-}
-
struct CharacterClass {
WTF_MAKE_FAST_ALLOCATED;
public:
@@ -83,34 +60,29 @@
// specified matches and ranges)
CharacterClass()
: m_table(0)
- , m_characterWidths(CharacterClassWidths::Unknown)
+ , m_hasNonBMPCharacters(false)
, m_anyCharacter(false)
{
}
CharacterClass(const char* table, bool inverted)
: m_table(table)
- , m_characterWidths(CharacterClassWidths::Unknown)
, m_tableInverted(inverted)
+ , m_hasNonBMPCharacters(false)
, m_anyCharacter(false)
{
}
- CharacterClass(std::initializer_list<UChar32> matches, std::initializer_list<CharacterRange> ranges, std::initializer_list<UChar32> matchesUnicode, std::initializer_list<CharacterRange> rangesUnicode, CharacterClassWidths widths)
+ CharacterClass(std::initializer_list<UChar32> matches, std::initializer_list<CharacterRange> ranges, std::initializer_list<UChar32> matchesUnicode, std::initializer_list<CharacterRange> rangesUnicode)
: m_matches(matches)
, m_ranges(ranges)
, m_matchesUnicode(matchesUnicode)
, m_rangesUnicode(rangesUnicode)
, m_table(0)
- , m_characterWidths(widths)
, m_tableInverted(false)
+ , m_hasNonBMPCharacters(false)
, m_anyCharacter(false)
{
}
- bool hasNonBMPCharacters() { return m_characterWidths & CharacterClassWidths::HasNonBMPChars; }
-
- bool hasOneCharacterSize() { return m_characterWidths == CharacterClassWidths::HasBMPChars || m_characterWidths == CharacterClassWidths::HasNonBMPChars; }
- bool hasOnlyNonBMPCharacters() { return m_characterWidths == CharacterClassWidths::HasNonBMPChars; }
-
Vector<UChar32> m_matches;
Vector<CharacterRange> m_ranges;
Vector<UChar32> m_matchesUnicode;
@@ -117,8 +89,8 @@
Vector<CharacterRange> m_rangesUnicode;
const char* m_table;
- CharacterClassWidths m_characterWidths;
bool m_tableInverted : 1;
+ bool m_hasNonBMPCharacters : 1;
bool m_anyCharacter : 1;
};
@@ -248,7 +220,7 @@
return PatternTerm(TypeAssertionWordBoundary, invert);
}
- bool invert() const
+ bool invert()
{
return m_invert;
}
Modified: tags/Safari-608.1.15/Source/_javascript_Core/yarr/create_regex_tables (243949 => 243950)
--- tags/Safari-608.1.15/Source/_javascript_Core/yarr/create_regex_tables 2019-04-05 22:08:22 UTC (rev 243949)
+++ tags/Safari-608.1.15/Source/_javascript_Core/yarr/create_regex_tables 2019-04-05 22:08:26 UTC (rev 243950)
@@ -100,13 +100,8 @@
function += (" auto characterClass = std::make_unique<CharacterClass>(_%sData, false);\n" % (name))
else:
function += (" auto characterClass = std::make_unique<CharacterClass>();\n")
- hasBMPCharacters = False
hasNonBMPCharacters = False
for (min, max) in ranges:
- if min < 0x10000:
- hasBMPCharacters = True
- if max >= 0x10000:
- hasNonBMPCharacters = True
if (min == max):
if (min > 127):
function += (" characterClass->m_matchesUnicode.append(0x%04x);\n" % min)
@@ -117,7 +112,9 @@
function += (" characterClass->m_rangesUnicode.append(CharacterRange(0x%04x, 0x%04x));\n" % (min, max))
else:
function += (" characterClass->m_ranges.append(CharacterRange(0x%02x, 0x%02x));\n" % (min, max))
- function += (" characterClass->m_characterWidths = CharacterClassWidths::%s;\n" % (("Unknown", "HasBMPChars", "HasNonBMPChars", "HasBothBMPAndNonBMP")[int(hasNonBMPCharacters) * 2 + int(hasBMPCharacters)]))
+ if max >= 0x10000:
+ hasNonBMPCharacters = True
+ function += (" characterClass->m_hasNonBMPCharacters = %s;\n" % ("true" if hasNonBMPCharacters else "false"))
function += (" return characterClass;\n")
function += ("}\n\n")
functions += function
Modified: tags/Safari-608.1.15/Source/_javascript_Core/yarr/generateYarrUnicodePropertyTables.py (243949 => 243950)
--- tags/Safari-608.1.15/Source/_javascript_Core/yarr/generateYarrUnicodePropertyTables.py 2019-04-05 22:08:22 UTC (rev 243949)
+++ tags/Safari-608.1.15/Source/_javascript_Core/yarr/generateYarrUnicodePropertyTables.py 2019-04-05 22:08:26 UTC (rev 243950)
@@ -35,7 +35,7 @@
from hasher import stringHash
header = """/*
-* Copyright (C) 2017-2019 Apple Inc. All rights reserved.
+* Copyright (C) 2017-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -225,7 +225,6 @@
self.name = name
self.aliases = []
self.index = len(PropertyData.allPropertyData)
- self.hasBMPCharacters = False
self.hasNonBMPCharacters = False
self.matches = []
self.ranges = []
@@ -250,9 +249,7 @@
return "createCharacterClass{}".format(self.index)
def addMatch(self, codePoint):
- if codePoint <= MaxBMP:
- self.hasBMPCharacters = True
- else:
+ if codePoint > MaxBMP:
self.hasNonBMPCharacters = True
if codePoint <= lastASCIICodePoint:
if (len(self.matches) and self.matches[-1] > codePoint) or (len(self.ranges) and self.ranges[-1][1] > codePoint):
@@ -284,8 +281,6 @@
self.unicodeMatches.append(codePoint)
def addRange(self, lowCodePoint, highCodePoint):
- if lowCodePoint <= MaxBMP:
- self.hasBMPCharacters = True
if highCodePoint > MaxBMP:
self.hasNonBMPCharacters = True
if highCodePoint <= lastASCIICodePoint:
@@ -541,9 +536,9 @@
file.write("),\n")
file.write(" std::initializer_list<CharacterRange>(")
self.dumpMatchData(file, 4, self.unicodeRanges, lambda file, range: (file.write("{{{0:0=#6x}, {1:0=#6x}}}".format(range[0], range[1]))))
- file.write("),\n")
+ file.write("));\n")
- file.write(" CharacterClassWidths::{});\n".format(("Unknown", "HasBMPChars", "HasNonBMPChars", "HasBothBMPAndNonBMP")[int(self.hasNonBMPCharacters) * 2 + int(self.hasBMPCharacters)]))
+ file.write(" characterClass->m_hasNonBMPCharacters = {};\n".format(("false", "true")[self.hasNonBMPCharacters]))
file.write(" return characterClass;\n}\n\n")
@classmethod