void JSCompartment::updateForDebugMode(JSContext *cx) { for (ThreadContextRange r(cx); !r.empty(); r.popFront()) { JSContext *cx = r.front(); if (cx->compartment == this) cx->updateJITEnabled(); } #ifdef JS_METHODJIT bool enabled = debugMode(); if (enabled) { JS_ASSERT(!hasScriptsOnStack(cx)); } else if (hasScriptsOnStack(cx)) { hasDebugModeCodeToDrop = true; return; } /* * Discard JIT code for any scripts that change debugMode. This assumes * that 'comp' is in the same thread as 'cx'. */ for (gc::CellIter i(cx, this, gc::FINALIZE_SCRIPT); !i.done(); i.next()) { JSScript *script = i.get<JSScript>(); if (script->debugMode != enabled) { mjit::ReleaseScriptCode(cx, script); script->debugMode = enabled; } } hasDebugModeCodeToDrop = false; #endif }