Fix recompilation under jsd and simplify frame searching (bug 609363, r=lw, a=b7+).
authorDavid Anderson <danderson@mozilla.com>
Wed, 03 Nov 2010 18:34:20 -0700
changeset 56854 f7016571b4726d9f465ef4b698f0e9e88adaa3ea
parent 56853 a9def7f8c835bc964f5c4c8a680fb3cfbc0e83f2
child 56855 297086a0fb61ac0d6262fc878286488e23d76fa3
child 56858 493fe7f156e50eaa94ff460ededaeb98f7fab60b
push id16714
push userrsayre@mozilla.com
push dateThu, 04 Nov 2010 07:07:14 +0000
treeherdermozilla-central@f7016571b472 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslw, b7
bugs609363
milestone2.0b8pre
first release with
nightly linux32
f7016571b472 / 4.0b8pre / 20101104025921 / files
nightly linux64
f7016571b472 / 4.0b8pre / 20101104030828 / files
nightly mac
f7016571b472 / 4.0b8pre / 20101104030743 / files
nightly win32
f7016571b472 / 4.0b8pre / 20101104041903 / files
nightly win64
f7016571b472 / 4.0b8pre / 20101104054656 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Fix recompilation under jsd and simplify frame searching (bug 609363, r=lw, a=b7+).
js/src/methodjit/Retcon.cpp
--- a/js/src/methodjit/Retcon.cpp
+++ b/js/src/methodjit/Retcon.cpp
@@ -117,41 +117,45 @@ Recompiler::Recompiler(JSContext *cx, JS
 bool
 Recompiler::recompile()
 {
     JS_ASSERT(script->hasJITCode());
 
     Vector<PatchableAddress> normalPatches(cx);
     Vector<PatchableAddress> ctorPatches(cx);
 
-    /* Scan the stack, saving the ncode elements of the frames. */
     JSStackFrame *firstCtorFrame = NULL;
     JSStackFrame *firstNormalFrame = NULL;
-    for (AllFramesIter i(cx); !i.done(); ++i) {
-        if (!firstCtorFrame && i.fp()->maybeScript() == script && i.fp()->isConstructing())
-            firstCtorFrame = i.fp();
-        else if (!firstNormalFrame && i.fp()->maybeScript() == script && !i.fp()->isConstructing())
-            firstNormalFrame = i.fp();
-        void **addr = i.fp()->addressOfNativeReturnAddress();
-        if (!*addr)
-            continue;
-        if (script->jitCtor && script->jitCtor->isValidCode(*addr)) {
-            if (!ctorPatches.append(findPatch(script->jitCtor, addr)))
-                return false;
-        } else if (script->jitNormal && script->jitNormal->isValidCode(*addr)) {
-            if (!normalPatches.append(findPatch(script->jitNormal, addr)))
-                return false;
-        }
-    }
 
-    /* Iterate over VMFrames saving the machine and scripted return. */
-    for (VMFrame *f = cx->jaegerCompartment()->activeFrame();
+    // Find all JIT'd stack frames to account for return addresses that will
+    // need to be patched after recompilation.
+    for (VMFrame *f = script->compartment->jaegerCompartment->activeFrame();
          f != NULL;
          f = f->previous) {
 
+        // Scan all frames owned by this VMFrame.
+        JSStackFrame *end = f->entryFp->prev();
+        for (JSStackFrame *fp = f->fp(); fp != end; fp = fp->prev()) {
+            // Remember the latest frame for each type of JIT'd code, so the
+            // compiler will have a frame to re-JIT from.
+            if (!firstCtorFrame && fp->script() == script && fp->isConstructing())
+                firstCtorFrame = fp;
+            else if (!firstNormalFrame && fp->script() == script && !fp->isConstructing())
+                firstNormalFrame = fp;
+
+            void **addr = fp->addressOfNativeReturnAddress();
+            if (script->jitCtor && script->jitCtor->isValidCode(*addr)) {
+                if (!ctorPatches.append(findPatch(script->jitCtor, addr)))
+                    return false;
+            } else if (script->jitNormal && script->jitNormal->isValidCode(*addr)) {
+                if (!normalPatches.append(findPatch(script->jitNormal, addr)))
+                    return false;
+            }
+        }
+
         void **addr = f->returnAddressLocation();
         if (script->jitCtor && script->jitCtor->isValidCode(*addr)) {
             if (!ctorPatches.append(findPatch(script->jitCtor, addr)))
                 return false;
         } else if (script->jitNormal && script->jitNormal->isValidCode(*addr)) {
             if (!normalPatches.append(findPatch(script->jitNormal, addr)))
                 return false;
         }