mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 502058: blacklist regexps for native compilation more efficiently and reliably, r=gal
This commit is contained in:
parent
55ec9409d5
commit
fd4086beac
@ -2617,6 +2617,7 @@ JS_SetErrorReporter(JSContext *cx, JSErrorReporter er);
|
||||
#define JSREG_MULTILINE 0x04 /* treat ^ and $ as begin and end of line */
|
||||
#define JSREG_STICKY 0x08 /* only match starting at lastIndex */
|
||||
#define JSREG_FLAT 0x10 /* parse as a flat regexp */
|
||||
#define JSREG_NOCOMPILE 0x20 /* do not try to compile to native code */
|
||||
|
||||
extern JS_PUBLIC_API(JSObject *)
|
||||
JS_NewRegExpObject(JSContext *cx, char *bytes, size_t length, uintN flags);
|
||||
|
@ -2388,8 +2388,10 @@ class RegExpNativeCompiler {
|
||||
* If the regexp is too long nanojit will assert when we
|
||||
* try to insert the guard record.
|
||||
*/
|
||||
if (re_length > 1024)
|
||||
if (re_length > 1024) {
|
||||
re->flags |= JSREG_NOCOMPILE;
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
this->cx = cx;
|
||||
/* At this point we have an empty fragment. */
|
||||
@ -2446,7 +2448,7 @@ class RegExpNativeCompiler {
|
||||
lirbuf->rewind();
|
||||
} else {
|
||||
if (!guard) insertGuard(re_chars, re_length);
|
||||
fragment->blacklist();
|
||||
re->flags |= JSREG_NOCOMPILE;
|
||||
}
|
||||
delete lirBufWriter;
|
||||
#ifdef NJ_VERBOSE
|
||||
@ -2469,8 +2471,6 @@ CompileRegExpToNative(JSContext* cx, JSRegExp* re, Fragment* fragment)
|
||||
RegExpNativeCompiler rc(re, &state, fragment);
|
||||
|
||||
JS_ASSERT(!fragment->code());
|
||||
JS_ASSERT(!fragment->isBlacklisted());
|
||||
|
||||
mark = JS_ARENA_MARK(&cx->tempPool);
|
||||
if (!CompileRegExpToAST(cx, NULL, re->source, re->flags, state)) {
|
||||
goto out;
|
||||
@ -2499,19 +2499,15 @@ GetNativeRegExp(JSContext* cx, JSRegExp* re)
|
||||
re->source->getCharsAndLength(re_chars, re_length);
|
||||
void* hash = HashRegExp(re->flags, re_chars, re_length);
|
||||
fragment = LookupNativeRegExp(cx, hash, re->flags, re_chars, re_length);
|
||||
if (fragment) {
|
||||
if (fragment->code())
|
||||
goto ok;
|
||||
if (fragment->isBlacklisted())
|
||||
return NULL;
|
||||
} else {
|
||||
if (!fragment) {
|
||||
fragment = fragmento->getAnchor(hash);
|
||||
fragment->lirbuf = JS_TRACE_MONITOR(cx).reLirBuf;
|
||||
fragment->root = fragment;
|
||||
}
|
||||
if (!fragment->code()) {
|
||||
if (!CompileRegExpToNative(cx, re, fragment))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!CompileRegExpToNative(cx, re, fragment))
|
||||
return NULL;
|
||||
ok:
|
||||
union { NIns *code; NativeRegExp func; } u;
|
||||
u.code = fragment->code();
|
||||
@ -3922,6 +3918,7 @@ MatchRegExp(REGlobalData *gData, REMatchState *x)
|
||||
|
||||
/* Run with native regexp if possible. */
|
||||
if (TRACING_ENABLED(gData->cx) &&
|
||||
!(gData->regexp->flags & JSREG_NOCOMPILE) &&
|
||||
(native = GetNativeRegExp(gData->cx, gData->regexp))) {
|
||||
gData->skipped = (ptrdiff_t) x->cp;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user