Assign fresh loop table slots for all JSOP_HEADER opcodes in a script as it is thawed since the slots we stored there are likely stale by now.
authorAndreas Gal <gal@uci.edu>
Sat, 31 May 2008 18:12:39 -0700
changeset 17188 b46fcf1b955182486e98993738b5c9f1cf338099
parent 17187 1805b63c9f77b324f91468614f00ee6b9e4a4d71
child 17199 b8bab0f8f4a135802b3d614398b7aa973dce4412
push id1452
push usershaver@mozilla.com
push dateFri, 22 Aug 2008 00:08:22 +0000
treeherderautoland@d13bb0868596 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.1a1pre
Assign fresh loop table slots for all JSOP_HEADER opcodes in a script as it is thawed since the slots we stored there are likely stale by now.
js/src/jsscript.cpp
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -530,16 +530,29 @@ js_XDRScript(JSXDRState *xdr, JSScript *
     ok = JS_XDRBytes(xdr, (char *) code, length * sizeof(jsbytecode));
 
     if (code != script->code)
         JS_free(cx, code);
 
     if (!ok)
         goto error;
 
+    jsbytecode *pc = code;
+    jsbytecode *end = pc + length;
+    while (pc < end) {
+        JSOp op = (JSOp)*pc;
+        int len = js_CodeSpec[op].length;
+        if (!len)
+            goto error;
+        /* Assign a new loop table slot for every JSOP_HEADER opcode. */
+        if (op == JSOP_HEADER) 
+            SET_UINT24(pc + 1, js_AllocateLoopTableSlot(cx->runtime));
+        pc += len;
+    }
+    
     if (!JS_XDRBytes(xdr, (char *)notes, nsrcnotes * sizeof(jssrcnote)) ||
         !JS_XDRCStringOrNull(xdr, (char **)&script->filename) ||
         !JS_XDRUint32(xdr, &lineno) ||
         !JS_XDRUint32(xdr, &depth)) {
         goto error;
     }
 
     if (xdr->mode == JSXDR_ENCODE) {