зеркало из https://github.com/mozilla/pjs.git
Bug 528414 - JS_IsRunning can be wrong. r=brendan.
--HG-- extra : rebase_source : 4fca5efd5f558c1b64b0e86580d2c42af7e61e34
This commit is contained in:
Родитель
c3a28c0d90
Коммит
994586ad1f
|
@ -48,6 +48,7 @@ PROGRAM = jsapi-tests$(BIN_SUFFIX)
|
|||
CPPSRCS = \
|
||||
tests.cpp \
|
||||
selfTest.cpp \
|
||||
testContexts.cpp \
|
||||
testDefineGetterSetterNonEnumerable.cpp \
|
||||
testIntString.cpp \
|
||||
testLookup.cpp \
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
#include "tests.h"
|
||||
|
||||
BEGIN_TEST(testContexts_IsRunning)
|
||||
{
|
||||
CHECK(JS_DefineFunction(cx, global, "chk", chk, 0, 0));
|
||||
EXEC("for (var i = 0; i < 9; i++) chk();");
|
||||
return true;
|
||||
}
|
||||
|
||||
static JSBool chk(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
JSRuntime *rt = JS_GetRuntime(cx);
|
||||
JSContext *acx = JS_NewContext(rt, 8192);
|
||||
if (!acx) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// acx should not be running
|
||||
bool ok = !JS_IsRunning(acx);
|
||||
if (!ok)
|
||||
JS_ReportError(cx, "Assertion failed: brand new context claims to be running");
|
||||
JS_DestroyContext(acx);
|
||||
return ok;
|
||||
}
|
||||
END_TEST(testContexts_IsRunning)
|
|
@ -5140,10 +5140,17 @@ JS_TriggerAllOperationCallbacks(JSRuntime *rt)
|
|||
JS_PUBLIC_API(JSBool)
|
||||
JS_IsRunning(JSContext *cx)
|
||||
{
|
||||
/* The use of cx->fp below is safe: if we're on trace, it is skipped. */
|
||||
/*
|
||||
* The use of cx->fp below is safe. Rationale: Here we don't care if the
|
||||
* interpreter state is stale. We just want to know if there *is* any
|
||||
* interpreter state.
|
||||
*/
|
||||
VOUCH_DOES_NOT_REQUIRE_STACK();
|
||||
|
||||
return JS_ON_TRACE(cx) || cx->fp != NULL;
|
||||
#ifdef JS_TRACER
|
||||
JS_ASSERT_IF(JS_TRACE_MONITOR(cx).tracecx == cx, cx->fp);
|
||||
#endif
|
||||
return cx->fp != NULL;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
|
|
Загрузка…
Ссылка в новой задаче