зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1466118 part 4 - Replace assertSameCompartment with JSContext::check. r=luke
--HG-- extra : rebase_source : df78f08fa1e3a26f6713f3c669f4777dbdd9c988 extra : source : e24d946c4978ef29e025fee2f9b79339a27b7d79
This commit is contained in:
Родитель
aa66503708
Коммит
4c32da5e1a
|
@ -171,7 +171,7 @@ bool
|
|||
DataViewObject::constructSameCompartment(JSContext* cx, HandleObject bufobj, const CallArgs& args)
|
||||
{
|
||||
MOZ_ASSERT(args.isConstructing());
|
||||
assertSameCompartment(cx, bufobj);
|
||||
cx->check(bufobj);
|
||||
|
||||
uint32_t byteOffset, byteLength;
|
||||
if (!getAndCheckConstructorArgs(cx, bufobj, args, &byteOffset, &byteLength))
|
||||
|
|
|
@ -440,7 +440,7 @@ static bool
|
|||
ExecuteInExtensibleLexicalEnvironment(JSContext* cx, HandleScript scriptArg, HandleObject env)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, env);
|
||||
cx->check(env);
|
||||
MOZ_ASSERT(IsExtensibleLexicalEnvironment(env));
|
||||
MOZ_RELEASE_ASSERT(scriptArg->hasNonSyntacticScope());
|
||||
|
||||
|
@ -518,7 +518,7 @@ JS_FRIEND_API(bool)
|
|||
js::ExecuteInJSMEnvironment(JSContext* cx, HandleScript scriptArg, HandleObject varEnv,
|
||||
AutoObjectVector& targetObj)
|
||||
{
|
||||
assertSameCompartment(cx, varEnv);
|
||||
cx->check(varEnv);
|
||||
MOZ_ASSERT(ObjectRealm::get(varEnv).getNonSyntacticLexicalEnvironment(varEnv));
|
||||
MOZ_DIAGNOSTIC_ASSERT(scriptArg->noScriptRval());
|
||||
|
||||
|
|
|
@ -1711,7 +1711,7 @@ RetT
|
|||
CallObjFunc(RetT(*ObjFunc)(JSContext*, HandleObject), JSContext* cx, HandleObject obj)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
// Always unwrap, in case this is an xray or cross-compartment wrapper.
|
||||
RootedObject unwrappedObj(cx);
|
||||
|
@ -1729,7 +1729,7 @@ CallObjFunc(bool(*ObjFunc)(JSContext *cx, HandleObject obj, HandleValue key, boo
|
|||
JSContext *cx, HandleObject obj, HandleValue key, bool *rval)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, key);
|
||||
cx->check(obj, key);
|
||||
|
||||
// Always unwrap, in case this is an xray or cross-compartment wrapper.
|
||||
RootedObject unwrappedObj(cx);
|
||||
|
@ -1754,7 +1754,7 @@ CallObjFunc(bool(*ObjFunc)(JSContext* cx, Iter kind,
|
|||
JSContext *cx, Iter iterType, HandleObject obj, MutableHandleValue rval)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
// Always unwrap, in case this is an xray or cross-compartment wrapper.
|
||||
RootedObject unwrappedObj(cx);
|
||||
|
@ -1794,7 +1794,7 @@ JS_PUBLIC_API(bool)
|
|||
JS::MapGet(JSContext* cx, HandleObject obj, HandleValue key, MutableHandleValue rval)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, key, rval);
|
||||
cx->check(obj, key, rval);
|
||||
|
||||
// Unwrap the object, and enter its realm. If object isn't wrapped,
|
||||
// this is essentially a noop.
|
||||
|
@ -1825,7 +1825,7 @@ JS_PUBLIC_API(bool)
|
|||
JS::MapSet(JSContext *cx, HandleObject obj, HandleValue key, HandleValue val)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, key, val);
|
||||
cx->check(obj, key, val);
|
||||
|
||||
// Unwrap the object, and enter its compartment. If object isn't wrapped,
|
||||
// this is essentially a noop.
|
||||
|
@ -1906,7 +1906,7 @@ JS_PUBLIC_API(bool)
|
|||
JS::SetAdd(JSContext *cx, HandleObject obj, HandleValue key)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, key);
|
||||
cx->check(obj, key);
|
||||
|
||||
// Unwrap the object, and enter its compartment. If object isn't wrapped,
|
||||
// this is essentially a noop.
|
||||
|
|
|
@ -400,7 +400,7 @@ static const JSFunctionSpec profiling_functions[] = {
|
|||
JS_PUBLIC_API(bool)
|
||||
JS_DefineProfilingFunctions(JSContext* cx, HandleObject obj)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
#ifdef MOZ_PROFILING
|
||||
return JS_DefineFunctions(cx, obj, profiling_functions);
|
||||
#else
|
||||
|
|
|
@ -232,9 +232,9 @@ NewPromiseAllDataHolder(JSContext* cx, HandleObject resultPromise, HandleValue v
|
|||
if (!dataHolder)
|
||||
return nullptr;
|
||||
|
||||
assertSameCompartment(cx, resultPromise);
|
||||
assertSameCompartment(cx, valuesArray);
|
||||
assertSameCompartment(cx, resolve);
|
||||
cx->check(resultPromise);
|
||||
cx->check(valuesArray);
|
||||
cx->check(resolve);
|
||||
|
||||
dataHolder->setFixedSlot(PromiseAllDataHolderSlot_Promise, ObjectValue(*resultPromise));
|
||||
dataHolder->setFixedSlot(PromiseAllDataHolderSlot_RemainingElements, Int32Value(1));
|
||||
|
@ -772,7 +772,7 @@ static bool Promise_then_impl(JSContext* cx, HandleValue promiseVal, HandleValue
|
|||
static MOZ_MUST_USE bool
|
||||
ResolvePromiseInternal(JSContext* cx, HandleObject promise, HandleValue resolutionVal)
|
||||
{
|
||||
assertSameCompartment(cx, promise, resolutionVal);
|
||||
cx->check(promise, resolutionVal);
|
||||
MOZ_ASSERT(!IsSettledMaybeWrappedPromise(promise));
|
||||
|
||||
// Step 7 (reordered).
|
||||
|
@ -935,7 +935,7 @@ EnqueuePromiseReactionJob(JSContext* cx, HandleObject reactionObj,
|
|||
// Must not enqueue a reaction job more than once.
|
||||
MOZ_ASSERT(reaction->targetState() == JS::PromiseState::Pending);
|
||||
|
||||
assertSameCompartment(cx, handlerArg);
|
||||
cx->check(handlerArg);
|
||||
reaction->setTargetStateAndHandlerArg(targetState, handlerArg);
|
||||
|
||||
RootedValue reactionVal(cx, ObjectValue(*reaction));
|
||||
|
@ -1637,7 +1637,7 @@ PromiseResolveBuiltinThenableJob(JSContext* cx, unsigned argc, Value* vp)
|
|||
RootedObject promise(cx, &job->getExtendedSlot(BuiltinThenableJobSlot_Promise).toObject());
|
||||
RootedObject thenable(cx, &job->getExtendedSlot(BuiltinThenableJobSlot_Thenable).toObject());
|
||||
|
||||
assertSameCompartment(cx, promise, thenable);
|
||||
cx->check(promise, thenable);
|
||||
MOZ_ASSERT(promise->is<PromiseObject>());
|
||||
MOZ_ASSERT(thenable->is<PromiseObject>());
|
||||
|
||||
|
@ -1740,7 +1740,7 @@ static MOZ_MUST_USE bool
|
|||
EnqueuePromiseResolveThenableBuiltinJob(JSContext* cx, HandleObject promiseToResolve,
|
||||
HandleObject thenable)
|
||||
{
|
||||
assertSameCompartment(cx, promiseToResolve, thenable);
|
||||
cx->check(promiseToResolve, thenable);
|
||||
MOZ_ASSERT(promiseToResolve->is<PromiseObject>());
|
||||
MOZ_ASSERT(thenable->is<PromiseObject>());
|
||||
|
||||
|
@ -2156,7 +2156,7 @@ js::GetWaitForAllPromise(JSContext* cx, const JS::AutoObjectVector& promises)
|
|||
#ifdef DEBUG
|
||||
for (size_t i = 0, len = promises.length(); i < len; i++) {
|
||||
JSObject* obj = promises[i];
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
MOZ_ASSERT(UncheckedUnwrap(obj)->is<PromiseObject>());
|
||||
}
|
||||
#endif
|
||||
|
@ -2285,9 +2285,9 @@ RunResolutionFunction(JSContext *cx, HandleObject resolutionFun, HandleValue res
|
|||
// subclass constructor passes null/undefined to `super()`.)
|
||||
// There are also reactions where the Promise itself is missing. For
|
||||
// those, there's nothing left to do here.
|
||||
assertSameCompartment(cx, resolutionFun);
|
||||
assertSameCompartment(cx, result);
|
||||
assertSameCompartment(cx, promiseObj);
|
||||
cx->check(resolutionFun);
|
||||
cx->check(result);
|
||||
cx->check(promiseObj);
|
||||
if (resolutionFun) {
|
||||
RootedValue calleeOrRval(cx, ObjectValue(*resolutionFun));
|
||||
return Call(cx, calleeOrRval, UndefinedHandleValue, result, &calleeOrRval);
|
||||
|
@ -3080,12 +3080,12 @@ NewReactionRecord(JSContext* cx, Handle<PromiseCapability> resultCapability,
|
|||
if (!reaction)
|
||||
return nullptr;
|
||||
|
||||
assertSameCompartment(cx, resultCapability.promise());
|
||||
assertSameCompartment(cx, onFulfilled);
|
||||
assertSameCompartment(cx, onRejected);
|
||||
assertSameCompartment(cx, resultCapability.resolve());
|
||||
assertSameCompartment(cx, resultCapability.reject());
|
||||
assertSameCompartment(cx, incumbentGlobalObject);
|
||||
cx->check(resultCapability.promise());
|
||||
cx->check(onFulfilled);
|
||||
cx->check(onRejected);
|
||||
cx->check(resultCapability.resolve());
|
||||
cx->check(resultCapability.reject());
|
||||
cx->check(incumbentGlobalObject);
|
||||
|
||||
reaction->setFixedSlot(ReactionRecordSlot_Promise,
|
||||
ObjectOrNullValue(resultCapability.promise()));
|
||||
|
@ -3160,7 +3160,7 @@ static MOZ_MUST_USE bool
|
|||
OriginalPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> promise,
|
||||
Handle<PromiseObject*> promiseToResolve)
|
||||
{
|
||||
assertSameCompartment(cx, promise);
|
||||
cx->check(promise);
|
||||
|
||||
// Steps 3-4.
|
||||
Rooted<PromiseCapability> resultCapability(cx);
|
||||
|
@ -3187,7 +3187,7 @@ static bool
|
|||
OriginalPromiseThenBuiltin(JSContext* cx, HandleValue promiseVal, HandleValue onFulfilled,
|
||||
HandleValue onRejected, MutableHandleValue rval, bool rvalUsed)
|
||||
{
|
||||
assertSameCompartment(cx, promiseVal, onFulfilled, onRejected);
|
||||
cx->check(promiseVal, onFulfilled, onRejected);
|
||||
MOZ_ASSERT(CanCallOriginalPromiseThenBuiltin(cx, promiseVal));
|
||||
|
||||
Rooted<PromiseObject*> promise(cx, &promiseVal.toObject().as<PromiseObject>());
|
||||
|
|
|
@ -204,7 +204,7 @@ JS::GetWeakMapEntry(JSContext* cx, HandleObject mapObj, HandleObject key,
|
|||
MutableHandleValue rval)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, key);
|
||||
cx->check(key);
|
||||
rval.setUndefined();
|
||||
ObjectValueMap* map = mapObj->as<WeakMapObject>().getMap();
|
||||
if (!map)
|
||||
|
@ -223,7 +223,7 @@ JS::SetWeakMapEntry(JSContext* cx, HandleObject mapObj, HandleObject key,
|
|||
HandleValue val)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, key, val);
|
||||
cx->check(key, val);
|
||||
Handle<WeakMapObject*> rootedMap = mapObj.as<WeakMapObject>();
|
||||
return WeakCollectionPutEntryInternal(cx, rootedMap, key, val);
|
||||
}
|
||||
|
|
|
@ -244,7 +244,7 @@ jit::EnterBaselineAtBranch(JSContext* cx, InterpreterFrame* fp, jsbytecode* pc)
|
|||
MethodStatus
|
||||
jit::BaselineCompile(JSContext* cx, JSScript* script, bool forceDebugInstrumentation)
|
||||
{
|
||||
assertSameCompartment(cx, script);
|
||||
cx->check(script);
|
||||
MOZ_ASSERT(!script->hasBaselineScript());
|
||||
MOZ_ASSERT(script->canBaselineCompile());
|
||||
MOZ_ASSERT(IsBaselineEnabled(cx));
|
||||
|
|
254
js/src/jsapi.cpp
254
js/src/jsapi.cpp
|
@ -160,7 +160,7 @@ JS::ObjectOpResult::reportStrictErrorOrWarning(JSContext* cx, HandleObject obj,
|
|||
"unsigned value of OkCode must not be an error code");
|
||||
MOZ_ASSERT(code_ != Uninitialized);
|
||||
MOZ_ASSERT(!ok());
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
unsigned flags = strict ? JSREPORT_ERROR : (JSREPORT_WARNING | JSREPORT_STRICT);
|
||||
if (code_ == JSMSG_OBJECT_NOT_EXTENSIBLE) {
|
||||
|
@ -207,7 +207,7 @@ JS::ObjectOpResult::reportStrictErrorOrWarning(JSContext* cx, HandleObject obj,
|
|||
MOZ_ASSERT(code_ != Uninitialized);
|
||||
MOZ_ASSERT(!ok());
|
||||
MOZ_ASSERT(!ErrorTakesArguments(code_));
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
unsigned flags = strict ? JSREPORT_ERROR : (JSREPORT_WARNING | JSREPORT_STRICT);
|
||||
return JS_ReportErrorFlagsAndNumberASCII(cx, flags, GetErrorMessage, nullptr, code_);
|
||||
|
@ -359,7 +359,7 @@ JS_ValueToObject(JSContext* cx, HandleValue value, MutableHandleObject objp)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, value);
|
||||
cx->check(value);
|
||||
if (value.isNullOrUndefined()) {
|
||||
objp.set(nullptr);
|
||||
return true;
|
||||
|
@ -376,7 +376,7 @@ JS_ValueToFunction(JSContext* cx, HandleValue value)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, value);
|
||||
cx->check(value);
|
||||
return ReportIfNotFunction(cx, value);
|
||||
}
|
||||
|
||||
|
@ -385,7 +385,7 @@ JS_ValueToConstructor(JSContext* cx, HandleValue value)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, value);
|
||||
cx->check(value);
|
||||
return ReportIfNotFunction(cx, value);
|
||||
}
|
||||
|
||||
|
@ -394,7 +394,7 @@ JS_ValueToSource(JSContext* cx, HandleValue value)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, value);
|
||||
cx->check(value);
|
||||
return ValueToSource(cx, value);
|
||||
}
|
||||
|
||||
|
@ -409,7 +409,7 @@ JS_TypeOfValue(JSContext* cx, HandleValue value)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, value);
|
||||
cx->check(value);
|
||||
return TypeOfValue(value);
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,7 @@ JS_StrictlyEqual(JSContext* cx, HandleValue value1, HandleValue value2, bool* eq
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, value1, value2);
|
||||
cx->check(value1, value2);
|
||||
MOZ_ASSERT(equal);
|
||||
return StrictlyEqual(cx, value1, value2, equal);
|
||||
}
|
||||
|
@ -428,7 +428,7 @@ JS_LooselyEqual(JSContext* cx, HandleValue value1, HandleValue value2, bool* equ
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, value1, value2);
|
||||
cx->check(value1, value2);
|
||||
MOZ_ASSERT(equal);
|
||||
return LooselyEqual(cx, value1, value2, equal);
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ JS_SameValue(JSContext* cx, HandleValue value1, HandleValue value2, bool* same)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, value1, value2);
|
||||
cx->check(value1, value2);
|
||||
MOZ_ASSERT(same);
|
||||
return SameValue(cx, value1, value2, same);
|
||||
}
|
||||
|
@ -1039,7 +1039,7 @@ JS_ResolveStandardClass(JSContext* cx, HandleObject obj, HandleId id, bool* reso
|
|||
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id);
|
||||
cx->check(obj, id);
|
||||
|
||||
Handle<GlobalObject*> global = obj.as<GlobalObject>();
|
||||
*resolved = false;
|
||||
|
@ -1117,7 +1117,7 @@ JS_EnumerateStandardClasses(JSContext* cx, HandleObject obj)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
Handle<GlobalObject*> global = obj.as<GlobalObject>();
|
||||
return GlobalObject::initStandardClasses(cx, global);
|
||||
}
|
||||
|
@ -1218,7 +1218,7 @@ JS_IdToProtoKey(JSContext* cx, HandleId id)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, id);
|
||||
cx->check(id);
|
||||
|
||||
if (!JSID_IS_ATOM(id))
|
||||
return JSProto_Null;
|
||||
|
@ -1296,7 +1296,7 @@ JS_PUBLIC_API(bool)
|
|||
JS::detail::ComputeThis(JSContext* cx, Value* vp, MutableHandleObject thisObject)
|
||||
{
|
||||
AssertHeapIsIdle();
|
||||
assertSameCompartment(cx, vp[0], vp[1]);
|
||||
cx->check(vp[0], vp[1]);
|
||||
|
||||
MutableHandleValue thisv = MutableHandleValue::fromMarkedLocation(&vp[1]);
|
||||
if (!BoxNonStrictThis(cx, thisv, thisv))
|
||||
|
@ -1625,7 +1625,7 @@ JS_ValueToId(JSContext* cx, HandleValue value, MutableHandleId idp)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, value);
|
||||
cx->check(value);
|
||||
return ValueToId<CanGC>(cx, value, idp);
|
||||
}
|
||||
|
||||
|
@ -1634,7 +1634,7 @@ JS_StringToId(JSContext* cx, HandleString string, MutableHandleId idp)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, string);
|
||||
cx->check(string);
|
||||
RootedValue value(cx, StringValue(string));
|
||||
return ValueToId<CanGC>(cx, value, idp);
|
||||
}
|
||||
|
@ -1644,9 +1644,9 @@ JS_IdToValue(JSContext* cx, jsid id, MutableHandleValue vp)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, id);
|
||||
cx->check(id);
|
||||
vp.set(IdToValue(id));
|
||||
assertSameCompartment(cx, vp);
|
||||
cx->check(vp);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1655,7 +1655,7 @@ JS::ToPrimitive(JSContext* cx, HandleObject obj, JSType hint, MutableHandleValue
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
MOZ_ASSERT(obj != nullptr);
|
||||
MOZ_ASSERT(hint == JSTYPE_UNDEFINED || hint == JSTYPE_STRING || hint == JSTYPE_NUMBER);
|
||||
vp.setObject(*obj);
|
||||
|
@ -1718,7 +1718,7 @@ JS_InitClass(JSContext* cx, HandleObject obj, HandleObject parent_proto,
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, parent_proto);
|
||||
cx->check(obj, parent_proto);
|
||||
return InitClass(cx, obj, parent_proto, Valueify(clasp), constructor,
|
||||
nargs, ps, fs, static_ps, static_fs);
|
||||
}
|
||||
|
@ -1742,8 +1742,8 @@ JS_InstanceOf(JSContext* cx, HandleObject obj, const JSClass* clasp, CallArgs* a
|
|||
CHECK_REQUEST(cx);
|
||||
#ifdef DEBUG
|
||||
if (args) {
|
||||
assertSameCompartment(cx, obj);
|
||||
assertSameCompartment(cx, args->thisv(), args->calleev());
|
||||
cx->check(obj);
|
||||
cx->check(args->thisv(), args->calleev());
|
||||
}
|
||||
#endif
|
||||
if (!obj || obj->getJSClass() != clasp) {
|
||||
|
@ -1758,7 +1758,7 @@ JS_PUBLIC_API(bool)
|
|||
JS_HasInstance(JSContext* cx, HandleObject obj, HandleValue value, bool* bp)
|
||||
{
|
||||
AssertHeapIsIdle();
|
||||
assertSameCompartment(cx, obj, value);
|
||||
cx->check(obj, value);
|
||||
return HasInstance(cx, obj, value, bp);
|
||||
}
|
||||
|
||||
|
@ -1789,7 +1789,7 @@ JS_GetConstructor(JSContext* cx, HandleObject proto)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, proto);
|
||||
cx->check(proto);
|
||||
|
||||
RootedValue cval(cx);
|
||||
if (!GetProperty(cx, proto, proto, cx->names().constructor, &cval))
|
||||
|
@ -1929,7 +1929,7 @@ JS_FireOnNewGlobalObject(JSContext* cx, JS::HandleObject global)
|
|||
// to be able to throw errors during delicate global creation routines.
|
||||
// This infallibility will eat OOM and slow script, but if that happens
|
||||
// we'll likely run up into them again soon in a fallible context.
|
||||
assertSameCompartment(cx, global);
|
||||
cx->check(global);
|
||||
Rooted<js::GlobalObject*> globalObject(cx, &global->as<GlobalObject>());
|
||||
Debugger::onNewGlobalObject(cx, globalObject);
|
||||
}
|
||||
|
@ -1957,7 +1957,7 @@ JS_NewObjectWithGivenProto(JSContext* cx, const JSClass* jsclasp, HandleObject p
|
|||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, proto);
|
||||
cx->check(proto);
|
||||
|
||||
const Class* clasp = Valueify(jsclasp);
|
||||
if (!clasp)
|
||||
|
@ -1986,7 +1986,7 @@ JS_NewObjectForConstructor(JSContext* cx, const JSClass* clasp, const CallArgs&
|
|||
CHECK_REQUEST(cx);
|
||||
|
||||
Value callee = args.calleev();
|
||||
assertSameCompartment(cx, callee);
|
||||
cx->check(callee);
|
||||
RootedObject obj(cx, &callee.toObject());
|
||||
return CreateThis(cx, Valueify(clasp), obj);
|
||||
}
|
||||
|
@ -2010,7 +2010,7 @@ JS::AssertObjectBelongsToCurrentThread(JSObject* obj)
|
|||
JS_PUBLIC_API(bool)
|
||||
JS_GetPrototype(JSContext* cx, HandleObject obj, MutableHandleObject result)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
return GetPrototype(cx, obj, result);
|
||||
}
|
||||
|
||||
|
@ -2019,7 +2019,7 @@ JS_SetPrototype(JSContext* cx, HandleObject obj, HandleObject proto)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, proto);
|
||||
cx->check(obj, proto);
|
||||
|
||||
return SetPrototype(cx, obj, proto);
|
||||
}
|
||||
|
@ -2028,28 +2028,28 @@ JS_PUBLIC_API(bool)
|
|||
JS_GetPrototypeIfOrdinary(JSContext* cx, HandleObject obj, bool* isOrdinary,
|
||||
MutableHandleObject result)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
return GetPrototypeIfOrdinary(cx, obj, isOrdinary, result);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_IsExtensible(JSContext* cx, HandleObject obj, bool* extensible)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
return IsExtensible(cx, obj, extensible);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_PreventExtensions(JSContext* cx, JS::HandleObject obj, ObjectOpResult& result)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
return PreventExtensions(cx, obj, result);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_SetImmutablePrototype(JSContext *cx, JS::HandleObject obj, bool *succeeded)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
return SetImmutablePrototype(cx, obj, succeeded);
|
||||
}
|
||||
|
||||
|
@ -2059,7 +2059,7 @@ JS_GetOwnPropertyDescriptorById(JSContext* cx, HandleObject obj, HandleId id,
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id);
|
||||
cx->check(obj, id);
|
||||
|
||||
return GetOwnPropertyDescriptor(cx, obj, id, desc);
|
||||
}
|
||||
|
@ -2090,7 +2090,7 @@ JS_PUBLIC_API(bool)
|
|||
JS_GetPropertyDescriptorById(JSContext* cx, HandleObject obj, HandleId id,
|
||||
MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
assertSameCompartment(cx, obj, id);
|
||||
cx->check(obj, id);
|
||||
return GetPropertyDescriptor(cx, obj, id, desc);
|
||||
}
|
||||
|
||||
|
@ -2111,7 +2111,7 @@ DefinePropertyByDescriptor(JSContext* cx, HandleObject obj, HandleId id,
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id, desc);
|
||||
cx->check(obj, id, desc);
|
||||
return DefineProperty(cx, obj, id, desc, result);
|
||||
}
|
||||
|
||||
|
@ -2147,7 +2147,7 @@ DefineAccessorPropertyById(JSContext* cx, HandleObject obj, HandleId id,
|
|||
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id, getter, setter);
|
||||
cx->check(obj, id, getter, setter);
|
||||
|
||||
return js::DefineAccessorProperty(cx, obj, id, getter, setter, attrs);
|
||||
}
|
||||
|
@ -2203,7 +2203,7 @@ DefineDataPropertyById(JSContext* cx, HandleObject obj, HandleId id, HandleValue
|
|||
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id, value);
|
||||
cx->check(obj, id, value);
|
||||
|
||||
return js::DefineDataProperty(cx, obj, id, value, attrs);
|
||||
}
|
||||
|
@ -2470,7 +2470,7 @@ static bool
|
|||
DefineDataElement(JSContext* cx, HandleObject obj, uint32_t index, HandleValue value,
|
||||
unsigned attrs)
|
||||
{
|
||||
assertSameCompartment(cx, obj, value);
|
||||
cx->check(obj, value);
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
RootedId id(cx);
|
||||
|
@ -2541,7 +2541,7 @@ JS_HasPropertyById(JSContext* cx, HandleObject obj, HandleId id, bool* foundp)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id);
|
||||
cx->check(obj, id);
|
||||
|
||||
return HasProperty(cx, obj, id, foundp);
|
||||
}
|
||||
|
@ -2582,7 +2582,7 @@ JS_HasOwnPropertyById(JSContext* cx, HandleObject obj, HandleId id, bool* foundp
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id);
|
||||
cx->check(obj, id);
|
||||
|
||||
return HasOwnProperty(cx, obj, id, foundp);
|
||||
}
|
||||
|
@ -2603,7 +2603,7 @@ JS_ForwardGetPropertyTo(JSContext* cx, HandleObject obj, HandleId id, HandleValu
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id, receiver);
|
||||
cx->check(obj, id, receiver);
|
||||
|
||||
return GetProperty(cx, obj, receiver, id, vp);
|
||||
}
|
||||
|
@ -2614,7 +2614,7 @@ JS_ForwardGetElementTo(JSContext* cx, HandleObject obj, uint32_t index, HandleOb
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
return GetElement(cx, obj, receiver, index, vp);
|
||||
}
|
||||
|
@ -2659,7 +2659,7 @@ JS_ForwardSetPropertyTo(JSContext* cx, HandleObject obj, HandleId id, HandleValu
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id, v, receiver);
|
||||
cx->check(obj, id, v, receiver);
|
||||
|
||||
return SetProperty(cx, obj, id, v, receiver, result);
|
||||
}
|
||||
|
@ -2669,7 +2669,7 @@ JS_SetPropertyById(JSContext* cx, HandleObject obj, HandleId id, HandleValue v)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id, v);
|
||||
cx->check(obj, id, v);
|
||||
|
||||
RootedValue receiver(cx, ObjectValue(*obj));
|
||||
ObjectOpResult ignored;
|
||||
|
@ -2702,7 +2702,7 @@ SetElement(JSContext* cx, HandleObject obj, uint32_t index, HandleValue v)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, v);
|
||||
cx->check(obj, v);
|
||||
|
||||
RootedValue receiver(cx, ObjectValue(*obj));
|
||||
ObjectOpResult ignored;
|
||||
|
@ -2755,7 +2755,7 @@ JS_DeletePropertyById(JSContext* cx, HandleObject obj, HandleId id, ObjectOpResu
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id);
|
||||
cx->check(obj, id);
|
||||
|
||||
return DeleteProperty(cx, obj, id, result);
|
||||
}
|
||||
|
@ -2764,7 +2764,7 @@ JS_PUBLIC_API(bool)
|
|||
JS_DeleteProperty(JSContext* cx, HandleObject obj, const char* name, ObjectOpResult& result)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
JSAtom* atom = Atomize(cx, name, strlen(name));
|
||||
if (!atom)
|
||||
|
@ -2778,7 +2778,7 @@ JS_DeleteUCProperty(JSContext* cx, HandleObject obj, const char16_t* name, size_
|
|||
ObjectOpResult& result)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
JSAtom* atom = AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen));
|
||||
if (!atom)
|
||||
|
@ -2792,7 +2792,7 @@ JS_DeleteElement(JSContext* cx, HandleObject obj, uint32_t index, ObjectOpResult
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
return DeleteElement(cx, obj, index, result);
|
||||
}
|
||||
|
@ -2823,7 +2823,7 @@ JS_Enumerate(JSContext* cx, HandleObject obj, JS::MutableHandle<IdVector> props)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, props);
|
||||
cx->check(obj, props);
|
||||
MOZ_ASSERT(props.empty());
|
||||
|
||||
AutoIdVector ids(cx);
|
||||
|
@ -2852,7 +2852,7 @@ JS_CallFunctionValue(JSContext* cx, HandleObject obj, HandleValue fval, const Ha
|
|||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, fval, args);
|
||||
cx->check(obj, fval, args);
|
||||
|
||||
InvokeArgs iargs(cx);
|
||||
if (!FillArgumentsFromArraylike(cx, iargs, args))
|
||||
|
@ -2869,7 +2869,7 @@ JS_CallFunction(JSContext* cx, HandleObject obj, HandleFunction fun, const Handl
|
|||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, fun, args);
|
||||
cx->check(obj, fun, args);
|
||||
|
||||
InvokeArgs iargs(cx);
|
||||
if (!FillArgumentsFromArraylike(cx, iargs, args))
|
||||
|
@ -2887,7 +2887,7 @@ JS_CallFunctionName(JSContext* cx, HandleObject obj, const char* name, const Han
|
|||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, args);
|
||||
cx->check(obj, args);
|
||||
|
||||
JSAtom* atom = Atomize(cx, name, strlen(name));
|
||||
if (!atom)
|
||||
|
@ -2912,7 +2912,7 @@ JS::Call(JSContext* cx, HandleValue thisv, HandleValue fval, const JS::HandleVal
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, thisv, fval, args);
|
||||
cx->check(thisv, fval, args);
|
||||
|
||||
InvokeArgs iargs(cx);
|
||||
if (!FillArgumentsFromArraylike(cx, iargs, args))
|
||||
|
@ -2927,7 +2927,7 @@ JS::Construct(JSContext* cx, HandleValue fval, HandleObject newTarget, const JS:
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, fval, newTarget, args);
|
||||
cx->check(fval, newTarget, args);
|
||||
|
||||
if (!IsConstructor(fval)) {
|
||||
ReportValueError(cx, JSMSG_NOT_CONSTRUCTOR, JSDVG_IGNORE_STACK, fval, nullptr);
|
||||
|
@ -2953,7 +2953,7 @@ JS::Construct(JSContext* cx, HandleValue fval, const JS::HandleValueArray& args,
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, fval, args);
|
||||
cx->check(fval, args);
|
||||
|
||||
if (!IsConstructor(fval)) {
|
||||
ReportValueError(cx, JSMSG_NOT_CONSTRUCTOR, JSDVG_IGNORE_STACK, fval, nullptr);
|
||||
|
@ -2975,7 +2975,7 @@ JS_AlreadyHasOwnPropertyById(JSContext* cx, HandleObject obj, HandleId id, bool*
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id);
|
||||
cx->check(obj, id);
|
||||
|
||||
if (!obj->isNative())
|
||||
return js::HasOwnProperty(cx, obj, id, foundp);
|
||||
|
@ -3024,7 +3024,7 @@ JS_FreezeObject(JSContext* cx, HandleObject obj)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
return FreezeObject(cx, obj);
|
||||
}
|
||||
|
||||
|
@ -3042,7 +3042,7 @@ JS_DeepFreezeObject(JSContext* cx, HandleObject obj)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
/* Assume that non-extensible objects are already deep-frozen, to avoid divergence. */
|
||||
bool extensible;
|
||||
|
@ -3119,7 +3119,7 @@ JS_DefineObject(JSContext* cx, HandleObject obj, const char* name, const JSClass
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
const Class* clasp = Valueify(jsclasp);
|
||||
if (!clasp)
|
||||
|
@ -3273,7 +3273,7 @@ JS::ObjectToCompletePropertyDescriptor(JSContext* cx,
|
|||
{
|
||||
// |obj| can be in a different compartment here. The caller is responsible
|
||||
// for wrapping it (see JS_WrapPropertyDescriptor).
|
||||
assertSameCompartment(cx, descObj);
|
||||
cx->check(descObj);
|
||||
if (!ToPropertyDescriptor(cx, descObj, true, desc))
|
||||
return false;
|
||||
CompletePropertyDescriptor(desc);
|
||||
|
@ -3287,7 +3287,7 @@ JS_SetAllNonReservedSlotsToUndefined(JSContext* cx, JSObject* objArg)
|
|||
RootedObject obj(cx, objArg);
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
if (!obj->isNative())
|
||||
return;
|
||||
|
@ -3318,7 +3318,7 @@ JS_NewArrayObject(JSContext* cx, const JS::HandleValueArray& contents)
|
|||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
assertSameCompartment(cx, contents);
|
||||
cx->check(contents);
|
||||
return NewDenseCopiedArray(cx, contents.length(), contents.begin());
|
||||
}
|
||||
|
||||
|
@ -3335,7 +3335,7 @@ JS_NewArrayObject(JSContext* cx, size_t length)
|
|||
inline bool
|
||||
IsGivenTypeObject(JSContext* cx, JS::HandleObject obj, const ESClass& typeClass, bool* isType)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(cx, obj, &cls))
|
||||
|
@ -3368,7 +3368,7 @@ JS_GetArrayLength(JSContext* cx, HandleObject obj, uint32_t* lengthp)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
return GetLengthProperty(cx, obj, lengthp);
|
||||
}
|
||||
|
||||
|
@ -3377,7 +3377,7 @@ JS_SetArrayLength(JSContext* cx, HandleObject obj, uint32_t length)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
return SetLengthProperty(cx, obj, length);
|
||||
}
|
||||
|
||||
|
@ -3473,7 +3473,7 @@ JS::GetSelfHostedFunction(JSContext* cx, const char* selfHostedName, HandleId id
|
|||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, id);
|
||||
cx->check(id);
|
||||
|
||||
RootedAtom name(cx, IdToFunctionName(cx, id));
|
||||
if (!name)
|
||||
|
@ -3492,7 +3492,7 @@ JS::GetSelfHostedFunction(JSContext* cx, const char* selfHostedName, HandleId id
|
|||
JS_PUBLIC_API(JSFunction*)
|
||||
JS::NewFunctionFromSpec(JSContext* cx, const JSFunctionSpec* fs, HandleId id)
|
||||
{
|
||||
assertSameCompartment(cx, id);
|
||||
cx->check(id);
|
||||
|
||||
// Delay cloning self-hosted functions until they are called. This is
|
||||
// achieved by passing DefineFunction a nullptr JSNative which produces an
|
||||
|
@ -3600,7 +3600,7 @@ CloneFunctionObject(JSContext* cx, HandleObject funobj, HandleObject env, Handle
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, env);
|
||||
cx->check(env);
|
||||
MOZ_ASSERT(env);
|
||||
// Note that funobj can be in a different compartment.
|
||||
|
||||
|
@ -3705,7 +3705,7 @@ JS_GetFunctionArity(JSFunction* fun)
|
|||
JS_PUBLIC_API(bool)
|
||||
JS_GetFunctionLength(JSContext* cx, HandleFunction fun, uint16_t* length)
|
||||
{
|
||||
assertSameCompartment(cx, fun);
|
||||
cx->check(fun);
|
||||
return JSFunction::getLength(cx, fun, length);
|
||||
}
|
||||
|
||||
|
@ -3736,7 +3736,7 @@ JS_DefineFunctions(JSContext* cx, HandleObject obj, const JSFunctionSpec* fs)
|
|||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
return DefineFunctions(cx, obj, fs, NotIntrinsic);
|
||||
}
|
||||
|
@ -3748,7 +3748,7 @@ JS_DefineFunction(JSContext* cx, HandleObject obj, const char* name, JSNative ca
|
|||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
JSAtom* atom = Atomize(cx, name, strlen(name));
|
||||
if (!atom)
|
||||
return nullptr;
|
||||
|
@ -3764,7 +3764,7 @@ JS_DefineUCFunction(JSContext* cx, HandleObject obj,
|
|||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
JSAtom* atom = AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen));
|
||||
if (!atom)
|
||||
return nullptr;
|
||||
|
@ -3779,7 +3779,7 @@ JS_DefineFunctionById(JSContext* cx, HandleObject obj, HandleId id, JSNative cal
|
|||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id);
|
||||
cx->check(obj, id);
|
||||
return DefineFunction(cx, obj, id, call, nargs, attrs);
|
||||
}
|
||||
|
||||
|
@ -4376,7 +4376,7 @@ JS_BufferIsCompilableUnit(JSContext* cx, HandleObject obj, const char* utf8, siz
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
cx->clearPendingException();
|
||||
|
||||
|
@ -4471,7 +4471,7 @@ CompileFunction(JSContext* cx, const ReadOnlyCompileOptions& optionsArg,
|
|||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, enclosingEnv);
|
||||
cx->check(enclosingEnv);
|
||||
RootedAtom funAtom(cx);
|
||||
|
||||
fun.set(NewScriptedFunction(cx, 0, JSFunction::INTERPRETED_NORMAL,
|
||||
|
@ -4648,7 +4648,7 @@ JS_DecompileFunction(JSContext* cx, HandleFunction fun)
|
|||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, fun);
|
||||
cx->check(fun);
|
||||
return FunctionToString(cx, fun, /* isToSource = */ false);
|
||||
}
|
||||
|
||||
|
@ -4658,7 +4658,7 @@ ExecuteScript(JSContext* cx, HandleObject scope, HandleScript script, Value* rva
|
|||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, scope, script);
|
||||
cx->check(scope, script);
|
||||
MOZ_ASSERT_IF(!IsGlobalLexicalEnvironment(scope), script->hasNonSyntacticScope());
|
||||
return Execute(cx, script, *scope, rval);
|
||||
}
|
||||
|
@ -4752,7 +4752,7 @@ Evaluate(JSContext* cx, ScopeKind scopeKind, HandleObject env,
|
|||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, env);
|
||||
cx->check(env);
|
||||
MOZ_ASSERT_IF(!IsGlobalLexicalEnvironment(env), scopeKind == ScopeKind::NonSyntactic);
|
||||
|
||||
options.setIsRunOnce(true);
|
||||
|
@ -4893,7 +4893,7 @@ JS::ModuleInstantiate(JSContext* cx, JS::HandleScript script)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, script);
|
||||
cx->check(script);
|
||||
RootedModuleObject module(cx, script->module());
|
||||
MOZ_ASSERT(module);
|
||||
return ModuleObject::Instantiate(cx, module);
|
||||
|
@ -4904,7 +4904,7 @@ JS::ModuleEvaluate(JSContext* cx, JS::HandleScript script)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, script);
|
||||
cx->check(script);
|
||||
RootedModuleObject module(cx, script->module());
|
||||
MOZ_ASSERT(module);
|
||||
return ModuleObject::Evaluate(cx, module);
|
||||
|
@ -4915,7 +4915,7 @@ JS::GetRequestedModules(JSContext* cx, JS::HandleScript script)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, script);
|
||||
cx->check(script);
|
||||
RootedModuleObject module(cx, script->module());
|
||||
MOZ_ASSERT(module);
|
||||
return &module->requestedModules();
|
||||
|
@ -4926,7 +4926,7 @@ JS::GetRequestedModuleSpecifier(JSContext* cx, JS::HandleValue value)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, value);
|
||||
cx->check(value);
|
||||
JSObject* obj = &value.toObject();
|
||||
return obj->as<RequestedModuleObject>().moduleSpecifier();
|
||||
}
|
||||
|
@ -4937,7 +4937,7 @@ JS::GetRequestedModuleSourcePos(JSContext* cx, JS::HandleValue value,
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, value);
|
||||
cx->check(value);
|
||||
MOZ_ASSERT(lineNumber);
|
||||
MOZ_ASSERT(columnNumber);
|
||||
auto& requested = value.toObject().as<RequestedModuleObject>();
|
||||
|
@ -4950,7 +4950,7 @@ JS_New(JSContext* cx, HandleObject ctor, const JS::HandleValueArray& inputArgs)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, ctor, inputArgs);
|
||||
cx->check(ctor, inputArgs);
|
||||
|
||||
RootedValue ctorVal(cx, ObjectValue(*ctor));
|
||||
if (!IsConstructor(ctorVal)) {
|
||||
|
@ -5040,7 +5040,7 @@ JS::NewPromiseObject(JSContext* cx, HandleObject executor, HandleObject proto /*
|
|||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, executor, proto);
|
||||
cx->check(executor, proto);
|
||||
|
||||
if (!executor)
|
||||
return PromiseObject::createSkippingExecutor(cx);
|
||||
|
@ -5136,7 +5136,7 @@ JS::CallOriginalPromiseResolve(JSContext* cx, JS::HandleValue resolutionValue)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, resolutionValue);
|
||||
cx->check(resolutionValue);
|
||||
|
||||
RootedObject promise(cx, PromiseObject::unforgeableResolve(cx, resolutionValue));
|
||||
MOZ_ASSERT_IF(promise, CheckedUnwrap(promise)->is<PromiseObject>());
|
||||
|
@ -5148,7 +5148,7 @@ JS::CallOriginalPromiseReject(JSContext* cx, JS::HandleValue rejectionValue)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, rejectionValue);
|
||||
cx->check(rejectionValue);
|
||||
|
||||
RootedObject promise(cx, PromiseObject::unforgeableReject(cx, rejectionValue));
|
||||
MOZ_ASSERT_IF(promise, CheckedUnwrap(promise)->is<PromiseObject>());
|
||||
|
@ -5161,7 +5161,7 @@ ResolveOrRejectPromise(JSContext* cx, JS::HandleObject promiseObj, JS::HandleVal
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, promiseObj, resultOrReason_);
|
||||
cx->check(promiseObj, resultOrReason_);
|
||||
|
||||
mozilla::Maybe<AutoRealm> ar;
|
||||
Rooted<PromiseObject*> promise(cx);
|
||||
|
@ -5205,7 +5205,7 @@ CallOriginalPromiseThenImpl(JSContext* cx, JS::HandleObject promiseObj,
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, promiseObj, onResolvedObj_, onRejectedObj_);
|
||||
cx->check(promiseObj, onResolvedObj_, onRejectedObj_);
|
||||
|
||||
MOZ_ASSERT_IF(onResolvedObj_, IsCallable(onResolvedObj_));
|
||||
MOZ_ASSERT_IF(onRejectedObj_, IsCallable(onRejectedObj_));
|
||||
|
@ -5446,8 +5446,8 @@ JS::ReadableStreamCancel(JSContext* cx, HandleObject streamObj, HandleValue reas
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, streamObj);
|
||||
assertSameCompartment(cx, reason);
|
||||
cx->check(streamObj);
|
||||
cx->check(reason);
|
||||
|
||||
Rooted<ReadableStream*> stream(cx, &streamObj->as<ReadableStream>());
|
||||
return ReadableStream::cancel(cx, stream, reason);
|
||||
|
@ -5464,7 +5464,7 @@ JS::ReadableStreamGetReader(JSContext* cx, HandleObject streamObj, ReadableStrea
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, streamObj);
|
||||
cx->check(streamObj);
|
||||
|
||||
Rooted<ReadableStream*> stream(cx, &streamObj->as<ReadableStream>());
|
||||
return ReadableStream::getReader(cx, stream, mode);
|
||||
|
@ -5475,7 +5475,7 @@ JS::ReadableStreamGetExternalUnderlyingSource(JSContext* cx, HandleObject stream
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, streamObj);
|
||||
cx->check(streamObj);
|
||||
|
||||
Rooted<ReadableStream*> stream(cx, &streamObj->as<ReadableStream>());
|
||||
return ReadableStream::getExternalSource(cx, stream, source);
|
||||
|
@ -5493,7 +5493,7 @@ JS::ReadableStreamUpdateDataAvailableFromSource(JSContext* cx, JS::HandleObject
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, streamObj);
|
||||
cx->check(streamObj);
|
||||
|
||||
Rooted<ReadableStream*> stream(cx, &streamObj->as<ReadableStream>());
|
||||
return ReadableStream::updateDataAvailableFromSource(cx, stream, availableData);
|
||||
|
@ -5505,7 +5505,7 @@ JS::ReadableStreamTee(JSContext* cx, HandleObject streamObj,
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, streamObj);
|
||||
cx->check(streamObj);
|
||||
|
||||
Rooted<ReadableStream*> stream(cx, &streamObj->as<ReadableStream>());
|
||||
Rooted<ReadableStream*> branch1Stream(cx);
|
||||
|
@ -5531,7 +5531,7 @@ JS::ReadableStreamClose(JSContext* cx, HandleObject streamObj)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, streamObj);
|
||||
cx->check(streamObj);
|
||||
|
||||
Rooted<ReadableStream*> stream(cx, &streamObj->as<ReadableStream>());
|
||||
return ReadableStream::close(cx, stream);
|
||||
|
@ -5542,8 +5542,8 @@ JS::ReadableStreamEnqueue(JSContext* cx, HandleObject streamObj, HandleValue chu
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, streamObj);
|
||||
assertSameCompartment(cx, chunk);
|
||||
cx->check(streamObj);
|
||||
cx->check(chunk);
|
||||
|
||||
Rooted<ReadableStream*> stream(cx, &streamObj->as<ReadableStream>());
|
||||
if (stream->mode() != JS::ReadableStreamMode::Default) {
|
||||
|
@ -5560,8 +5560,8 @@ JS::ReadableByteStreamEnqueueBuffer(JSContext* cx, HandleObject streamObj, Handl
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, streamObj);
|
||||
assertSameCompartment(cx, chunkObj);
|
||||
cx->check(streamObj);
|
||||
cx->check(chunkObj);
|
||||
|
||||
Rooted<ReadableStream*> stream(cx, &streamObj->as<ReadableStream>());
|
||||
if (stream->mode() != JS::ReadableStreamMode::Byte) {
|
||||
|
@ -5592,8 +5592,8 @@ JS::ReadableStreamError(JSContext* cx, HandleObject streamObj, HandleValue error
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, streamObj);
|
||||
assertSameCompartment(cx, error);
|
||||
cx->check(streamObj);
|
||||
cx->check(error);
|
||||
|
||||
Rooted<ReadableStream*> stream(cx, &streamObj->as<ReadableStream>());
|
||||
return js::ReadableStream::error(cx, stream, error);
|
||||
|
@ -5610,8 +5610,8 @@ JS::ReadableStreamReaderCancel(JSContext* cx, HandleObject reader, HandleValue r
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, reader);
|
||||
assertSameCompartment(cx, reason);
|
||||
cx->check(reader);
|
||||
cx->check(reason);
|
||||
|
||||
return js::ReadableStreamReaderCancel(cx, reader, reason);
|
||||
}
|
||||
|
@ -5621,7 +5621,7 @@ JS::ReadableStreamReaderReleaseLock(JSContext* cx, HandleObject reader)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, reader);
|
||||
cx->check(reader);
|
||||
|
||||
return js::ReadableStreamReaderReleaseLock(cx, reader);
|
||||
}
|
||||
|
@ -5631,7 +5631,7 @@ JS::ReadableStreamDefaultReaderRead(JSContext* cx, HandleObject readerObj)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, readerObj);
|
||||
cx->check(readerObj);
|
||||
|
||||
Rooted<ReadableStreamDefaultReader*> reader(cx, &readerObj->as<ReadableStreamDefaultReader>());
|
||||
return js::ReadableStreamDefaultReader::read(cx, reader);
|
||||
|
@ -5642,8 +5642,8 @@ JS::ReadableStreamBYOBReaderRead(JSContext* cx, HandleObject readerObj, HandleOb
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, readerObj);
|
||||
assertSameCompartment(cx, viewObj);
|
||||
cx->check(readerObj);
|
||||
cx->check(viewObj);
|
||||
|
||||
Rooted<ReadableStreamBYOBReader*> reader(cx, &readerObj->as<ReadableStreamBYOBReader>());
|
||||
Rooted<ArrayBufferViewObject*> view(cx, &viewObj->as<ArrayBufferViewObject>());
|
||||
|
@ -5906,7 +5906,7 @@ JS_GetLatin1StringCharsAndLength(JSContext* cx, const JS::AutoRequireNoGC& nogc,
|
|||
MOZ_ASSERT(plength);
|
||||
AssertHeapIsIdleOrStringIsFlat(str);
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, str);
|
||||
cx->check(str);
|
||||
JSLinearString* linear = str->ensureLinear(cx);
|
||||
if (!linear)
|
||||
return nullptr;
|
||||
|
@ -5921,7 +5921,7 @@ JS_GetTwoByteStringCharsAndLength(JSContext* cx, const JS::AutoRequireNoGC& nogc
|
|||
MOZ_ASSERT(plength);
|
||||
AssertHeapIsIdleOrStringIsFlat(str);
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, str);
|
||||
cx->check(str);
|
||||
JSLinearString* linear = str->ensureLinear(cx);
|
||||
if (!linear)
|
||||
return nullptr;
|
||||
|
@ -5940,7 +5940,7 @@ JS_GetStringCharAt(JSContext* cx, JSString* str, size_t index, char16_t* res)
|
|||
{
|
||||
AssertHeapIsIdleOrStringIsFlat(str);
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, str);
|
||||
cx->check(str);
|
||||
|
||||
JSLinearString* linear = str->ensureLinear(cx);
|
||||
if (!linear)
|
||||
|
@ -5961,7 +5961,7 @@ JS_CopyStringChars(JSContext* cx, mozilla::Range<char16_t> dest, JSString* str)
|
|||
{
|
||||
AssertHeapIsIdleOrStringIsFlat(str);
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, str);
|
||||
cx->check(str);
|
||||
|
||||
JSLinearString* linear = str->ensureLinear(cx);
|
||||
if (!linear)
|
||||
|
@ -5997,7 +5997,7 @@ JS_FlattenString(JSContext* cx, JSString* str)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, str);
|
||||
cx->check(str);
|
||||
JSFlatString* flat = str->ensureFlat(cx);
|
||||
if (!flat)
|
||||
return nullptr;
|
||||
|
@ -6160,7 +6160,7 @@ JS::NewSymbol(JSContext* cx, HandleString description)
|
|||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
if (description)
|
||||
assertSameCompartment(cx, description);
|
||||
cx->check(description);
|
||||
|
||||
return Symbol::new_(cx, SymbolCode::UniqueSymbol, description);
|
||||
}
|
||||
|
@ -6170,7 +6170,7 @@ JS::GetSymbolFor(JSContext* cx, HandleString key)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, key);
|
||||
cx->check(key);
|
||||
|
||||
return Symbol::for_(cx, key);
|
||||
}
|
||||
|
@ -6228,7 +6228,7 @@ JS_Stringify(JSContext* cx, MutableHandleValue vp, HandleObject replacer,
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, replacer, space);
|
||||
cx->check(replacer, space);
|
||||
StringBuffer sb(cx);
|
||||
if (!sb.ensureTwoByteChars())
|
||||
return false;
|
||||
|
@ -6245,7 +6245,7 @@ JS::ToJSONMaybeSafely(JSContext* cx, JS::HandleObject input,
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, input);
|
||||
cx->check(input);
|
||||
|
||||
StringBuffer sb(cx);
|
||||
if (!sb.ensureTwoByteChars())
|
||||
|
@ -6289,7 +6289,7 @@ JS_ParseJSONWithReviver(JSContext* cx, HandleString str, HandleValue reviver, Mu
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, str);
|
||||
cx->check(str);
|
||||
|
||||
AutoStableStringChars stableChars(cx);
|
||||
if (!stableChars.init(cx, str))
|
||||
|
@ -6571,7 +6571,7 @@ JS::NewDateObject(JSContext* cx, JS::ClippedTime time)
|
|||
JS_PUBLIC_API(bool)
|
||||
JS_ObjectIsDate(JSContext* cx, HandleObject obj, bool* isDate)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(cx, obj, &cls))
|
||||
|
@ -6615,7 +6615,7 @@ JS_SetRegExpInput(JSContext* cx, HandleObject obj, HandleString input)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, input);
|
||||
cx->check(input);
|
||||
|
||||
Handle<GlobalObject*> global = obj.as<GlobalObject>();
|
||||
RegExpStatics* res = GlobalObject::getRegExpStatics(cx, global);
|
||||
|
@ -6679,7 +6679,7 @@ JS_ExecuteRegExpNoStatics(JSContext* cx, HandleObject obj, char16_t* chars, size
|
|||
JS_PUBLIC_API(bool)
|
||||
JS_ObjectIsRegExp(JSContext* cx, HandleObject obj, bool* isRegExp)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(cx, obj, &cls))
|
||||
|
@ -6777,7 +6777,7 @@ JS_SetPendingException(JSContext* cx, HandleValue value)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, value);
|
||||
cx->check(value);
|
||||
cx->setPendingException(value);
|
||||
}
|
||||
|
||||
|
@ -6879,7 +6879,7 @@ JS_ErrorFromException(JSContext* cx, HandleObject obj)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
return ErrorFromException(cx, obj);
|
||||
}
|
||||
|
||||
|
@ -7308,7 +7308,7 @@ JS_CharsToId(JSContext* cx, JS::TwoByteChars chars, MutableHandleId idp)
|
|||
JS_PUBLIC_API(bool)
|
||||
JS_IsIdentifier(JSContext* cx, HandleString str, bool* isIdentifier)
|
||||
{
|
||||
assertSameCompartment(cx, str);
|
||||
cx->check(str);
|
||||
|
||||
JSLinearString* linearStr = str->ensureLinear(cx);
|
||||
if (!linearStr)
|
||||
|
@ -7540,7 +7540,7 @@ JS::detail::AssertArgumentsAreSane(JSContext* cx, HandleValue value)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, value);
|
||||
cx->check(value);
|
||||
}
|
||||
#endif /* JS_DEBUG */
|
||||
|
||||
|
|
|
@ -1034,7 +1034,7 @@ JS::CreateError(JSContext* cx, JSExnType type, HandleObject stack, HandleString
|
|||
uint32_t lineNumber, uint32_t columnNumber, JSErrorReport* report,
|
||||
HandleString message, MutableHandleValue rval)
|
||||
{
|
||||
assertSameCompartment(cx, stack, fileName, message);
|
||||
cx->check(stack, fileName, message);
|
||||
AssertObjectIsSavedFrameOrWrapper(cx, stack);
|
||||
|
||||
js::UniquePtr<JSErrorReport> rep;
|
||||
|
|
|
@ -76,7 +76,7 @@ JS_SetGrayGCRootsTracer(JSContext* cx, JSTraceDataOp traceOp, void* data)
|
|||
JS_FRIEND_API(JSObject*)
|
||||
JS_FindCompilationScope(JSContext* cx, HandleObject objArg)
|
||||
{
|
||||
assertSameCompartment(cx, objArg);
|
||||
cx->check(objArg);
|
||||
|
||||
RootedObject obj(cx, objArg);
|
||||
|
||||
|
@ -111,7 +111,7 @@ JS_SplicePrototype(JSContext* cx, HandleObject obj, HandleObject proto)
|
|||
* does not nuke type information for the object.
|
||||
*/
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, proto);
|
||||
cx->check(obj, proto);
|
||||
|
||||
if (!obj->isSingleton()) {
|
||||
/*
|
||||
|
@ -145,7 +145,7 @@ JS_NewObjectWithUniqueType(JSContext* cx, const JSClass* clasp, HandleObject pro
|
|||
JS_FRIEND_API(JSObject*)
|
||||
JS_NewObjectWithoutMetadata(JSContext* cx, const JSClass* clasp, JS::Handle<JSObject*> proto)
|
||||
{
|
||||
assertSameCompartment(cx, proto);
|
||||
cx->check(proto);
|
||||
AutoSuppressAllocationMetadataBuilder suppressMetadata(cx);
|
||||
return JS_NewObjectWithGivenProto(cx, clasp, proto);
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ JS_DefineFunctionsWithHelp(JSContext* cx, HandleObject obj, const JSFunctionSpec
|
|||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
for (; fs->name; fs++) {
|
||||
JSAtom* atom = Atomize(cx, fs->name, strlen(fs->name));
|
||||
if (!atom)
|
||||
|
@ -333,7 +333,7 @@ js::GetBuiltinClass(JSContext* cx, HandleObject obj, ESClass* cls)
|
|||
JS_FRIEND_API(const char*)
|
||||
js::ObjectClassName(JSContext* cx, HandleObject obj)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
return GetObjectClassName(cx, obj);
|
||||
}
|
||||
|
||||
|
@ -393,13 +393,13 @@ js::GetPrototypeNoProxy(JSObject* obj)
|
|||
JS_FRIEND_API(void)
|
||||
js::AssertSameCompartment(JSContext* cx, JSObject* obj)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
js::AssertSameCompartment(JSContext* cx, JS::HandleValue v)
|
||||
{
|
||||
assertSameCompartment(cx, v);
|
||||
cx->check(v);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -445,7 +445,7 @@ js::DefineFunctionWithReserved(JSContext* cx, JSObject* objArg, const char* name
|
|||
RootedObject obj(cx, objArg);
|
||||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
JSAtom* atom = Atomize(cx, name, strlen(name));
|
||||
if (!atom)
|
||||
return nullptr;
|
||||
|
@ -480,7 +480,7 @@ js::NewFunctionByIdWithReserved(JSContext* cx, JSNative native, unsigned nargs,
|
|||
MOZ_ASSERT(JSID_IS_STRING(id));
|
||||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, id);
|
||||
cx->check(id);
|
||||
|
||||
RootedAtom atom(cx, JSID_TO_ATOM(id));
|
||||
return (flags & JSFUN_CONSTRUCTOR) ?
|
||||
|
@ -513,7 +513,7 @@ js::FunctionHasNativeReserved(JSObject* fun)
|
|||
JS_FRIEND_API(bool)
|
||||
js::GetObjectProto(JSContext* cx, JS::Handle<JSObject*> obj, JS::MutableHandle<JSObject*> proto)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
if (IsProxy(obj))
|
||||
return JS_GetPrototype(cx, obj, proto);
|
||||
|
@ -659,7 +659,7 @@ JS_FRIEND_API(JSObject*)
|
|||
JS_CloneObject(JSContext* cx, HandleObject obj, HandleObject protoArg)
|
||||
{
|
||||
// |obj| might be in a different compartment.
|
||||
assertSameCompartment(cx, protoArg);
|
||||
cx->check(protoArg);
|
||||
Rooted<TaggedProto> proto(cx, TaggedProto(protoArg.get()));
|
||||
return CloneObject(cx, obj, proto);
|
||||
}
|
||||
|
@ -1120,7 +1120,7 @@ JS::ForceLexicalInitialization(JSContext *cx, HandleObject obj)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
bool initializedAny = false;
|
||||
NativeObject* nobj = &obj->as<NativeObject>();
|
||||
|
@ -1446,7 +1446,7 @@ js::GetAllocationMetadata(JSObject* obj)
|
|||
JS_FRIEND_API(bool)
|
||||
js::ReportIsNotFunction(JSContext* cx, HandleValue v)
|
||||
{
|
||||
assertSameCompartment(cx, v);
|
||||
cx->check(v);
|
||||
return ReportIsNotFunction(cx, v, -1);
|
||||
}
|
||||
|
||||
|
@ -1491,7 +1491,7 @@ js::SetWindowProxy(JSContext* cx, HandleObject global, HandleObject windowProxy)
|
|||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
assertSameCompartment(cx, global, windowProxy);
|
||||
cx->check(global, windowProxy);
|
||||
|
||||
MOZ_ASSERT(IsWindowProxy(windowProxy));
|
||||
global->as<GlobalObject>().setWindowProxy(windowProxy);
|
||||
|
|
|
@ -470,7 +470,7 @@ Proxy::enumerate(JSContext* cx, HandleObject proxy)
|
|||
return nullptr;
|
||||
if (!proto)
|
||||
return EnumeratedIdVectorToIterator(cx, proxy, props);
|
||||
assertSameCompartment(cx, proxy, proto);
|
||||
cx->check(proxy, proto);
|
||||
|
||||
AutoIdVector protoProps(cx);
|
||||
if (!GetPropertyKeys(cx, proto, 0, &protoProps))
|
||||
|
|
|
@ -479,7 +479,7 @@ NoteViewBufferWasDetached(ArrayBufferViewObject* view,
|
|||
ArrayBufferObject::detach(JSContext* cx, Handle<ArrayBufferObject*> buffer,
|
||||
BufferContents newContents)
|
||||
{
|
||||
assertSameCompartment(cx, buffer);
|
||||
cx->check(buffer);
|
||||
MOZ_ASSERT(!buffer->isPreparedForAsmJS());
|
||||
|
||||
// When detaching buffers where we don't know all views, the new data must
|
||||
|
@ -1350,7 +1350,7 @@ ArrayBufferObject::stealContents(JSContext* cx, Handle<ArrayBufferObject*> buffe
|
|||
// stealContents() is used internally by the impl of memory growth.
|
||||
MOZ_ASSERT_IF(hasStealableContents, buffer->hasStealableContents() ||
|
||||
(buffer->isWasm() && !buffer->isPreparedForAsmJS()));
|
||||
assertSameCompartment(cx, buffer);
|
||||
cx->check(buffer);
|
||||
|
||||
BufferContents oldContents = buffer->contents();
|
||||
|
||||
|
@ -1813,7 +1813,7 @@ JS_DetachArrayBuffer(JSContext* cx, HandleObject obj)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
if (!obj->is<ArrayBufferObject>()) {
|
||||
JS_ReportErrorASCII(cx, "ArrayBuffer object required");
|
||||
|
@ -1930,7 +1930,7 @@ JS_ExternalizeArrayBufferContents(JSContext* cx, HandleObject obj)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
if (!obj->is<ArrayBufferObject>()) {
|
||||
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS);
|
||||
|
@ -1962,7 +1962,7 @@ JS_StealArrayBufferContents(JSContext* cx, HandleObject objArg)
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, objArg);
|
||||
cx->check(objArg);
|
||||
|
||||
JSObject* obj = CheckedUnwrap(objArg);
|
||||
if (!obj)
|
||||
|
@ -2050,7 +2050,7 @@ JS_GetArrayBufferViewBuffer(JSContext* cx, HandleObject objArg, bool* isSharedMe
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, objArg);
|
||||
cx->check(objArg);
|
||||
|
||||
JSObject* obj = CheckedUnwrap(objArg);
|
||||
if (!obj)
|
||||
|
|
|
@ -2100,7 +2100,7 @@ ExpressionDecompiler::decompilePC(const OffsetAndDefIndex& offsetAndDefIndex)
|
|||
bool
|
||||
ExpressionDecompiler::init()
|
||||
{
|
||||
assertSameCompartment(cx, script);
|
||||
cx->check(script);
|
||||
return sprinter.init();
|
||||
}
|
||||
|
||||
|
|
|
@ -688,7 +688,7 @@ Debugger::Debugger(JSContext* cx, NativeObject* dbg)
|
|||
traceLoggerScriptedCallsLastDrainedSize(0),
|
||||
traceLoggerScriptedCallsLastDrainedIteration(0)
|
||||
{
|
||||
assertSameCompartment(cx, dbg);
|
||||
cx->check(dbg);
|
||||
|
||||
#ifdef JS_TRACE_LOGGING
|
||||
TraceLoggerThread* logger = TraceLoggerForCurrentThread(cx);
|
||||
|
@ -1154,7 +1154,7 @@ Debugger::wrapEnvironment(JSContext* cx, Handle<Env*> env,
|
|||
bool
|
||||
Debugger::wrapDebuggeeValue(JSContext* cx, MutableHandleValue vp)
|
||||
{
|
||||
assertSameCompartment(cx, object.get());
|
||||
cx->check(object.get());
|
||||
|
||||
if (vp.isObject()) {
|
||||
RootedObject obj(cx, &vp.toObject());
|
||||
|
@ -1282,7 +1282,7 @@ Debugger::unwrapDebuggeeObject(JSContext* cx, MutableHandleObject obj)
|
|||
bool
|
||||
Debugger::unwrapDebuggeeValue(JSContext* cx, MutableHandleValue vp)
|
||||
{
|
||||
assertSameCompartment(cx, object.get(), vp);
|
||||
cx->check(object.get(), vp);
|
||||
if (vp.isObject()) {
|
||||
RootedObject dobj(cx, &vp.toObject());
|
||||
if (!unwrapDebuggeeObject(cx, &dobj))
|
||||
|
@ -1671,8 +1671,8 @@ Debugger::newCompletionValue(JSContext* cx, ResumeMode resumeMode, const Value&
|
|||
{
|
||||
// We must be in the debugger's compartment, since that's where we want
|
||||
// to construct the completion value.
|
||||
assertSameCompartment(cx, object.get());
|
||||
assertSameCompartment(cx, value_);
|
||||
cx->check(object.get());
|
||||
cx->check(value_);
|
||||
|
||||
RootedId key(cx);
|
||||
RootedValue value(cx, value_);
|
||||
|
@ -2346,7 +2346,7 @@ Debugger::slowPathPromiseHook(JSContext* cx, Hook hook, Handle<PromiseObject*> p
|
|||
if (hook == OnNewPromise)
|
||||
ar.emplace(cx, promise);
|
||||
|
||||
assertSameCompartment(cx, promise);
|
||||
cx->check(promise);
|
||||
|
||||
RootedValue rval(cx);
|
||||
ResumeMode resumeMode = dispatchHook(
|
||||
|
@ -5445,7 +5445,7 @@ class DebuggerScriptSetPrivateMatcher
|
|||
NativeObject*
|
||||
Debugger::newDebuggerScript(JSContext* cx, Handle<DebuggerScriptReferent> referent)
|
||||
{
|
||||
assertSameCompartment(cx, object.get());
|
||||
cx->check(object.get());
|
||||
|
||||
RootedObject proto(cx, &object->getReservedSlot(JSSLOT_DEBUG_SCRIPT_PROTO).toObject());
|
||||
MOZ_ASSERT(proto);
|
||||
|
@ -5465,7 +5465,7 @@ JSObject*
|
|||
Debugger::wrapVariantReferent(JSContext* cx, Map& map, Handle<CrossCompartmentKey> key,
|
||||
Handle<ReferentVariant> referent)
|
||||
{
|
||||
assertSameCompartment(cx, object);
|
||||
cx->check(object);
|
||||
|
||||
Handle<Referent> untaggedReferent = referent.template as<Referent>();
|
||||
MOZ_ASSERT(cx->compartment() != untaggedReferent->compartment());
|
||||
|
@ -7239,7 +7239,7 @@ class SetDebuggerSourcePrivateMatcher
|
|||
NativeObject*
|
||||
Debugger::newDebuggerSource(JSContext* cx, Handle<DebuggerSourceReferent> referent)
|
||||
{
|
||||
assertSameCompartment(cx, object.get());
|
||||
cx->check(object.get());
|
||||
|
||||
RootedObject proto(cx, &object->getReservedSlot(JSSLOT_DEBUG_SOURCE_PROTO).toObject());
|
||||
MOZ_ASSERT(proto);
|
||||
|
@ -8192,7 +8192,7 @@ EvaluateInEnv(JSContext* cx, Handle<Env*> env, AbstractFramePtr frame,
|
|||
mozilla::Range<const char16_t> chars, const char* filename,
|
||||
unsigned lineno, MutableHandleValue rval)
|
||||
{
|
||||
assertSameCompartment(cx, env, frame);
|
||||
cx->check(env, frame);
|
||||
|
||||
CompileOptions options(cx);
|
||||
options.setIsRunOnce(true)
|
||||
|
|
|
@ -227,7 +227,7 @@ CallObject*
|
|||
CallObject::create(JSContext* cx, AbstractFramePtr frame)
|
||||
{
|
||||
MOZ_ASSERT(frame.isFunctionFrame());
|
||||
assertSameCompartment(cx, frame);
|
||||
cx->check(frame);
|
||||
|
||||
RootedObject envChain(cx, frame.environmentChain());
|
||||
RootedFunction callee(cx, frame.callee());
|
||||
|
@ -913,7 +913,7 @@ LexicalEnvironmentObject::createTemplateObject(JSContext* cx, HandleShape shape,
|
|||
LexicalEnvironmentObject::create(JSContext* cx, Handle<LexicalScope*> scope,
|
||||
HandleObject enclosing, gc::InitialHeap heap)
|
||||
{
|
||||
assertSameCompartment(cx, enclosing);
|
||||
cx->check(enclosing);
|
||||
MOZ_ASSERT(scope->hasEnvironment());
|
||||
|
||||
RootedShape shape(cx, scope->environmentShape());
|
||||
|
@ -1249,7 +1249,7 @@ EnvironmentIter::EnvironmentIter(JSContext* cx, AbstractFramePtr frame, jsbyteco
|
|||
env_(cx, frame.environmentChain()),
|
||||
frame_(frame)
|
||||
{
|
||||
assertSameCompartment(cx, frame);
|
||||
cx->check(frame);
|
||||
settle();
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
@ -1260,7 +1260,7 @@ EnvironmentIter::EnvironmentIter(JSContext* cx, JSObject* env, Scope* scope, Abs
|
|||
env_(cx, env),
|
||||
frame_(frame)
|
||||
{
|
||||
assertSameCompartment(cx, frame);
|
||||
cx->check(frame);
|
||||
settle();
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
@ -2705,7 +2705,7 @@ DebugEnvironments::takeFrameSnapshot(JSContext* cx, Handle<DebugEnvironmentProxy
|
|||
/* static */ void
|
||||
DebugEnvironments::onPopCall(JSContext* cx, AbstractFramePtr frame)
|
||||
{
|
||||
assertSameCompartment(cx, frame);
|
||||
cx->check(frame);
|
||||
|
||||
DebugEnvironments* envs = cx->realm()->debugEnvs();
|
||||
if (!envs)
|
||||
|
@ -2747,7 +2747,7 @@ DebugEnvironments::onPopCall(JSContext* cx, AbstractFramePtr frame)
|
|||
void
|
||||
DebugEnvironments::onPopLexical(JSContext* cx, AbstractFramePtr frame, jsbytecode* pc)
|
||||
{
|
||||
assertSameCompartment(cx, frame);
|
||||
cx->check(frame);
|
||||
|
||||
DebugEnvironments* envs = cx->realm()->debugEnvs();
|
||||
if (!envs)
|
||||
|
@ -2795,7 +2795,7 @@ DebugEnvironments::onPopLexical(JSContext* cx, const EnvironmentIter& ei)
|
|||
void
|
||||
DebugEnvironments::onPopVar(JSContext* cx, AbstractFramePtr frame, jsbytecode* pc)
|
||||
{
|
||||
assertSameCompartment(cx, frame);
|
||||
cx->check(frame);
|
||||
|
||||
DebugEnvironments* envs = cx->realm()->debugEnvs();
|
||||
if (!envs)
|
||||
|
@ -3115,7 +3115,7 @@ GetDebugEnvironment(JSContext* cx, const EnvironmentIter& ei)
|
|||
JSObject*
|
||||
js::GetDebugEnvironmentForFunction(JSContext* cx, HandleFunction fun)
|
||||
{
|
||||
assertSameCompartment(cx, fun);
|
||||
cx->check(fun);
|
||||
MOZ_ASSERT(CanUseDebugEnvironmentMaps(cx));
|
||||
if (!DebugEnvironments::updateLiveEnvironments(cx))
|
||||
return nullptr;
|
||||
|
@ -3129,7 +3129,7 @@ js::GetDebugEnvironmentForFunction(JSContext* cx, HandleFunction fun)
|
|||
JSObject*
|
||||
js::GetDebugEnvironmentForFrame(JSContext* cx, AbstractFramePtr frame, jsbytecode* pc)
|
||||
{
|
||||
assertSameCompartment(cx, frame);
|
||||
cx->check(frame);
|
||||
if (CanUseDebugEnvironmentMaps(cx) && !DebugEnvironments::updateLiveEnvironments(cx))
|
||||
return nullptr;
|
||||
|
||||
|
@ -3155,7 +3155,7 @@ js::CreateObjectsForEnvironmentChain(JSContext* cx, AutoObjectVector& chain,
|
|||
{
|
||||
#ifdef DEBUG
|
||||
for (size_t i = 0; i < chain.length(); ++i) {
|
||||
assertSameCompartment(cx, chain[i]);
|
||||
cx->check(chain[i]);
|
||||
MOZ_ASSERT(!chain[i]->is<GlobalObject>() &&
|
||||
!chain[i]->is<NonSyntacticVariablesObject>());
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ js::ErrorObject::init(JSContext* cx, Handle<ErrorObject*> obj, JSExnType type,
|
|||
HandleString message)
|
||||
{
|
||||
AssertObjectIsSavedFrameOrWrapper(cx, stack);
|
||||
assertSameCompartment(cx, obj, stack);
|
||||
cx->check(obj, stack);
|
||||
|
||||
// Null out early in case of error, for exn_finalize's sake.
|
||||
obj->initReservedSlot(ERROR_REPORT_SLOT, PrivateValue(nullptr));
|
||||
|
|
|
@ -816,7 +816,7 @@ GlobalObject::getDebuggers() const
|
|||
/* static */ GlobalObject::DebuggerVector*
|
||||
GlobalObject::getOrCreateDebuggers(JSContext* cx, Handle<GlobalObject*> global)
|
||||
{
|
||||
assertSameCompartment(cx, global);
|
||||
cx->check(global);
|
||||
DebuggerVector* debuggers = global->getDebuggers();
|
||||
if (debuggers)
|
||||
return debuggers;
|
||||
|
@ -835,7 +835,7 @@ GlobalObject::getOrCreateDebuggers(JSContext* cx, Handle<GlobalObject*> global)
|
|||
/* static */ NativeObject*
|
||||
GlobalObject::getOrCreateForOfPICObject(JSContext* cx, Handle<GlobalObject*> global)
|
||||
{
|
||||
assertSameCompartment(cx, global);
|
||||
cx->check(global);
|
||||
NativeObject* forOfPIC = global->getForOfPICObject();
|
||||
if (forOfPIC)
|
||||
return forOfPIC;
|
||||
|
|
|
@ -442,13 +442,13 @@ CallJSNative(JSContext* cx, Native native, const CallArgs& args)
|
|||
#ifdef DEBUG
|
||||
bool alreadyThrowing = cx->isExceptionPending();
|
||||
#endif
|
||||
assertSameCompartment(cx, args);
|
||||
cx->check(args);
|
||||
MOZ_ASSERT(!args.callee().is<ProxyObject>());
|
||||
|
||||
AutoRealm ar(cx, &args.callee());
|
||||
bool ok = native(cx, args.length(), args.base());
|
||||
if (ok) {
|
||||
assertSameCompartment(cx, args.rval());
|
||||
cx->check(args.rval());
|
||||
MOZ_ASSERT_IF(!alreadyThrowing, !cx->isExceptionPending());
|
||||
}
|
||||
return ok;
|
||||
|
@ -801,7 +801,7 @@ js::Execute(JSContext* cx, HandleScript script, JSObject& envChainArg, Value* rv
|
|||
#ifdef DEBUG
|
||||
JSObject* s = envChain;
|
||||
do {
|
||||
assertSameCompartment(cx, s);
|
||||
cx->check(s);
|
||||
MOZ_ASSERT_IF(!s->enclosingEnvironment(), s->is<GlobalObject>());
|
||||
} while ((s = s->enclosingEnvironment()));
|
||||
#endif
|
||||
|
|
|
@ -935,7 +935,7 @@ js::GetIterator(JSContext* cx, HandleObject obj)
|
|||
return nullptr;
|
||||
|
||||
PropertyIteratorObject* iterobj = &res->as<PropertyIteratorObject>();
|
||||
assertSameCompartment(cx, iterobj);
|
||||
cx->check(iterobj);
|
||||
|
||||
// Cache the iterator object.
|
||||
if (numGuards > 0) {
|
||||
|
|
|
@ -191,16 +191,16 @@ assertSameCompartmentImpl(JSContext* cx, int argIndex, const Head& head, const T
|
|||
assertSameCompartmentImpl(cx, argIndex + 1, tail...);
|
||||
}
|
||||
|
||||
} // namespace js
|
||||
|
||||
template <class... Args> inline void
|
||||
assertSameCompartment(JSContext* cx, const Args&... args)
|
||||
JSContext::check(const Args&... args)
|
||||
{
|
||||
#ifdef JS_CRASH_DIAGNOSTICS
|
||||
assertSameCompartmentImpl(cx, 1, args...);
|
||||
assertSameCompartmentImpl(this, 0, args...);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace js
|
||||
|
||||
template <class... Args> inline void
|
||||
JSContext::releaseCheck(const Args&... args)
|
||||
{
|
||||
|
@ -224,10 +224,10 @@ CallNativeImpl(JSContext* cx, NativeImpl impl, const CallArgs& args)
|
|||
#ifdef DEBUG
|
||||
bool alreadyThrowing = cx->isExceptionPending();
|
||||
#endif
|
||||
assertSameCompartment(cx, args);
|
||||
cx->check(args);
|
||||
bool ok = impl(cx, args);
|
||||
if (ok) {
|
||||
assertSameCompartment(cx, args.rval());
|
||||
cx->check(args.rval());
|
||||
MOZ_ASSERT_IF(!alreadyThrowing, !cx->isExceptionPending());
|
||||
}
|
||||
return ok;
|
||||
|
@ -240,10 +240,10 @@ CallJSGetterOp(JSContext* cx, GetterOp op, HandleObject obj, HandleId id,
|
|||
if (!CheckRecursionLimit(cx))
|
||||
return false;
|
||||
|
||||
assertSameCompartment(cx, obj, id, vp);
|
||||
cx->check(obj, id, vp);
|
||||
bool ok = op(cx, obj, id, vp);
|
||||
if (ok)
|
||||
assertSameCompartment(cx, vp);
|
||||
cx->check(vp);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ CallJSSetterOp(JSContext* cx, SetterOp op, HandleObject obj, HandleId id, Handle
|
|||
if (!CheckRecursionLimit(cx))
|
||||
return false;
|
||||
|
||||
assertSameCompartment(cx, obj, id, v);
|
||||
cx->check(obj, id, v);
|
||||
return op(cx, obj, id, v, result);
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,7 @@ CallJSAddPropertyOp(JSContext* cx, JSAddPropertyOp op, HandleObject obj, HandleI
|
|||
if (!CheckRecursionLimit(cx))
|
||||
return false;
|
||||
|
||||
assertSameCompartment(cx, obj, id, v);
|
||||
cx->check(obj, id, v);
|
||||
return op(cx, obj, id, v);
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ CallJSDeletePropertyOp(JSContext* cx, JSDeletePropertyOp op, HandleObject receiv
|
|||
if (!CheckRecursionLimit(cx))
|
||||
return false;
|
||||
|
||||
assertSameCompartment(cx, receiver, id);
|
||||
cx->check(receiver, id);
|
||||
if (op)
|
||||
return op(cx, receiver, id, result);
|
||||
return result.succeed();
|
||||
|
|
|
@ -1354,7 +1354,7 @@ JSContext::getPendingException(MutableHandleValue rval)
|
|||
clearPendingException();
|
||||
if (!compartment()->wrap(this, rval))
|
||||
return false;
|
||||
assertSameCompartment(this, rval);
|
||||
this->check(rval);
|
||||
setPendingException(rval);
|
||||
overRecursed_ = wasOverRecursed;
|
||||
return true;
|
||||
|
|
|
@ -955,6 +955,7 @@ struct JSContext : public JS::RootingContext,
|
|||
void addUnhandledRejectedPromise(JSContext* cx, js::HandleObject promise);
|
||||
void removeUnhandledRejectedPromise(JSContext* cx, js::HandleObject promise);
|
||||
|
||||
template <class... Args> inline void check(const Args&... args);
|
||||
template <class... Args> inline void releaseCheck(const Args&... args);
|
||||
template <class... Args> MOZ_ALWAYS_INLINE void debugOnlyCheck(const Args&... args);
|
||||
}; /* struct JSContext */
|
||||
|
|
|
@ -731,7 +731,7 @@ bool
|
|||
JS::OrdinaryHasInstance(JSContext* cx, HandleObject objArg, HandleValue v, bool* bp)
|
||||
{
|
||||
AssertHeapIsIdle();
|
||||
assertSameCompartment(cx, objArg, v);
|
||||
cx->check(objArg, v);
|
||||
|
||||
RootedObject obj(cx, objArg);
|
||||
|
||||
|
|
|
@ -817,7 +817,7 @@ InitClass(JSContext* cx, HandleObject obj, HandleObject parent_proto,
|
|||
MOZ_ALWAYS_INLINE const char*
|
||||
GetObjectClassName(JSContext* cx, HandleObject obj)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
if (obj->is<ProxyObject>())
|
||||
return Proxy::className(cx, obj);
|
||||
|
|
|
@ -140,7 +140,7 @@ JS::FromPropertyDescriptor(JSContext* cx, Handle<PropertyDescriptor> desc, Mutab
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, desc);
|
||||
cx->check(desc);
|
||||
|
||||
// Step 1.
|
||||
if (!desc.object()) {
|
||||
|
@ -476,7 +476,7 @@ GetSealedOrFrozenAttributes(unsigned attrs, IntegrityLevel level)
|
|||
bool
|
||||
js::SetIntegrityLevel(JSContext* cx, HandleObject obj, IntegrityLevel level)
|
||||
{
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
// Steps 3-5. (Steps 1-2 are redundant assertions.)
|
||||
if (!PreventExtensions(cx, obj))
|
||||
|
@ -1139,7 +1139,7 @@ JS_CopyPropertyFrom(JSContext* cx, HandleId id, HandleObject target,
|
|||
HandleObject obj, PropertyCopyBehavior copyBehavior)
|
||||
{
|
||||
// |obj| and |cx| are generally not same-compartment with |target| here.
|
||||
assertSameCompartment(cx, obj, id);
|
||||
cx->check(obj, id);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
|
||||
if (!GetOwnPropertyDescriptor(cx, obj, id, &desc))
|
||||
|
@ -1376,7 +1376,7 @@ InitializePropertiesFromCompatibleNativeObject(JSContext* cx,
|
|||
HandleNativeObject dst,
|
||||
HandleNativeObject src)
|
||||
{
|
||||
assertSameCompartment(cx, src, dst);
|
||||
cx->check(src, dst);
|
||||
MOZ_ASSERT(src->getClass() == dst->getClass());
|
||||
MOZ_ASSERT(dst->lastProperty()->getObjectFlags() == 0);
|
||||
MOZ_ASSERT(!src->isSingleton());
|
||||
|
@ -1445,7 +1445,7 @@ js::XDRObjectLiteral(XDRState<mode>* xdr, MutableHandleObject obj)
|
|||
/* NB: Keep this in sync with DeepCloneObjectLiteral. */
|
||||
|
||||
JSContext* cx = xdr->cx();
|
||||
assertSameCompartment(cx, obj);
|
||||
cx->check(obj);
|
||||
|
||||
// Distinguish between objects and array classes.
|
||||
uint32_t isArray = 0;
|
||||
|
|
|
@ -2753,7 +2753,7 @@ JSScript::partiallyInit(JSContext* cx, HandleScript script, uint32_t nscopes,
|
|||
uint32_t nconsts, uint32_t nobjects, uint32_t ntrynotes,
|
||||
uint32_t nscopenotes, uint32_t nyieldoffsets, uint32_t nTypeSets)
|
||||
{
|
||||
assertSameCompartment(cx, script);
|
||||
cx->check(script);
|
||||
|
||||
size_t size = ScriptDataSize(nscopes, nconsts, nobjects, ntrynotes,
|
||||
nscopenotes, nyieldoffsets);
|
||||
|
@ -3824,7 +3824,7 @@ JSScript::setNewStepMode(FreeOp* fop, uint32_t newValue)
|
|||
bool
|
||||
JSScript::incrementStepModeCount(JSContext* cx)
|
||||
{
|
||||
assertSameCompartment(cx, this);
|
||||
cx->check(this);
|
||||
MOZ_ASSERT(cx->realm()->isDebuggee());
|
||||
|
||||
AutoRealm ar(cx, this);
|
||||
|
@ -4282,7 +4282,7 @@ LazyScript::CreateRaw(JSContext* cx, HandleFunction fun,
|
|||
uint64_t packedFields, uint32_t sourceStart, uint32_t sourceEnd,
|
||||
uint32_t toStringStart, uint32_t lineno, uint32_t column)
|
||||
{
|
||||
assertSameCompartment(cx, fun);
|
||||
cx->check(fun);
|
||||
|
||||
MOZ_ASSERT(sourceObject);
|
||||
union {
|
||||
|
|
|
@ -281,7 +281,7 @@ const Class ForOfPIC::class_ = {
|
|||
/* static */ NativeObject*
|
||||
js::ForOfPIC::createForOfPICObject(JSContext* cx, Handle<GlobalObject*> global)
|
||||
{
|
||||
assertSameCompartment(cx, global);
|
||||
cx->check(global);
|
||||
NativeObject* obj = NewNativeObjectWithGivenProto(cx, &ForOfPIC::class_, nullptr);
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
|
|
|
@ -642,12 +642,12 @@ void
|
|||
Realm::setNewObjectMetadata(JSContext* cx, HandleObject obj)
|
||||
{
|
||||
MOZ_ASSERT(obj->maybeCCWRealm() == this);
|
||||
assertSameCompartment(cx, compartment(), obj);
|
||||
cx->check(compartment(), obj);
|
||||
|
||||
AutoEnterOOMUnsafeRegion oomUnsafe;
|
||||
if (JSObject* metadata = allocationMetadataBuilder_->build(cx, obj, oomUnsafe)) {
|
||||
MOZ_ASSERT(metadata->maybeCCWRealm() == obj->maybeCCWRealm());
|
||||
assertSameCompartment(cx, metadata);
|
||||
cx->check(metadata);
|
||||
|
||||
if (!objects_.objectMetadataTable) {
|
||||
auto table = cx->make_unique<ObjectWeakMap>(cx);
|
||||
|
|
|
@ -554,7 +554,7 @@ SavedFrame::initFromLookup(JSContext* cx, SavedFrame::HandleLookup lookup)
|
|||
SavedFrame::create(JSContext* cx)
|
||||
{
|
||||
RootedGlobalObject global(cx, cx->global());
|
||||
assertSameCompartment(cx, global);
|
||||
cx->check(global);
|
||||
|
||||
// Ensure that we don't try to capture the stack again in the
|
||||
// `SavedStacksMetadataBuilder` for this new SavedFrame object, and
|
||||
|
@ -564,7 +564,7 @@ SavedFrame::create(JSContext* cx)
|
|||
RootedNativeObject proto(cx, GlobalObject::getOrCreateSavedFramePrototype(cx, global));
|
||||
if (!proto)
|
||||
return nullptr;
|
||||
assertSameCompartment(cx, proto);
|
||||
cx->check(proto);
|
||||
|
||||
return NewObjectWithGivenProto<SavedFrame>(cx, proto, TenuredObject);
|
||||
}
|
||||
|
@ -1089,7 +1089,7 @@ BuildStackString(JSContext* cx, JSPrincipals* principals, HandleObject stack,
|
|||
JSString* str = sb.finishString();
|
||||
if (!str)
|
||||
return false;
|
||||
assertSameCompartment(cx, str);
|
||||
cx->check(str);
|
||||
stringp.set(str);
|
||||
return true;
|
||||
}
|
||||
|
@ -1699,7 +1699,7 @@ SavedStacks::getLocation(JSContext* cx, const FrameIter& iter,
|
|||
// the cache because our compartment's sweep method isn't called when their
|
||||
// compartment gets collected.
|
||||
MOZ_DIAGNOSTIC_ASSERT(&cx->realm()->savedStacks() == this);
|
||||
assertSameCompartment(cx, iter.compartment());
|
||||
cx->check(iter.compartment());
|
||||
|
||||
// When we have a |JSScript| for this frame, use a potentially memoized
|
||||
// location from our PCLocationMap and copy it into |locationp|. When we do
|
||||
|
|
|
@ -1559,7 +1559,7 @@ intrinsic_SetOverlappingTypedElements(JSContext* cx, unsigned argc, Value* vp)
|
|||
MOZ_ASSERT(args.length() == 3);
|
||||
|
||||
Rooted<TypedArrayObject*> target(cx, &args[0].toObject().as<TypedArrayObject>());
|
||||
assertSameCompartment(cx, target);
|
||||
cx->check(target);
|
||||
MOZ_ASSERT(!target->hasDetachedBuffer(),
|
||||
"shouldn't set elements if underlying buffer is detached");
|
||||
|
||||
|
|
|
@ -2186,7 +2186,7 @@ js::ValueToSource(JSContext* cx, HandleValue v)
|
|||
{
|
||||
if (!CheckRecursionLimit(cx))
|
||||
return nullptr;
|
||||
assertSameCompartment(cx, v);
|
||||
cx->check(v);
|
||||
|
||||
if (v.isUndefined())
|
||||
return cx->names().void0;
|
||||
|
|
|
@ -1640,7 +1640,7 @@ JSStructuredCloneWriter::traverseSavedFrame(HandleObject obj)
|
|||
bool
|
||||
JSStructuredCloneWriter::startWrite(HandleValue v)
|
||||
{
|
||||
assertSameCompartment(context(), v);
|
||||
context()->check(v);
|
||||
|
||||
if (v.isString()) {
|
||||
return writeString(SCTAG_STRING, v.toString());
|
||||
|
@ -1943,7 +1943,7 @@ JSStructuredCloneWriter::write(HandleValue v)
|
|||
|
||||
while (!counts.empty()) {
|
||||
obj = &objs.back().toObject();
|
||||
assertSameCompartment(context(), obj);
|
||||
context()->check(obj);
|
||||
if (counts.back()) {
|
||||
counts.back()--;
|
||||
key = entries.back();
|
||||
|
@ -2941,7 +2941,7 @@ JS_WriteStructuredClone(JSContext* cx, HandleValue value, JSStructuredCloneData*
|
|||
{
|
||||
AssertHeapIsIdle();
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, value);
|
||||
cx->check(value);
|
||||
|
||||
const JSStructuredCloneCallbacks* callbacks = optionalCallbacks;
|
||||
return WriteStructuredClone(cx, value, bufp, scope, cloneDataPolicy, callbacks, closure,
|
||||
|
@ -3150,7 +3150,7 @@ JS_PUBLIC_API(bool)
|
|||
JS_WriteTypedArray(JSStructuredCloneWriter* w, HandleValue v)
|
||||
{
|
||||
MOZ_ASSERT(v.isObject());
|
||||
assertSameCompartment(w->context(), v);
|
||||
w->context()->check(v);
|
||||
RootedObject obj(w->context(), &v.toObject());
|
||||
|
||||
// Note: writeTypedArray also does a CheckedUnwrap but it assumes this
|
||||
|
|
|
@ -636,7 +636,7 @@ TypeScript::MonitorAssign(JSContext* cx, HandleObject obj, jsid id)
|
|||
/* static */ inline void
|
||||
TypeScript::SetThis(JSContext* cx, JSScript* script, TypeSet::Type type)
|
||||
{
|
||||
assertSameCompartment(cx, script, type);
|
||||
cx->check(script, type);
|
||||
|
||||
AutoSweepTypeScript sweep(script);
|
||||
StackTypeSet* types = ThisTypes(script);
|
||||
|
@ -661,7 +661,7 @@ TypeScript::SetThis(JSContext* cx, JSScript* script, const js::Value& value)
|
|||
/* static */ inline void
|
||||
TypeScript::SetArgument(JSContext* cx, JSScript* script, unsigned arg, TypeSet::Type type)
|
||||
{
|
||||
assertSameCompartment(cx, script, type);
|
||||
cx->check(script, type);
|
||||
|
||||
AutoSweepTypeScript sweep(script);
|
||||
StackTypeSet* types = ArgTypes(script, arg);
|
||||
|
|
|
@ -3415,7 +3415,7 @@ js::FillBytecodeTypeMap(JSScript* script, uint32_t* bytecodeMap)
|
|||
void
|
||||
js::TypeMonitorResult(JSContext* cx, JSScript* script, jsbytecode* pc, TypeSet::Type type)
|
||||
{
|
||||
assertSameCompartment(cx, script, type);
|
||||
cx->check(script, type);
|
||||
|
||||
AutoEnterAnalysis enter(cx);
|
||||
|
||||
|
@ -3433,7 +3433,7 @@ void
|
|||
js::TypeMonitorResult(JSContext* cx, JSScript* script, jsbytecode* pc, StackTypeSet* types,
|
||||
TypeSet::Type type)
|
||||
{
|
||||
assertSameCompartment(cx, script, type);
|
||||
cx->check(script, type);
|
||||
|
||||
AutoEnterAnalysis enter(cx);
|
||||
|
||||
|
@ -3468,7 +3468,7 @@ bool
|
|||
JSScript::makeTypes(JSContext* cx)
|
||||
{
|
||||
MOZ_ASSERT(!types_);
|
||||
assertSameCompartment(cx, this);
|
||||
cx->check(this);
|
||||
|
||||
AutoEnterAnalysis enter(cx);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче