if (ok) ok = js_InitRuntimeScriptState(cx);
js_NewContext(JSRuntime *rt, size_t stackChunkSize){    JSContext *cx;    JSBool ok, first;    cx = (JSContext *) malloc(sizeof *cx);    if (!cx)        return NULL;    memset(cx, 0, sizeof *cx);    cx->runtime = rt;#if JS_STACK_GROWTH_DIRECTION > 0    cx->stackLimit = (jsuword)-1;#endif#ifdef JS_THREADSAFE    js_InitContextForLocking(cx);#endif    JS_LOCK_GC(rt);    for (;;) {        first = (rt->contextList.next == &rt->contextList);        if (rt->state == JSRTS_UP) {            JS_ASSERT(!first);            break;        }        if (rt->state == JSRTS_DOWN) {            JS_ASSERT(first);            rt->state = JSRTS_LAUNCHING;            break;        }        JS_WAIT_CONDVAR(rt->stateChange, JS_NO_TIMEOUT);    }    JS_APPEND_LINK(&cx->links, &rt->contextList);    JS_UNLOCK_GC(rt);    /*     * First we do the infallible, every-time per-context initializations.     * Should a later, fallible initialization (js_InitRegExpStatics, e.g.,     * or the stuff under 'if (first)' below) fail, at least the version     * and arena-pools will be valid and safe to use (say, from the last GC     * done by js_DestroyContext).     */    cx->version = JSVERSION_DEFAULT;    cx->jsop_eq = JSOP_EQ;    cx->jsop_ne = JSOP_NE;    JS_InitArenaPool(&cx->stackPool, "stack", stackChunkSize, sizeof(jsval));    JS_InitArenaPool(&cx->tempPool, "temp", 1024, sizeof(jsdouble));#if JS_HAS_REGEXPS    if (!js_InitRegExpStatics(cx, &cx->regExpStatics)) {        js_DestroyContext(cx, JS_NO_GC);        return NULL;    }#endif#if JS_HAS_EXCEPTIONS    cx->throwing = JS_FALSE;#endif    /*     * If cx is the first context on this runtime, initialize well-known atoms,     * keywords, numbers, and strings.  If one of these steps should fail, the     * runtime will be left in a partially initialized state, with zeroes and     * nulls stored in the default-initialized remainder of the struct.  We'll     * clean the runtime up under js_DestroyContext, because cx will be "last"     * as well as "first".     */    if (first) {        ok = (rt->atomState.liveAtoms == 0)             ? js_InitAtomState(cx, &rt->atomState)             : js_InitPinnedAtoms(cx, &rt->atomState);        if (ok)            ok = js_InitScanner(cx);        if (ok)            ok = js_InitRuntimeNumberState(cx);        if (ok)            ok = js_InitRuntimeScriptState(cx);        if (ok)            ok = js_InitRuntimeStringState(cx);        if (!ok) {            js_DestroyContext(cx, JS_NO_GC);            return NULL;        }        JS_LOCK_GC(rt);        rt->state = JSRTS_UP;        JS_NOTIFY_ALL_CONDVAR(rt->stateChange);        JS_UNLOCK_GC(rt);    }    return cx;}