Bug 464138 - Intermittent JS regexp error on tinderbox. r=gal a=dsicore
authorDavid Mandelin <dmandelin@mozilla.com>
Tue, 11 Nov 2008 17:05:45 -0800
changeset 21572 1c473d3f87ea8a807c536d2d9ef760ca15e34f62
parent 21571 9ac7c363cf788616d233b43d6ecb9f14513b3975
child 21573 b80820b02087b9a9af18629abe9f52bb6fee9ce3
push id3589
push usermrbkap@mozilla.com
push dateWed, 12 Nov 2008 01:06:42 +0000
treeherdermozilla-central@1c473d3f87ea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgal, dsicore
bugs464138
milestone1.9.1b2pre
Bug 464138 - Intermittent JS regexp error on tinderbox. r=gal a=dsicore
js/src/jsregexp.cpp
--- a/js/src/jsregexp.cpp
+++ b/js/src/jsregexp.cpp
@@ -2150,17 +2150,19 @@ class RegExpNativeCompiler {
     JSBool compile(JSContext* cx) 
     {
         GuardRecord* guard;
         LIns* skip;
         LIns* start;
         bool oom = false;
         
         Fragmento* fragmento = JS_TRACE_MONITOR(cx).reFragmento;
-        fragment = fragmento->getAnchor(re);
+        fragment = fragmento->getLoop(re);
+        if (!fragment) 
+            fragment = fragmento->getAnchor(re);
         fragment->lirbuf = new (&gc) LirBuffer(fragmento, NULL);
         /* Scary: required to have the onDestroy method delete the lirbuf. */
         fragment->root = fragment;
         LirBuffer* lirbuf = fragment->lirbuf;
         LirBufWriter* lirb;
         if (lirbuf->outOmem()) goto fail2;
         /* FIXME Use bug 463260 smart pointer when available. */
         lir = lirb = new (&gc) LirBufWriter(lirbuf);
@@ -2825,19 +2827,20 @@ ProcessCharSet(REGlobalData *gData, RECh
     }
     return JS_TRUE;
 }
 
 void
 js_DestroyRegExp(JSContext *cx, JSRegExp *re)
 {
     if (JS_ATOMIC_DECREMENT(&re->nrefs) == 0) {
-#ifdef JS_TRACER
-        JS_TRACE_MONITOR(cx).reFragmento->clearFrag(re);
-#endif
+        /* Don't reuse this compiled code for some new regexp at same addr */
+        Fragment* fragment = JS_TRACE_MONITOR(cx).reFragmento->getLoop(re);
+        if (fragment) 
+            fragment->blacklist();
         if (re->classList) {
             uintN i;
             for (i = 0; i < re->classCount; i++) {
                 if (re->classList[i].converted)
                     JS_free(cx, re->classList[i].u.bits);
                 re->classList[i].u.bits = NULL;
             }
             JS_free(cx, re->classList);
@@ -3639,17 +3642,18 @@ MatchRegExp(REGlobalData *gData, REMatch
     const jschar *cp = x->cp;
     const jschar *cp2;
     uintN j;
 #ifdef JS_TRACER
     Fragment *fragment;
 
     /* Run with native regexp if possible. */
     if (((fragment = JS_TRACE_MONITOR(gData->cx).reFragmento->getLoop(gData->regexp)) != NULL)
-        && fragment->code()) {
+        && fragment->code()
+        && !fragment->isBlacklisted()) {
         union { NIns *code; REMatchState* (FASTCALL *func)(void*, void*); } u;
         u.code = fragment->code();
         REMatchState *lr;
         gData->skipped = (ptrdiff_t) x->cp;
 
         debug_only_v(printf("entering REGEXP trace at %s:%u@%u, code: %p\n",
                             gData->cx->fp->script->filename,
                             js_PCToLineNumber(gData->cx, gData->cx->fp->script, gData->cx->fp->regs->pc),