aboutsummaryrefslogtreecommitdiffstats
path: root/src/3rdparty/masm/yarr/YarrInterpreter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/masm/yarr/YarrInterpreter.cpp')
-rw-r--r--src/3rdparty/masm/yarr/YarrInterpreter.cpp59
1 files changed, 27 insertions, 32 deletions
diff --git a/src/3rdparty/masm/yarr/YarrInterpreter.cpp b/src/3rdparty/masm/yarr/YarrInterpreter.cpp
index 31603f6d34..f0312ea251 100644
--- a/src/3rdparty/masm/yarr/YarrInterpreter.cpp
+++ b/src/3rdparty/masm/yarr/YarrInterpreter.cpp
@@ -83,8 +83,8 @@ public:
static inline void popParenthesesDisjunctionContext(BackTrackInfoParentheses* backTrack)
{
- ASSERT(backTrack->matchAmount);
- ASSERT(backTrack->lastContext);
+ RELEASE_ASSERT(backTrack->matchAmount);
+ RELEASE_ASSERT(backTrack->lastContext);
backTrack->lastContext = backTrack->lastContext->next;
--backTrack->matchAmount;
}
@@ -111,8 +111,7 @@ public:
{
size_t size = sizeof(DisjunctionContext) - sizeof(uintptr_t) + disjunction->m_frameSize * sizeof(uintptr_t);
allocatorPool = allocatorPool->ensureCapacity(size);
- if (!allocatorPool)
- CRASH();
+ RELEASE_ASSERT(allocatorPool);
return new (allocatorPool->alloc(size)) DisjunctionContext();
}
@@ -161,8 +160,7 @@ public:
{
size_t size = sizeof(ParenthesesDisjunctionContext) - sizeof(unsigned) + (term.atom.parenthesesDisjunction->m_numSubpatterns << 1) * sizeof(unsigned) + sizeof(DisjunctionContext) - sizeof(uintptr_t) + disjunction->m_frameSize * sizeof(uintptr_t);
allocatorPool = allocatorPool->ensureCapacity(size);
- if (!allocatorPool)
- CRASH();
+ RELEASE_ASSERT(allocatorPool);
return new (allocatorPool->alloc(size)) ParenthesesDisjunctionContext(output, term);
}
@@ -207,8 +205,7 @@ public:
int readChecked(unsigned negativePositionOffest)
{
- if (pos < negativePositionOffest)
- CRASH();
+ RELEASE_ASSERT(pos >= negativePositionOffest);
unsigned p = pos - negativePositionOffest;
ASSERT(p < length);
return input[p];
@@ -264,8 +261,7 @@ public:
void uncheckInput(unsigned count)
{
- if (pos < count)
- CRASH();
+ RELEASE_ASSERT(pos >= count);
pos -= count;
}
@@ -276,8 +272,7 @@ public:
bool atEnd(unsigned negativePositionOffest)
{
- if (pos < negativePositionOffest)
- CRASH();
+ RELEASE_ASSERT(pos >= negativePositionOffest);
return (pos - negativePositionOffest) == length;
}
@@ -485,7 +480,7 @@ public:
return true;
}
- ASSERT_NOT_REACHED();
+ RELEASE_ASSERT_NOT_REACHED();
return false;
}
@@ -567,7 +562,7 @@ public:
return true;
}
- ASSERT_NOT_REACHED();
+ RELEASE_ASSERT_NOT_REACHED();
return false;
}
@@ -801,7 +796,7 @@ public:
{
// 'Terminal' parentheses are at the end of the regex, and as such a match past end
// should always be returned as a successful match - we should never backtrack to here.
- ASSERT_NOT_REACHED();
+ RELEASE_ASSERT_NOT_REACHED();
return false;
}
@@ -927,7 +922,7 @@ public:
return JSRegExpMatch;
}
- ASSERT_NOT_REACHED();
+ RELEASE_ASSERT_NOT_REACHED();
return JSRegExpErrorNoMatch;
}
@@ -1067,7 +1062,7 @@ public:
}
}
- ASSERT_NOT_REACHED();
+ RELEASE_ASSERT_NOT_REACHED();
return JSRegExpErrorNoMatch;
}
@@ -1273,7 +1268,7 @@ public:
}
// We should never fall-through to here.
- ASSERT_NOT_REACHED();
+ RELEASE_ASSERT_NOT_REACHED();
backtrack:
ASSERT(context->term < static_cast<int>(disjunction->terms.size()));
@@ -1282,7 +1277,7 @@ public:
case ByteTerm::TypeSubpatternBegin:
return JSRegExpNoMatch;
case ByteTerm::TypeSubpatternEnd:
- ASSERT_NOT_REACHED();
+ RELEASE_ASSERT_NOT_REACHED();
case ByteTerm::TypeBodyAlternativeBegin:
case ByteTerm::TypeBodyAlternativeDisjunction: {
@@ -1304,7 +1299,7 @@ public:
MATCH_NEXT();
}
case ByteTerm::TypeBodyAlternativeEnd:
- ASSERT_NOT_REACHED();
+ RELEASE_ASSERT_NOT_REACHED();
case ByteTerm::TypeAlternativeBegin:
case ByteTerm::TypeAlternativeDisjunction: {
@@ -1393,10 +1388,10 @@ public:
BACKTRACK();
case ByteTerm::TypeDotStarEnclosure:
- ASSERT_NOT_REACHED();
+ RELEASE_ASSERT_NOT_REACHED();
}
- ASSERT_NOT_REACHED();
+ RELEASE_ASSERT_NOT_REACHED();
return JSRegExpErrorNoMatch;
}
@@ -1425,8 +1420,7 @@ public:
output[i << 1] = offsetNoMatch;
allocatorPool = pattern->m_allocator->startAllocator();
- if (!allocatorPool)
- CRASH();
+ RELEASE_ASSERT(allocatorPool);
DisjunctionContext* context = allocDisjunctionContext(pattern->m_body.get());
@@ -1461,8 +1455,6 @@ private:
unsigned remainingMatchCount;
};
-
-
class ByteCompiler {
struct ParenthesesStackEntry {
unsigned beginTerm;
@@ -1718,17 +1710,20 @@ public:
unsigned subpatternId = parenthesesBegin.atom.subpatternId;
unsigned numSubpatterns = lastSubpatternId - subpatternId + 1;
- ByteDisjunction* parenthesesDisjunction = new ByteDisjunction(numSubpatterns, callFrameSize);
+ OwnPtr<ByteDisjunction> parenthesesDisjunction = adoptPtr(new ByteDisjunction(numSubpatterns, callFrameSize));
+
+ unsigned firstTermInParentheses = beginTerm + 1;
+ parenthesesDisjunction->terms.reserveInitialCapacity(endTerm - firstTermInParentheses + 2);
parenthesesDisjunction->terms.append(ByteTerm::SubpatternBegin());
- for (unsigned termInParentheses = beginTerm + 1; termInParentheses < endTerm; ++termInParentheses)
+ for (unsigned termInParentheses = firstTermInParentheses; termInParentheses < endTerm; ++termInParentheses)
parenthesesDisjunction->terms.append(m_bodyDisjunction->terms[termInParentheses]);
parenthesesDisjunction->terms.append(ByteTerm::SubpatternEnd());
m_bodyDisjunction->terms.shrink(beginTerm);
- m_allParenthesesInfo.append(parenthesesDisjunction);
- m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParenthesesSubpattern, subpatternId, parenthesesDisjunction, capture, inputPosition));
+ m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParenthesesSubpattern, subpatternId, parenthesesDisjunction.get(), capture, inputPosition));
+ m_allParenthesesInfo.append(parenthesesDisjunction.release());
m_bodyDisjunction->terms[beginTerm].atom.quantityCount = quantityCount.unsafeGet();
m_bodyDisjunction->terms[beginTerm].atom.quantityType = quantityType;
@@ -1815,7 +1810,7 @@ public:
for (unsigned alt = 0; alt < disjunction->m_alternatives.size(); ++alt) {
unsigned currentCountAlreadyChecked = inputCountAlreadyChecked;
- PatternAlternative* alternative = disjunction->m_alternatives[alt];
+ PatternAlternative* alternative = disjunction->m_alternatives[alt].get();
if (alt) {
if (disjunction == m_pattern.m_body)
@@ -1926,7 +1921,7 @@ private:
OwnPtr<ByteDisjunction> m_bodyDisjunction;
unsigned m_currentAlternativeIndex;
Vector<ParenthesesStackEntry> m_parenthesesStack;
- Vector<ByteDisjunction*> m_allParenthesesInfo;
+ Vector<OwnPtr<ByteDisjunction> > m_allParenthesesInfo;
};
PassOwnPtr<BytecodePattern> byteCompile(YarrPattern& pattern, BumpPointerAllocator* allocator)