summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/yarr
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
commitcd44dc59cdfc39534aef4d417e9f3c412e3be139 (patch)
tree8d89889ba95ed6ec9322e733846cc9cce9d7dff1 /Source/JavaScriptCore/yarr
parentd11f84f5b5cdc0d92a08af01b13472fdd5f9acb9 (diff)
downloadqtwebkit-cd44dc59cdfc39534aef4d417e9f3c412e3be139.tar.gz
Imported WebKit commit fce473cb4d55aa9fe9d0b0322a2fffecb731b961 (http://svn.webkit.org/repository/webkit/trunk@106560)
Diffstat (limited to 'Source/JavaScriptCore/yarr')
-rw-r--r--Source/JavaScriptCore/yarr/Yarr.h4
-rw-r--r--Source/JavaScriptCore/yarr/YarrInterpreter.cpp21
-rw-r--r--Source/JavaScriptCore/yarr/YarrJIT.cpp10
-rw-r--r--Source/JavaScriptCore/yarr/YarrPattern.h2
4 files changed, 27 insertions, 10 deletions
diff --git a/Source/JavaScriptCore/yarr/Yarr.h b/Source/JavaScriptCore/yarr/Yarr.h
index 501afac5f..3495fc7e4 100644
--- a/Source/JavaScriptCore/yarr/Yarr.h
+++ b/Source/JavaScriptCore/yarr/Yarr.h
@@ -62,8 +62,8 @@ enum YarrCharSize {
Char16
};
-PassOwnPtr<BytecodePattern> byteCompile(YarrPattern&, BumpPointerAllocator*);
-int interpret(BytecodePattern*, const UString& input, unsigned start, unsigned length, int* output);
+JS_EXPORT_PRIVATE PassOwnPtr<BytecodePattern> byteCompile(YarrPattern&, BumpPointerAllocator*);
+JS_EXPORT_PRIVATE int interpret(BytecodePattern*, const UString& input, unsigned start, unsigned length, int* output);
} } // namespace JSC::Yarr
diff --git a/Source/JavaScriptCore/yarr/YarrInterpreter.cpp b/Source/JavaScriptCore/yarr/YarrInterpreter.cpp
index b6bfb2c98..a452bb7f2 100644
--- a/Source/JavaScriptCore/yarr/YarrInterpreter.cpp
+++ b/Source/JavaScriptCore/yarr/YarrInterpreter.cpp
@@ -565,7 +565,10 @@ public:
if (matchEnd == -1)
return true;
- ASSERT((matchBegin == -1) || (matchBegin <= matchEnd));
+ if (matchBegin == -1)
+ return true;
+
+ ASSERT(matchBegin <= matchEnd);
if (matchBegin == matchEnd)
return true;
@@ -607,7 +610,11 @@ public:
int matchBegin = output[(term.atom.subpatternId << 1)];
int matchEnd = output[(term.atom.subpatternId << 1) + 1];
- ASSERT((matchBegin == -1) || (matchBegin <= matchEnd));
+
+ if (matchBegin == -1)
+ return false;
+
+ ASSERT(matchBegin <= matchEnd);
if (matchBegin == matchEnd)
return false;
@@ -1443,13 +1450,16 @@ public:
int interpret()
{
+ if (input.isNotAvailableInput(0))
+ return -1;
+
+ for (unsigned i = 0; i < pattern->m_body->m_numSubpatterns + 1; ++i)
+ output[i << 1] = -1;
+
allocatorPool = pattern->m_allocator->startAllocator();
if (!allocatorPool)
CRASH();
- for (unsigned i = 0; i < ((pattern->m_body->m_numSubpatterns + 1) << 1); ++i)
- output[i] = -1;
-
DisjunctionContext* context = allocDisjunctionContext(pattern->m_body.get());
JSRegExpResult result = matchDisjunction(pattern->m_body.get(), context, false);
@@ -1462,7 +1472,6 @@ public:
pattern->m_allocator->stopAllocator();
- // RegExp.cpp currently expects all error to be converted to -1.
ASSERT((result == JSRegExpMatch) == (output[0] != -1));
return output[0];
}
diff --git a/Source/JavaScriptCore/yarr/YarrJIT.cpp b/Source/JavaScriptCore/yarr/YarrJIT.cpp
index a3f467dc1..06faeaa1a 100644
--- a/Source/JavaScriptCore/yarr/YarrJIT.cpp
+++ b/Source/JavaScriptCore/yarr/YarrJIT.cpp
@@ -2477,6 +2477,14 @@ public:
{
generateEnter();
+ Jump hasInput = checkInput();
+ move(TrustedImm32(-1), returnRegister);
+ generateReturn();
+ hasInput.link(this);
+
+ for (unsigned i = 0; i < m_pattern.m_numSubpatterns + 1; ++i)
+ store32(TrustedImm32(-1), Address(output, (i << 1) * sizeof(int)));
+
if (!m_pattern.m_body->m_hasFixedSize)
store32(index, Address(output));
@@ -2497,7 +2505,7 @@ public:
backtrack();
// Link & finalize the code.
- LinkBuffer linkBuffer(*globalData, this);
+ LinkBuffer linkBuffer(*globalData, this, REGEXP_CODE_ID);
m_backtrackingState.linkDataLabels(linkBuffer);
if (m_charSize == Char8)
jitObject.set8BitCode(linkBuffer.finalizeCode());
diff --git a/Source/JavaScriptCore/yarr/YarrPattern.h b/Source/JavaScriptCore/yarr/YarrPattern.h
index 2cbb79586..a31deee67 100644
--- a/Source/JavaScriptCore/yarr/YarrPattern.h
+++ b/Source/JavaScriptCore/yarr/YarrPattern.h
@@ -316,7 +316,7 @@ struct TermChain {
};
struct YarrPattern {
- YarrPattern(const UString& pattern, bool ignoreCase, bool multiline, const char** error);
+ JS_EXPORT_PRIVATE YarrPattern(const UString& pattern, bool ignoreCase, bool multiline, const char** error);
~YarrPattern()
{