mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 792797 - Handle interrupts in the Yarr interpreter. r=dvander
This commit is contained in:
parent
2bdd3dccb8
commit
3594bd8087
@ -550,11 +550,11 @@ RegExpShared::execute(JSContext *cx, StableCharPtr chars, size_t length,
|
||||
|
||||
#if ENABLE_YARR_JIT
|
||||
if (codeBlock.isFallBack())
|
||||
result = JSC::Yarr::interpret(bytecode, chars.get(), length, start, outputBuf);
|
||||
result = JSC::Yarr::interpret(cx, bytecode, chars.get(), length, start, outputBuf);
|
||||
else
|
||||
result = codeBlock.execute(chars.get(), start, length, (int *)outputBuf).start;
|
||||
#else
|
||||
result = JSC::Yarr::interpret(bytecode, chars.get(), length, start, outputBuf);
|
||||
result = JSC::Yarr::interpret(cx, bytecode, chars.get(), length, start, outputBuf);
|
||||
#endif
|
||||
|
||||
if (result == JSC::Yarr::offsetNoMatch)
|
||||
@ -609,7 +609,7 @@ RegExpShared::executeMatchOnly(JSContext *cx, StableCharPtr chars, size_t length
|
||||
return RegExpRunStatus_Error;
|
||||
|
||||
unsigned result =
|
||||
JSC::Yarr::interpret(bytecode, chars.get(), length, start, matches.rawBuf());
|
||||
JSC::Yarr::interpret(cx, bytecode, chars.get(), length, start, matches.rawBuf());
|
||||
|
||||
if (result == JSC::Yarr::offsetNoMatch)
|
||||
return RegExpRunStatus_Success_NotFound;
|
||||
|
@ -1120,6 +1120,10 @@ public:
|
||||
matchAgain:
|
||||
ASSERT(context->term < static_cast<int>(disjunction->terms.size()));
|
||||
|
||||
// Prevent jank resulting from getting stuck in Yarr for a long time.
|
||||
if (!JS_CHECK_OPERATION_LIMIT(this->cx))
|
||||
return JSRegExpErrorInternal;
|
||||
|
||||
switch (currentTerm().type) {
|
||||
case ByteTerm::TypeSubpatternBegin:
|
||||
MATCH_NEXT();
|
||||
@ -1278,6 +1282,10 @@ public:
|
||||
backtrack:
|
||||
ASSERT(context->term < static_cast<int>(disjunction->terms.size()));
|
||||
|
||||
// Prevent jank resulting from getting stuck in Yarr for a long time.
|
||||
if (!JS_CHECK_OPERATION_LIMIT(this->cx))
|
||||
return JSRegExpErrorInternal;
|
||||
|
||||
switch (currentTerm().type) {
|
||||
case ByteTerm::TypeSubpatternBegin:
|
||||
return JSRegExpNoMatch;
|
||||
@ -1444,8 +1452,9 @@ public:
|
||||
return output[0];
|
||||
}
|
||||
|
||||
Interpreter(BytecodePattern* pattern, unsigned* output, const CharType* input, unsigned length, unsigned start)
|
||||
: pattern(pattern)
|
||||
Interpreter(JSContext *cx, BytecodePattern* pattern, unsigned* output, const CharType* input, unsigned length, unsigned start)
|
||||
: cx(cx)
|
||||
, pattern(pattern)
|
||||
, output(output)
|
||||
, input(input, start, length)
|
||||
, allocatorPool(0)
|
||||
@ -1454,6 +1463,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
JSContext *cx;
|
||||
BytecodePattern* pattern;
|
||||
unsigned* output;
|
||||
InputStream input;
|
||||
@ -1938,23 +1948,23 @@ PassOwnPtr<BytecodePattern> byteCompile(YarrPattern& pattern, BumpPointerAllocat
|
||||
return ByteCompiler(pattern).compile(allocator);
|
||||
}
|
||||
|
||||
unsigned interpret(BytecodePattern* bytecode, const String& input, unsigned start, unsigned* output)
|
||||
unsigned interpret(JSContext *cx, BytecodePattern* bytecode, const String& input, unsigned start, unsigned* output)
|
||||
{
|
||||
#if YARR_8BIT_CHAR_SUPPORT
|
||||
if (input.is8Bit())
|
||||
return Interpreter<LChar>(bytecode, output, input.characters8(), input.length(), start).interpret();
|
||||
return Interpreter<LChar>(cx, bytecode, output, input.characters8(), input.length(), start).interpret();
|
||||
#endif
|
||||
return Interpreter<UChar>(bytecode, output, input.chars(), input.length(), start).interpret();
|
||||
return Interpreter<UChar>(cx, bytecode, output, input.chars(), input.length(), start).interpret();
|
||||
}
|
||||
|
||||
unsigned interpret(BytecodePattern* bytecode, const LChar* input, unsigned length, unsigned start, unsigned* output)
|
||||
unsigned interpret(JSContext *cx, BytecodePattern* bytecode, const LChar* input, unsigned length, unsigned start, unsigned* output)
|
||||
{
|
||||
return Interpreter<LChar>(bytecode, output, input, length, start).interpret();
|
||||
return Interpreter<LChar>(cx, bytecode, output, input, length, start).interpret();
|
||||
}
|
||||
|
||||
unsigned interpret(BytecodePattern* bytecode, const UChar* input, unsigned length, unsigned start, unsigned* output)
|
||||
unsigned interpret(JSContext *cx, BytecodePattern* bytecode, const UChar* input, unsigned length, unsigned start, unsigned* output)
|
||||
{
|
||||
return Interpreter<UChar>(bytecode, output, input, length, start).interpret();
|
||||
return Interpreter<UChar>(cx, bytecode, output, input, length, start).interpret();
|
||||
}
|
||||
|
||||
// These should be the same for both UChar & LChar.
|
||||
|
@ -26,6 +26,7 @@
|
||||
#ifndef YarrInterpreter_h
|
||||
#define YarrInterpreter_h
|
||||
|
||||
#include "jscntxt.h"
|
||||
#include "YarrPattern.h"
|
||||
|
||||
namespace WTF {
|
||||
@ -379,9 +380,9 @@ private:
|
||||
};
|
||||
|
||||
JS_EXPORT_PRIVATE PassOwnPtr<BytecodePattern> byteCompile(YarrPattern&, BumpPointerAllocator*);
|
||||
JS_EXPORT_PRIVATE unsigned interpret(BytecodePattern*, const String& input, unsigned start, unsigned* output);
|
||||
unsigned interpret(BytecodePattern*, const LChar* input, unsigned length, unsigned start, unsigned* output);
|
||||
unsigned interpret(BytecodePattern*, const UChar* input, unsigned length, unsigned start, unsigned* output);
|
||||
JS_EXPORT_PRIVATE unsigned interpret(JSContext *cx, BytecodePattern*, const String& input, unsigned start, unsigned* output);
|
||||
unsigned interpret(JSContext *cx, BytecodePattern*, const LChar* input, unsigned length, unsigned start, unsigned* output);
|
||||
unsigned interpret(JSContext *cx, BytecodePattern*, const UChar* input, unsigned length, unsigned start, unsigned* output);
|
||||
|
||||
} } // namespace JSC::Yarr
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user