summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/yarr/YarrJIT.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
commit32761a6cee1d0dee366b885b7b9c777e67885688 (patch)
treed6bec92bebfb216f4126356e55518842c2f476a1 /Source/JavaScriptCore/yarr/YarrJIT.cpp
parenta4e969f4965059196ca948db781e52f7cfebf19e (diff)
downloadWebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/JavaScriptCore/yarr/YarrJIT.cpp')
-rw-r--r--Source/JavaScriptCore/yarr/YarrJIT.cpp64
1 files changed, 30 insertions, 34 deletions
diff --git a/Source/JavaScriptCore/yarr/YarrJIT.cpp b/Source/JavaScriptCore/yarr/YarrJIT.cpp
index 89e2888a0..364a72dd8 100644
--- a/Source/JavaScriptCore/yarr/YarrJIT.cpp
+++ b/Source/JavaScriptCore/yarr/YarrJIT.cpp
@@ -1626,7 +1626,8 @@ class YarrGenerator : private MacroAssembler {
if (term->quantityType == QuantifierFixedCount)
inputOffset -= term->parentheses.disjunction->m_minimumSize;
if (inputOffset) {
- add32(Imm32(inputOffset), index, indexTemporary);
+ move(index, indexTemporary);
+ add32(Imm32(inputOffset), indexTemporary);
setSubpatternStart(indexTemporary, term->parentheses.subpatternId);
} else
setSubpatternStart(index, term->parentheses.subpatternId);
@@ -1638,14 +1639,16 @@ class YarrGenerator : private MacroAssembler {
const RegisterID indexTemporary = regT0;
ASSERT(term->quantityCount == 1);
+#ifndef NDEBUG
// Runtime ASSERT to make sure that the nested alternative handled the
// "no input consumed" check.
- if (!ASSERT_DISABLED && term->quantityType != QuantifierFixedCount && !term->parentheses.disjunction->m_minimumSize) {
+ if (term->quantityType != QuantifierFixedCount && !term->parentheses.disjunction->m_minimumSize) {
Jump pastBreakpoint;
pastBreakpoint = branch32(NotEqual, index, Address(stackPointerRegister, term->frameLocation * sizeof(void*)));
- abortWithReason(YARRNoInputConsumed);
+ breakpoint();
pastBreakpoint.link(this);
}
+#endif
// If the parenthese are capturing, store the ending index value to the
// captures array, offsetting as necessary.
@@ -1656,7 +1659,8 @@ class YarrGenerator : private MacroAssembler {
if (term->capture() && compileMode == IncludeSubpatterns) {
int inputOffset = term->inputPosition - m_checked;
if (inputOffset) {
- add32(Imm32(inputOffset), index, indexTemporary);
+ move(index, indexTemporary);
+ add32(Imm32(inputOffset), indexTemporary);
setSubpatternEnd(indexTemporary, term->parentheses.subpatternId);
} else
setSubpatternEnd(index, term->parentheses.subpatternId);
@@ -1691,16 +1695,16 @@ class YarrGenerator : private MacroAssembler {
}
case OpParenthesesSubpatternTerminalEnd: {
YarrOp& beginOp = m_ops[op.m_previousOp];
- if (!ASSERT_DISABLED) {
- PatternTerm* term = op.m_term;
-
- // Runtime ASSERT to make sure that the nested alternative handled the
- // "no input consumed" check.
- Jump pastBreakpoint;
- pastBreakpoint = branch32(NotEqual, index, Address(stackPointerRegister, term->frameLocation * sizeof(void*)));
- abortWithReason(YARRNoInputConsumed);
- pastBreakpoint.link(this);
- }
+#ifndef NDEBUG
+ PatternTerm* term = op.m_term;
+
+ // Runtime ASSERT to make sure that the nested alternative handled the
+ // "no input consumed" check.
+ Jump pastBreakpoint;
+ pastBreakpoint = branch32(NotEqual, index, Address(stackPointerRegister, term->frameLocation * sizeof(void*)));
+ breakpoint();
+ pastBreakpoint.link(this);
+#endif
// We know that the match is non-zero, we can accept it and
// loop back up to the head of the subpattern.
@@ -2342,7 +2346,7 @@ class YarrGenerator : private MacroAssembler {
m_ops.append(alternativeBeginOpCode);
m_ops.last().m_previousOp = notFound;
m_ops.last().m_term = term;
- Vector<std::unique_ptr<PatternAlternative>>& alternatives = term->parentheses.disjunction->m_alternatives;
+ Vector<OwnPtr<PatternAlternative>>& alternatives = term->parentheses.disjunction->m_alternatives;
for (unsigned i = 0; i < alternatives.size(); ++i) {
size_t lastOpIndex = m_ops.size() - 1;
@@ -2393,7 +2397,7 @@ class YarrGenerator : private MacroAssembler {
m_ops.append(OpSimpleNestedAlternativeBegin);
m_ops.last().m_previousOp = notFound;
m_ops.last().m_term = term;
- Vector<std::unique_ptr<PatternAlternative>>& alternatives = term->parentheses.disjunction->m_alternatives;
+ Vector<OwnPtr<PatternAlternative>>& alternatives = term->parentheses.disjunction->m_alternatives;
for (unsigned i = 0; i < alternatives.size(); ++i) {
size_t lastOpIndex = m_ops.size() - 1;
@@ -2467,7 +2471,7 @@ class YarrGenerator : private MacroAssembler {
// to return the failing result.
void opCompileBody(PatternDisjunction* disjunction)
{
- Vector<std::unique_ptr<PatternAlternative>>& alternatives = disjunction->m_alternatives;
+ Vector<OwnPtr<PatternAlternative>>& alternatives = disjunction->m_alternatives;
size_t currentAlternativeIndex = 0;
// Emit the 'once through' alternatives.
@@ -2580,14 +2584,10 @@ class YarrGenerator : private MacroAssembler {
#elif CPU(MIPS)
// Do nothing.
#endif
-
- store8(TrustedImm32(1), &m_vm->isExecutingInRegExpJIT);
}
void generateReturn()
{
- store8(TrustedImm32(0), &m_vm->isExecutingInRegExpJIT);
-
#if CPU(X86_64)
#if OS(WINDOWS)
// Store the return value in the allocated space pointed by rcx.
@@ -2616,9 +2616,8 @@ class YarrGenerator : private MacroAssembler {
}
public:
- YarrGenerator(VM* vm, YarrPattern& pattern, YarrCharSize charSize)
- : m_vm(vm)
- , m_pattern(pattern)
+ YarrGenerator(YarrPattern& pattern, YarrCharSize charSize)
+ : m_pattern(pattern)
, m_charSize(charSize)
, m_charScale(m_charSize == Char8 ? TimesOne: TimesTwo)
, m_shouldFallBack(false)
@@ -2646,8 +2645,11 @@ public:
initCallFrame();
+ // Compile the pattern to the internal 'YarrOp' representation.
opCompileBody(m_pattern.m_body);
+ // If we encountered anything we can't handle in the JIT code
+ // (e.g. backreferences) then return early.
if (m_shouldFallBack) {
jitObject.setFallBack(true);
return;
@@ -2656,12 +2658,8 @@ public:
generate();
backtrack();
- LinkBuffer linkBuffer(*vm, *this, REGEXP_CODE_ID, JITCompilationCanFail);
- if (linkBuffer.didFailToAllocate()) {
- jitObject.setFallBack(true);
- return;
- }
-
+ // Link & finalize the code.
+ LinkBuffer linkBuffer(*vm, this, REGEXP_CODE_ID);
m_backtrackingState.linkDataLabels(linkBuffer);
if (compileMode == MatchOnly) {
@@ -2679,8 +2677,6 @@ public:
}
private:
- VM* m_vm;
-
YarrPattern& m_pattern;
YarrCharSize m_charSize;
@@ -2713,9 +2709,9 @@ private:
void jitCompile(YarrPattern& pattern, YarrCharSize charSize, VM* vm, YarrCodeBlock& jitObject, YarrJITCompileMode mode)
{
if (mode == MatchOnly)
- YarrGenerator<MatchOnly>(vm, pattern, charSize).compile(vm, jitObject);
+ YarrGenerator<MatchOnly>(pattern, charSize).compile(vm, jitObject);
else
- YarrGenerator<IncludeSubpatterns>(vm, pattern, charSize).compile(vm, jitObject);
+ YarrGenerator<IncludeSubpatterns>(pattern, charSize).compile(vm, jitObject);
}
}}