Merge
This commit is contained in:
275
js/src/jsapi.cpp
275
js/src/jsapi.cpp
@@ -88,6 +88,7 @@
|
||||
#include "prmjtime.h"
|
||||
#include "jsstaticcheck.h"
|
||||
#include "jsvector.h"
|
||||
#include "jswrapper.h"
|
||||
#include "jstypedarray.h"
|
||||
|
||||
#include "jsatominlines.h"
|
||||
@@ -191,6 +192,7 @@ JS_ConvertArgumentsVA(JSContext *cx, uintN argc, jsval *argv, const char *format
|
||||
JSObject *obj;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, ValueArray(argv - 2, argc + 2));
|
||||
sp = argv;
|
||||
required = JS_TRUE;
|
||||
while ((c = *format++) != '\0') {
|
||||
@@ -354,6 +356,7 @@ JS_ConvertValue(JSContext *cx, jsval v, JSType type, jsval *vp)
|
||||
jsdouble d;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, v);
|
||||
switch (type) {
|
||||
case JSTYPE_VOID:
|
||||
*vp = JSVAL_VOID;
|
||||
@@ -396,6 +399,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_ValueToObject(JSContext *cx, jsval v, JSObject **objp)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, v);
|
||||
Value objv;
|
||||
bool ok = !!js_ValueToObjectOrNull(cx, Valueify(v), &objv);
|
||||
*objp = objv.asObjectOrNull();
|
||||
@@ -406,6 +410,7 @@ JS_PUBLIC_API(JSFunction *)
|
||||
JS_ValueToFunction(JSContext *cx, jsval v)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, v);
|
||||
return js_ValueToFunction(cx, Valueify(&v), JSV2F_SEARCH_STACK);
|
||||
}
|
||||
|
||||
@@ -413,6 +418,7 @@ JS_PUBLIC_API(JSFunction *)
|
||||
JS_ValueToConstructor(JSContext *cx, jsval v)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, v);
|
||||
return js_ValueToFunction(cx, Valueify(&v), JSV2F_SEARCH_STACK);
|
||||
}
|
||||
|
||||
@@ -420,6 +426,7 @@ JS_PUBLIC_API(JSString *)
|
||||
JS_ValueToString(JSContext *cx, jsval v)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, v);
|
||||
return js_ValueToString(cx, Valueify(v));
|
||||
}
|
||||
|
||||
@@ -427,6 +434,7 @@ JS_PUBLIC_API(JSString *)
|
||||
JS_ValueToSource(JSContext *cx, jsval v)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, v);
|
||||
return js_ValueToSource(cx, Valueify(v));
|
||||
}
|
||||
|
||||
@@ -434,6 +442,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_ValueToNumber(JSContext *cx, jsval v, jsdouble *dp)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, v);
|
||||
|
||||
AutoValueRooter tvr(cx, Valueify(v));
|
||||
return ValueToNumber(cx, tvr.value(), dp);
|
||||
@@ -449,6 +458,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_ValueToECMAInt32(JSContext *cx, jsval v, int32 *ip)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, v);
|
||||
|
||||
AutoValueRooter tvr(cx, Valueify(v));
|
||||
return ValueToECMAInt32(cx, tvr.value(), (int32_t *)ip);
|
||||
@@ -458,6 +468,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_ValueToECMAUint32(JSContext *cx, jsval v, uint32 *ip)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, v);
|
||||
|
||||
AutoValueRooter tvr(cx, Valueify(v));
|
||||
return ValueToECMAUint32(cx, tvr.value(), (uint32_t *)ip);
|
||||
@@ -467,6 +478,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_ValueToInt32(JSContext *cx, jsval v, int32 *ip)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, v);
|
||||
|
||||
AutoValueRooter tvr(cx, Valueify(v));
|
||||
return ValueToInt32(cx, tvr.value(), (int32_t *)ip);
|
||||
@@ -476,6 +488,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_ValueToUint16(JSContext *cx, jsval v, uint16 *ip)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, v);
|
||||
|
||||
AutoValueRooter tvr(cx, Valueify(v));
|
||||
return ValueToUint16(cx, tvr.value(), (uint16_t *)ip);
|
||||
@@ -485,6 +498,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_ValueToBoolean(JSContext *cx, jsval v, JSBool *bp)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, v);
|
||||
*bp = js_ValueToBoolean(Valueify(v));
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -493,6 +507,7 @@ JS_PUBLIC_API(JSType)
|
||||
JS_TypeOfValue(JSContext *cx, jsval v)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, v);
|
||||
return TypeOfValue(cx, Valueify(v));
|
||||
}
|
||||
|
||||
@@ -507,12 +522,14 @@ JS_GetTypeName(JSContext *cx, JSType type)
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_StrictlyEqual(JSContext *cx, jsval v1, jsval v2)
|
||||
{
|
||||
assertSameCompartment(cx, v1, v2);
|
||||
return StrictlyEqual(cx, Valueify(v1), Valueify(v2));
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_SameValue(JSContext *cx, jsval v1, jsval v2)
|
||||
{
|
||||
assertSameCompartment(cx, v1, v2);
|
||||
return SameValue(Valueify(v1), Valueify(v2), cx);
|
||||
}
|
||||
|
||||
@@ -539,8 +556,10 @@ JSRuntime::JSRuntime()
|
||||
bool
|
||||
JSRuntime::init(uint32 maxbytes)
|
||||
{
|
||||
if (!(defaultCompartment = new JSCompartment(this)))
|
||||
if (!(defaultCompartment = new JSCompartment(this)) ||
|
||||
!defaultCompartment->init()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!js_InitGC(this, maxbytes) || !js_InitAtomState(this))
|
||||
return false;
|
||||
@@ -549,6 +568,8 @@ JSRuntime::init(uint32 maxbytes)
|
||||
if (!deflatedStringCache || !deflatedStringCache->init())
|
||||
return false;
|
||||
|
||||
wrapObjectCallback = js::TransparentObjectWrapper;
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
gcLock = JS_NEW_LOCK();
|
||||
if (!gcLock)
|
||||
@@ -757,13 +778,12 @@ JS_BeginRequest(JSContext *cx)
|
||||
#endif
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_EndRequest(JSContext *cx)
|
||||
{
|
||||
#ifdef JS_THREADSAFE
|
||||
static void
|
||||
StopRequest(JSContext *cx)
|
||||
{
|
||||
JSRuntime *rt;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
JS_ASSERT(CURRENT_THREAD_IS_ME(cx->thread));
|
||||
JS_ASSERT(cx->requestDepth > 0);
|
||||
JS_ASSERT(cx->outstandingRequests > 0);
|
||||
@@ -790,6 +810,21 @@ JS_EndRequest(JSContext *cx)
|
||||
}
|
||||
cx->requestDepth--;
|
||||
cx->outstandingRequests--;
|
||||
}
|
||||
#endif
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_EndRequest(JSContext *cx)
|
||||
{
|
||||
#ifdef JS_THREADSAFE
|
||||
/*
|
||||
* We do not allow to use JS_EndRequest to exit the request when there are
|
||||
* native frames on the stack that insist that the request must be on. But
|
||||
* we do allow to call the API if the request was suspended.
|
||||
*/
|
||||
JS_ASSERT_IF(cx->requestDepth == 1 && cx->outstandingRequests == 1,
|
||||
cx->checkRequestDepth == 0);
|
||||
StopRequest(cx);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -809,11 +844,16 @@ JS_SuspendRequest(JSContext *cx)
|
||||
{
|
||||
#ifdef JS_THREADSAFE
|
||||
jsrefcount saveDepth = cx->requestDepth;
|
||||
if (saveDepth == 0)
|
||||
return 0;
|
||||
|
||||
do {
|
||||
cx->outstandingRequests++; /* compensate for StopRequest */
|
||||
StopRequest(cx);
|
||||
} while (cx->requestDepth);
|
||||
|
||||
JS_THREAD_DATA(cx)->conservativeGC.enable();
|
||||
|
||||
while (cx->requestDepth) {
|
||||
cx->outstandingRequests++; /* compensate for JS_EndRequest */
|
||||
JS_EndRequest(cx);
|
||||
}
|
||||
return saveDepth;
|
||||
#else
|
||||
return 0;
|
||||
@@ -824,11 +864,16 @@ JS_PUBLIC_API(void)
|
||||
JS_ResumeRequest(JSContext *cx, jsrefcount saveDepth)
|
||||
{
|
||||
#ifdef JS_THREADSAFE
|
||||
JS_ASSERT(!cx->requestDepth);
|
||||
while (--saveDepth >= 0) {
|
||||
if (saveDepth == 0)
|
||||
return;
|
||||
|
||||
JS_THREAD_DATA(cx)->conservativeGC.disable();
|
||||
|
||||
JS_ASSERT(cx->outstandingRequests != 0);
|
||||
do {
|
||||
JS_BeginRequest(cx);
|
||||
cx->outstandingRequests--; /* compensate for JS_BeginRequest */
|
||||
}
|
||||
} while (--saveDepth != 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1023,6 +1068,39 @@ JS_GetImplementationVersion(void)
|
||||
return "JavaScript-C 1.8.0 pre-release 1 2007-10-03";
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSWrapObjectCallback)
|
||||
JS_SetWrapObjectCallback(JSContext *cx, JSWrapObjectCallback callback)
|
||||
{
|
||||
JSRuntime *rt = cx->runtime;
|
||||
JSWrapObjectCallback old = rt->wrapObjectCallback;
|
||||
rt->wrapObjectCallback = callback;
|
||||
return old;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSCrossCompartmentCall *)
|
||||
JS_EnterCrossCompartmentCall(JSContext *cx, JSObject *target)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
AutoCompartment *call = new AutoCompartment(cx, target);
|
||||
if (!call)
|
||||
return NULL;
|
||||
if (!call->enter()) {
|
||||
delete call;
|
||||
return NULL;
|
||||
}
|
||||
return reinterpret_cast<JSCrossCompartmentCall *>(call);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_LeaveCrossCompartmentCall(JSCrossCompartmentCall *call)
|
||||
{
|
||||
AutoCompartment *realcall = reinterpret_cast<AutoCompartment *>(call);
|
||||
CHECK_REQUEST(realcall->context);
|
||||
realcall->leave();
|
||||
delete realcall;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject *)
|
||||
JS_GetGlobalObject(JSContext *cx)
|
||||
{
|
||||
@@ -1033,7 +1111,9 @@ JS_PUBLIC_API(void)
|
||||
JS_SetGlobalObject(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
cx->globalObject = obj;
|
||||
cx->compartment = obj ? obj->getCompartment(cx) : cx->runtime->defaultCompartment;
|
||||
}
|
||||
|
||||
JSObject *
|
||||
@@ -1142,12 +1222,15 @@ out:
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_InitStandardClasses(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
JSAtom *atom;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
if (cx->globalObject)
|
||||
assertSameCompartment(cx, obj);
|
||||
else
|
||||
JS_SetGlobalObject(cx, obj);
|
||||
|
||||
/* Define a top-level property 'undefined' with the undefined value. */
|
||||
atom = cx->runtime->atomState.typeAtoms[JSTYPE_VOID];
|
||||
JSAtom *atom = cx->runtime->atomState.typeAtoms[JSTYPE_VOID];
|
||||
if (!obj->defineProperty(cx, ATOM_TO_JSID(atom), UndefinedTag(),
|
||||
PropertyStub, PropertyStub,
|
||||
JSPROP_PERMANENT | JSPROP_READONLY)) {
|
||||
@@ -1342,6 +1425,7 @@ JS_ResolveStandardClass(JSContext *cx, JSObject *obj, jsid id, JSBool *resolved)
|
||||
uintN i;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id);
|
||||
*resolved = JS_FALSE;
|
||||
|
||||
rt = cx->runtime;
|
||||
@@ -1441,6 +1525,7 @@ JS_EnumerateStandardClasses(JSContext *cx, JSObject *obj)
|
||||
uintN i;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
rt = cx->runtime;
|
||||
|
||||
/* Check whether we need to bind 'undefined' and define it if so. */
|
||||
@@ -1473,10 +1558,8 @@ NewIdArray(JSContext *cx, jsint length)
|
||||
|
||||
ida = (JSIdArray *)
|
||||
cx->calloc(offsetof(JSIdArray, vector) + length * sizeof(jsval));
|
||||
if (ida) {
|
||||
ida->self = ida;
|
||||
if (ida)
|
||||
ida->length = length;
|
||||
}
|
||||
return ida;
|
||||
}
|
||||
|
||||
@@ -1490,7 +1573,6 @@ SetIdArrayLength(JSContext *cx, JSIdArray *ida, jsint length)
|
||||
{
|
||||
JSIdArray *rida;
|
||||
|
||||
JS_ASSERT(ida->self == ida);
|
||||
rida = (JSIdArray *)
|
||||
JS_realloc(cx, ida,
|
||||
offsetof(JSIdArray, vector) + length * sizeof(jsval));
|
||||
@@ -1540,6 +1622,7 @@ JS_EnumerateResolvedStandardClasses(JSContext *cx, JSObject *obj, JSIdArray *ida
|
||||
JSObjectOp init;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, ida);
|
||||
rt = cx->runtime;
|
||||
if (ida) {
|
||||
i = ida->length;
|
||||
@@ -1600,6 +1683,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, JSObject **objp)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
return js_GetClassObject(cx, obj, key, objp);
|
||||
}
|
||||
|
||||
@@ -1636,6 +1720,7 @@ JS_GetScopeChain(JSContext *cx)
|
||||
JS_PUBLIC_API(JSObject *)
|
||||
JS_GetGlobalForObject(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
return obj->getGlobal();
|
||||
}
|
||||
|
||||
@@ -1667,6 +1752,7 @@ JS_GetGlobalForScopeChain(JSContext *cx)
|
||||
JS_PUBLIC_API(jsval)
|
||||
JS_ComputeThis(JSContext *cx, jsval *vp)
|
||||
{
|
||||
assertSameCompartment(cx, ValueArray(vp, 2));
|
||||
if (!ComputeThisFromVpInPlace(cx, Valueify(vp)))
|
||||
return JSVAL_NULL;
|
||||
return vp[1];
|
||||
@@ -1808,35 +1894,6 @@ JS_ClearNewbornRoots(JSContext *cx)
|
||||
JS_CLEAR_WEAK_ROOTS(&cx->weakRoots);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_EnterLocalRootScope(JSContext *cx)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
return js_EnterLocalRootScope(cx);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_LeaveLocalRootScope(JSContext *cx)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
js_LeaveLocalRootScope(cx);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_LeaveLocalRootScopeWithResult(JSContext *cx, jsval rval)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
if (JSVAL_IS_GCTHING(rval))
|
||||
js_LeaveLocalRootScopeWithResult(cx, JSVAL_TO_GCTHING(rval));
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_ForgetLocalRoot(JSContext *cx, void *thing)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
js_ForgetLocalRoot(cx, thing);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
@@ -2560,13 +2617,14 @@ JS_SetScriptStackQuota(JSContext *cx, size_t quota)
|
||||
JS_PUBLIC_API(void)
|
||||
JS_DestroyIdArray(JSContext *cx, JSIdArray *ida)
|
||||
{
|
||||
cx->free(ida->self);
|
||||
cx->free(ida);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_ValueToId(JSContext *cx, jsval v, jsid *idp)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, v);
|
||||
return ValueToId(cx, Valueify(v), idp);
|
||||
}
|
||||
|
||||
@@ -2575,6 +2633,7 @@ JS_IdToValue(JSContext *cx, jsid id, jsval *vp)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
*vp = IdToJsval(id);
|
||||
assertSameCompartment(cx, *vp);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
@@ -2614,6 +2673,7 @@ JS_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto,
|
||||
JSPropertySpec *static_ps, JSFunctionSpec *static_fs)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, parent_proto);
|
||||
return js_InitClass(cx, obj, parent_proto, Valueify(clasp),
|
||||
Valueify(constructor), nargs,
|
||||
ps, fs, static_ps, static_fs);
|
||||
@@ -2637,24 +2697,28 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_InstanceOf(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
return InstanceOf(cx, obj, Valueify(clasp), Valueify(argv));
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||
{
|
||||
assertSameCompartment(cx, obj, v);
|
||||
return js_HasInstance(cx, obj, Valueify(&v), bp);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void *)
|
||||
JS_GetPrivate(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
return obj->getPrivate();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_SetPrivate(JSContext *cx, JSObject *obj, void *data)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
obj->setPrivate(data);
|
||||
return true;
|
||||
}
|
||||
@@ -2673,6 +2737,7 @@ JS_GetPrototype(JSContext *cx, JSObject *obj)
|
||||
JSObject *proto;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
proto = obj->getProto();
|
||||
|
||||
/* Beware ref to dead object (we may be called from obj's finalizer). */
|
||||
@@ -2683,12 +2748,14 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_SetPrototype(JSContext *cx, JSObject *obj, JSObject *proto)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
return js_SetProtoOrParent(cx, obj, JSSLOT_PROTO, proto, JS_FALSE);
|
||||
assertSameCompartment(cx, obj, proto);
|
||||
return SetProto(cx, obj, proto, JS_FALSE);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject *)
|
||||
JS_GetParent(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
JSObject *parent = obj->getParent();
|
||||
|
||||
/* Beware ref to dead object (we may be called from obj's finalizer). */
|
||||
@@ -2699,7 +2766,9 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_SetParent(JSContext *cx, JSObject *obj, JSObject *parent)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
return js_SetProtoOrParent(cx, obj, JSSLOT_PARENT, parent, JS_FALSE);
|
||||
assertSameCompartment(cx, obj, parent);
|
||||
obj->setParent(parent);
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject *)
|
||||
@@ -2708,6 +2777,7 @@ JS_GetConstructor(JSContext *cx, JSObject *proto)
|
||||
Value cval;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, proto);
|
||||
{
|
||||
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED);
|
||||
|
||||
@@ -2726,6 +2796,7 @@ JS_GetConstructor(JSContext *cx, JSObject *proto)
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_GetObjectId(JSContext *cx, JSObject *obj, jsid *idp)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
*idp = OBJECT_TO_JSID(obj);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -2743,9 +2814,26 @@ JS_NewGlobalObject(JSContext *cx, JSClass *clasp)
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject *)
|
||||
JS_NewObject(JSContext *cx, JSClass *jsclasp, JSObject *proto, JSObject *parent)
|
||||
JS_NewCompartmentAndGlobalObject(JSContext *cx, JSClass *clasp, JSPrincipals *principals)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
JSCompartment *compartment = NewCompartment(cx, principals);
|
||||
if (!compartment)
|
||||
return NULL;
|
||||
|
||||
JSCompartment *saved = cx->compartment;
|
||||
cx->compartment = compartment;
|
||||
JSObject *obj = JS_NewGlobalObject(cx, clasp);
|
||||
cx->compartment = saved;
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject *)
|
||||
JS_NewObject(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, proto, parent);
|
||||
Class *clasp = Valueify(jsclasp);
|
||||
if (!clasp)
|
||||
clasp = &js_ObjectClass; /* default class is Object */
|
||||
@@ -2759,6 +2847,7 @@ JS_PUBLIC_API(JSObject *)
|
||||
JS_NewObjectWithGivenProto(JSContext *cx, JSClass *jsclasp, JSObject *proto, JSObject *parent)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, proto, parent);
|
||||
Class *clasp = Valueify(jsclasp);
|
||||
if (!clasp)
|
||||
clasp = &js_ObjectClass; /* default class is Object */
|
||||
@@ -2769,6 +2858,9 @@ JS_NewObjectWithGivenProto(JSContext *cx, JSClass *jsclasp, JSObject *proto, JSO
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_SealObject(JSContext *cx, JSObject *obj, JSBool deep)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
|
||||
JSScope *scope;
|
||||
JSIdArray *ida;
|
||||
uint32 nslots, i;
|
||||
@@ -2836,6 +2928,7 @@ JS_PUBLIC_API(JSObject *)
|
||||
JS_ConstructObject(JSContext *cx, JSClass *jsclasp, JSObject *proto, JSObject *parent)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, proto, parent);
|
||||
Class *clasp = Valueify(jsclasp);
|
||||
if (!clasp)
|
||||
clasp = &js_ObjectClass; /* default class is Object */
|
||||
@@ -2847,6 +2940,7 @@ JS_ConstructObjectWithArguments(JSContext *cx, JSClass *jsclasp, JSObject *proto
|
||||
JSObject *parent, uintN argc, jsval *argv)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, proto, parent, ValueArray(argv, argc));
|
||||
Class *clasp = Valueify(jsclasp);
|
||||
if (!clasp)
|
||||
clasp = &js_ObjectClass; /* default class is Object */
|
||||
@@ -2858,6 +2952,7 @@ LookupPropertyById(JSContext *cx, JSObject *obj, jsid id, uintN flags,
|
||||
JSObject **objp, JSProperty **propp)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id);
|
||||
|
||||
JSAutoResolveFlags rf(cx, flags);
|
||||
id = js_CheckForStringIndex(id);
|
||||
@@ -2938,6 +3033,7 @@ JS_LookupPropertyWithFlagsById(JSContext *cx, JSObject *obj, jsid id, uintN flag
|
||||
JSProperty *prop;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id);
|
||||
ok = obj->isNative()
|
||||
? js_LookupPropertyWithFlags(cx, obj, id, flags, objp, &prop) >= 0
|
||||
: obj->lookupProperty(cx, id, objp, &prop);
|
||||
@@ -2995,6 +3091,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_AlreadyHasOwnPropertyById(JSContext *cx, JSObject *obj, jsid id, JSBool *foundp)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id);
|
||||
|
||||
if (!obj->isNative()) {
|
||||
JSObject *obj2;
|
||||
@@ -3044,6 +3141,13 @@ DefinePropertyById(JSContext *cx, JSObject *obj, jsid id, const Value &value,
|
||||
uintN flags, intN tinyid)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id, value,
|
||||
(attrs & JSPROP_GETTER)
|
||||
? JS_FUNC_TO_DATA_PTR(JSObject *, getter)
|
||||
: NULL,
|
||||
(attrs & JSPROP_SETTER)
|
||||
? JS_FUNC_TO_DATA_PTR(JSObject *, setter)
|
||||
: NULL);
|
||||
|
||||
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED | JSRESOLVE_DECLARING);
|
||||
if (flags != 0 && obj->isNative()) {
|
||||
@@ -3137,6 +3241,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_DefineOwnProperty(JSContext *cx, JSObject *obj, jsid id, jsval descriptor, JSBool *bp)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id, descriptor);
|
||||
return js_DefineOwnProperty(cx, obj, id, Valueify(descriptor), bp);
|
||||
}
|
||||
|
||||
@@ -3147,6 +3252,7 @@ JS_DefineObject(JSContext *cx, JSObject *obj, const char *name, JSClass *jsclasp
|
||||
JSObject *nobj;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, proto);
|
||||
Class *clasp = Valueify(jsclasp);
|
||||
if (!clasp)
|
||||
clasp = &js_ObjectClass; /* default class is Object */
|
||||
@@ -3201,6 +3307,7 @@ JS_AliasProperty(JSContext *cx, JSObject *obj, const char *name, const char *ali
|
||||
JSScopeProperty *sprop;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
|
||||
JSAtom *atom = js_Atomize(cx, name, strlen(name), 0);
|
||||
if (!atom)
|
||||
@@ -3241,6 +3348,7 @@ JS_AliasElement(JSContext *cx, JSObject *obj, const char *name, jsint alias)
|
||||
JSBool ok;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
|
||||
JSAtom *atom = js_Atomize(cx, name, strlen(name), 0);
|
||||
if (!atom)
|
||||
@@ -3437,6 +3545,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_GetPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id);
|
||||
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED);
|
||||
return obj->getProperty(cx, id, Valueify(vp));
|
||||
}
|
||||
@@ -3465,6 +3574,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_GetMethodById(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, jsval *vp)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id);
|
||||
if (!js_GetMethod(cx, obj, id, JSGET_METHOD_BARRIER, Valueify(vp)))
|
||||
return JS_FALSE;
|
||||
if (objp)
|
||||
@@ -3483,6 +3593,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_SetPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id);
|
||||
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED | JSRESOLVE_ASSIGNING);
|
||||
return obj->setProperty(cx, id, Valueify(vp));
|
||||
}
|
||||
@@ -3511,6 +3622,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_DeletePropertyById2(JSContext *cx, JSObject *obj, jsid id, jsval *rval)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id);
|
||||
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED);
|
||||
return obj->deleteProperty(cx, id, Valueify(rval));
|
||||
}
|
||||
@@ -3560,6 +3672,7 @@ JS_PUBLIC_API(void)
|
||||
JS_ClearScope(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
|
||||
if (obj->map->ops->clear)
|
||||
obj->map->ops->clear(cx, obj);
|
||||
@@ -3577,9 +3690,11 @@ JS_PUBLIC_API(JSIdArray *)
|
||||
JS_Enumerate(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
|
||||
AutoValueVector props(cx);
|
||||
JSIdArray *ida;
|
||||
if (!GetPropertyNames(cx, obj, JSITER_OWNONLY, &ida))
|
||||
if (!GetPropertyNames(cx, obj, JSITER_OWNONLY, props) || !VectorToIdArray(cx, props, &ida))
|
||||
return false;
|
||||
for (size_t n = 0; n < size_t(ida->length); ++n)
|
||||
JS_ASSERT(js_CheckForStringIndex(ida->vector[n]) == ida->vector[n]);
|
||||
@@ -3647,6 +3762,7 @@ JS_NewPropertyIterator(JSContext *cx, JSObject *obj)
|
||||
JSIdArray *ida;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
iterobj = NewObject(cx, &prop_iter_class, NULL, obj);
|
||||
if (!iterobj)
|
||||
return NULL;
|
||||
@@ -3687,6 +3803,7 @@ JS_NextProperty(JSContext *cx, JSObject *iterobj, jsid *idp)
|
||||
JSIdArray *ida;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, iterobj);
|
||||
i = iterobj->fslots[JSSLOT_ITER_INDEX].asInt32();
|
||||
if (i < 0) {
|
||||
/* Native case: private data is a property tree node pointer. */
|
||||
@@ -3727,6 +3844,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_GetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, jsval *vp)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
return js_GetReservedSlot(cx, obj, index, Valueify(vp));
|
||||
}
|
||||
|
||||
@@ -3734,6 +3852,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_SetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, jsval v)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, v);
|
||||
return js_SetReservedSlot(cx, obj, index, Valueify(v));
|
||||
}
|
||||
|
||||
@@ -3742,12 +3861,14 @@ JS_NewArrayObject(JSContext *cx, jsint length, jsval *vector)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
/* NB: jsuint cast does ToUint32. */
|
||||
assertSameCompartment(cx, ValueArray(vector, vector ? (jsuint)length : 0));
|
||||
return js_NewArrayObject(cx, (jsuint)length, Valueify(vector));
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_IsArrayObject(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
return obj->wrappedObject(cx)->isArray();
|
||||
}
|
||||
|
||||
@@ -3755,6 +3876,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_GetArrayLength(JSContext *cx, JSObject *obj, jsuint *lengthp)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
return js_GetLengthProperty(cx, obj, lengthp);
|
||||
}
|
||||
|
||||
@@ -3762,6 +3884,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_SetArrayLength(JSContext *cx, JSObject *obj, jsuint length)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
return js_SetLengthProperty(cx, obj, length);
|
||||
}
|
||||
|
||||
@@ -3769,6 +3892,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_HasArrayLength(JSContext *cx, JSObject *obj, jsuint *lengthp)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
return js_HasLengthProperty(cx, obj, lengthp);
|
||||
}
|
||||
|
||||
@@ -3777,7 +3901,8 @@ JS_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
|
||||
jsval *vp, uintN *attrsp)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
return obj->checkAccess(cx, id, mode, Valueify(vp), attrsp);
|
||||
assertSameCompartment(cx, obj, id);
|
||||
return CheckAccess(cx, obj, id, mode, vp, attrsp);
|
||||
}
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
@@ -3838,6 +3963,7 @@ JS_NewFunction(JSContext *cx, JSNative native, uintN nargs, uintN flags,
|
||||
JSAtom *atom;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, parent);
|
||||
|
||||
if (!name) {
|
||||
atom = NULL;
|
||||
@@ -3853,6 +3979,7 @@ JS_PUBLIC_API(JSObject *)
|
||||
JS_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, parent); // XXX no funobj for now
|
||||
if (!parent) {
|
||||
if (cx->fp)
|
||||
parent = js_GetScopeChain(cx, cx->fp);
|
||||
@@ -4074,6 +4201,7 @@ JS_DefineFunctions(JSContext *cx, JSObject *obj, JSFunctionSpec *fs)
|
||||
JSFunction *fun;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
ctor = NULL;
|
||||
for (; fs->name; fs++) {
|
||||
flags = fs->flags;
|
||||
@@ -4124,6 +4252,7 @@ JS_DefineFunction(JSContext *cx, JSObject *obj, const char *name, JSNative call,
|
||||
uintN nargs, uintN attrs)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
JSAtom *atom = js_Atomize(cx, name, strlen(name), 0);
|
||||
return atom ? js_DefineFunction(cx, obj, atom, Valueify(call), nargs, attrs) : NULL;
|
||||
}
|
||||
@@ -4134,6 +4263,7 @@ JS_DefineUCFunction(JSContext *cx, JSObject *obj,
|
||||
uintN nargs, uintN attrs)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
JSAtom *atom = js_AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen), 0);
|
||||
return atom ? js_DefineFunction(cx, obj, atom, Valueify(call), nargs, attrs) : NULL;
|
||||
}
|
||||
@@ -4167,6 +4297,7 @@ JS_CompileUCScriptForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *prin
|
||||
const char *filename, uintN lineno)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, principals);
|
||||
|
||||
uint32 tcflags = JS_OPTIONS_TO_TCFLAGS(cx) | TCF_NEED_MUTABLE_SCRIPT;
|
||||
JSScript *script = Compiler::compileScript(cx, obj, NULL, principals, tcflags,
|
||||
@@ -4214,6 +4345,7 @@ JS_BufferIsCompilableUnit(JSContext *cx, JSObject *obj, const char *bytes, size_
|
||||
JSErrorReporter older;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
chars = js_InflateString(cx, bytes, &length);
|
||||
if (!chars)
|
||||
return JS_TRUE;
|
||||
@@ -4253,6 +4385,7 @@ JS_CompileFile(JSContext *cx, JSObject *obj, const char *filename)
|
||||
JSScript *script;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
if (!filename || strcmp(filename, "-") == 0) {
|
||||
fp = stdin;
|
||||
} else {
|
||||
@@ -4281,6 +4414,7 @@ JS_CompileFileHandleForPrincipals(JSContext *cx, JSObject *obj, const char *file
|
||||
JSScript *script;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, principals);
|
||||
tcflags = JS_OPTIONS_TO_TCFLAGS(cx);
|
||||
script = Compiler::compileScript(cx, obj, NULL, principals, tcflags,
|
||||
NULL, 0, file, filename, 1);
|
||||
@@ -4300,6 +4434,7 @@ JS_NewScriptObject(JSContext *cx, JSScript *script)
|
||||
JSObject *obj;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, script);
|
||||
if (!script)
|
||||
return NewObject(cx, &js_ScriptClass, NULL, NULL);
|
||||
|
||||
@@ -4331,6 +4466,7 @@ JS_PUBLIC_API(void)
|
||||
JS_DestroyScript(JSContext *cx, JSScript *script)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, script);
|
||||
js_DestroyScript(cx, script);
|
||||
}
|
||||
|
||||
@@ -4346,6 +4482,7 @@ JS_CompileUCFunctionForPrincipals(JSContext *cx, JSObject *obj,
|
||||
uintN i;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, principals);
|
||||
if (!name) {
|
||||
funAtom = NULL;
|
||||
} else {
|
||||
@@ -4451,6 +4588,7 @@ JS_DecompileScript(JSContext *cx, JSScript *script, const char *name, uintN inde
|
||||
JSString *str;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, script);
|
||||
jp = js_NewPrinter(cx, name, NULL,
|
||||
indent & ~JS_DONT_PRETTY_PRINT,
|
||||
!(indent & JS_DONT_PRETTY_PRINT),
|
||||
@@ -4469,6 +4607,7 @@ JS_PUBLIC_API(JSString *)
|
||||
JS_DecompileFunction(JSContext *cx, JSFunction *fun, uintN indent)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, fun);
|
||||
return js_DecompileToString(cx, "JS_DecompileFunction", fun,
|
||||
indent & ~JS_DONT_PRETTY_PRINT,
|
||||
!(indent & JS_DONT_PRETTY_PRINT),
|
||||
@@ -4479,6 +4618,7 @@ JS_PUBLIC_API(JSString *)
|
||||
JS_DecompileFunctionBody(JSContext *cx, JSFunction *fun, uintN indent)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, fun);
|
||||
return js_DecompileToString(cx, "JS_DecompileFunctionBody", fun,
|
||||
indent & ~JS_DONT_PRETTY_PRINT,
|
||||
!(indent & JS_DONT_PRETTY_PRINT),
|
||||
@@ -4491,6 +4631,7 @@ JS_ExecuteScript(JSContext *cx, JSObject *obj, JSScript *script, jsval *rval)
|
||||
JSBool ok;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, script);
|
||||
ok = Execute(cx, obj, script, NULL, 0, Valueify(rval));
|
||||
LAST_FRAME_CHECKS(cx, ok);
|
||||
return ok;
|
||||
@@ -4559,6 +4700,7 @@ JS_CallFunction(JSContext *cx, JSObject *obj, JSFunction *fun, uintN argc, jsval
|
||||
JSBool ok;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, fun, ValueArray(argv, argc));
|
||||
ok = InternalCall(cx, obj, ObjectTag(*fun), argc, Valueify(argv), Valueify(rval));
|
||||
LAST_FRAME_CHECKS(cx, ok);
|
||||
return ok;
|
||||
@@ -4569,6 +4711,7 @@ JS_CallFunctionName(JSContext *cx, JSObject *obj, const char *name, uintN argc,
|
||||
jsval *rval)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, ValueArray(argv, argc));
|
||||
|
||||
AutoValueRooter tvr(cx);
|
||||
JSAtom *atom = js_Atomize(cx, name, strlen(name), 0);
|
||||
@@ -4586,6 +4729,7 @@ JS_CallFunctionValue(JSContext *cx, JSObject *obj, jsval fval, uintN argc, jsval
|
||||
JSBool ok;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, fval, ValueArray(argv, argc));
|
||||
ok = InternalCall(cx, obj, Valueify(fval), argc, Valueify(argv), Valueify(rval));
|
||||
LAST_FRAME_CHECKS(cx, ok);
|
||||
return ok;
|
||||
@@ -4595,6 +4739,7 @@ JS_PUBLIC_API(JSObject *)
|
||||
JS_New(JSContext *cx, JSObject *ctor, uintN argc, jsval *argv)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, ctor, ValueArray(argv, argc));
|
||||
|
||||
// This is not a simple variation of JS_CallFunctionValue because JSOP_NEW
|
||||
// is not a simple variation of JSOP_CALL. We have to determine what class
|
||||
@@ -4609,7 +4754,7 @@ JS_New(JSContext *cx, JSObject *ctor, uintN argc, jsval *argv)
|
||||
vp[1].setNull();
|
||||
memcpy(vp + 2, argv, argc * sizeof(jsval));
|
||||
|
||||
bool ok = InvokeConstructor(cx, args, JS_TRUE);
|
||||
bool ok = InvokeConstructor(cx, args);
|
||||
JSObject *obj = ok ? vp[0].asObjectOrNull() : NULL;
|
||||
|
||||
LAST_FRAME_CHECKS(cx, ok);
|
||||
@@ -4664,11 +4809,12 @@ JS_IsRunning(JSContext *cx)
|
||||
#ifdef JS_TRACER
|
||||
JS_ASSERT_IF(JS_TRACE_MONITOR(cx).tracecx == cx, cx->fp);
|
||||
#endif
|
||||
return cx->fp != NULL;
|
||||
JSStackFrame *fp = cx->fp;
|
||||
while (fp && fp->isDummyFrame())
|
||||
fp = fp->down;
|
||||
return fp != NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_IsConstructing(JSContext *cx)
|
||||
{
|
||||
@@ -4876,12 +5022,14 @@ JS_GetStringLength(JSString *str)
|
||||
JS_PUBLIC_API(const char *)
|
||||
JS_GetStringBytesZ(JSContext *cx, JSString *str)
|
||||
{
|
||||
assertSameCompartment(cx, str);
|
||||
return js_GetStringBytes(cx, str);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(const jschar *)
|
||||
JS_GetStringCharsZ(JSContext *cx, JSString *str)
|
||||
{
|
||||
assertSameCompartment(cx, str);
|
||||
return js_UndependString(cx, str);
|
||||
}
|
||||
|
||||
@@ -4967,6 +5115,7 @@ JS_Stringify(JSContext *cx, jsval *vp, JSObject *replacer, jsval space,
|
||||
JSONWriteCallback callback, void *data)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, replacer, space);
|
||||
JSCharBuffer cb(cx);
|
||||
if (!js_Stringify(cx, vp, replacer, space, cb))
|
||||
return false;
|
||||
@@ -4977,6 +5126,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_TryJSON(JSContext *cx, jsval *vp)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, *vp);
|
||||
return js_TryJSON(cx, vp);
|
||||
}
|
||||
|
||||
@@ -4998,6 +5148,7 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_FinishJSONParse(JSContext *cx, JSONParser *jp, jsval reviver)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, reviver);
|
||||
return js_FinishJSONParse(cx, jp, reviver);
|
||||
}
|
||||
|
||||
@@ -5159,6 +5310,8 @@ JS_SetRegExpInput(JSContext *cx, JSString *input, JSBool multiline)
|
||||
JSRegExpStatics *res;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, input);
|
||||
|
||||
/* No locking required, cx is thread-private and input must be live. */
|
||||
res = &cx->regExpStatics;
|
||||
res->clearRoots();
|
||||
@@ -5218,6 +5371,7 @@ JS_PUBLIC_API(void)
|
||||
JS_SetPendingException(JSContext *cx, jsval v)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, v);
|
||||
SetPendingException(cx, Valueify(v));
|
||||
}
|
||||
|
||||
@@ -5287,8 +5441,10 @@ JS_DropExceptionState(JSContext *cx, JSExceptionState *state)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
if (state) {
|
||||
if (state->throwing && JSVAL_IS_GCTHING(state->exception))
|
||||
if (state->throwing && JSVAL_IS_GCTHING(state->exception)) {
|
||||
assertSameCompartment(cx, state->exception);
|
||||
JS_RemoveValueRoot(cx, &state->exception);
|
||||
}
|
||||
cx->free(state);
|
||||
}
|
||||
}
|
||||
@@ -5297,6 +5453,7 @@ JS_PUBLIC_API(JSErrorReport *)
|
||||
JS_ErrorFromException(JSContext *cx, jsval v)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, v);
|
||||
return js_ErrorFromException(cx, v);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user