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.
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.
--- 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) {