Bug 865222 - Add MOZ_GUARD_OBJECT_NOTIFIER_PARAM to JSAutoCompartment and JSAutoNullableCompartment; r=efaust

This commit is contained in:
Kyle Machulis 2015-04-26 08:49:03 -07:00
parent 9e840f0fdb
commit f5855dda46
2 changed files with 19 additions and 6 deletions

View File

@ -908,19 +908,23 @@ JS_LeaveCompartment(JSContext* cx, JSCompartment* oldCompartment)
cx->leaveCompartment(oldCompartment);
}
JSAutoCompartment::JSAutoCompartment(JSContext* cx, JSObject* target)
JSAutoCompartment::JSAutoCompartment(JSContext* cx, JSObject* target
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: cx_(cx),
oldCompartment_(cx->compartment())
{
AssertHeapIsIdleOrIterating(cx_);
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
cx_->enterCompartment(target->compartment());
}
JSAutoCompartment::JSAutoCompartment(JSContext* cx, JSScript* target)
JSAutoCompartment::JSAutoCompartment(JSContext* cx, JSScript* target
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: cx_(cx),
oldCompartment_(cx->compartment())
{
AssertHeapIsIdleOrIterating(cx_);
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
cx_->enterCompartment(target->compartment());
}
@ -930,11 +934,13 @@ JSAutoCompartment::~JSAutoCompartment()
}
JSAutoNullableCompartment::JSAutoNullableCompartment(JSContext* cx,
JSObject* targetOrNull)
JSObject* targetOrNull
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: cx_(cx),
oldCompartment_(cx->compartment())
{
AssertHeapIsIdleOrIterating(cx_);
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
if (targetOrNull) {
cx_->enterCompartment(targetOrNull->compartment());
} else {

View File

@ -1448,9 +1448,13 @@ class JS_PUBLIC_API(JSAutoCompartment)
JSContext* cx_;
JSCompartment* oldCompartment_;
public:
JSAutoCompartment(JSContext* cx, JSObject* target);
JSAutoCompartment(JSContext* cx, JSScript* target);
JSAutoCompartment(JSContext* cx, JSObject* target
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
JSAutoCompartment(JSContext* cx, JSScript* target
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
~JSAutoCompartment();
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};
class JS_PUBLIC_API(JSAutoNullableCompartment)
@ -1458,8 +1462,11 @@ class JS_PUBLIC_API(JSAutoNullableCompartment)
JSContext* cx_;
JSCompartment* oldCompartment_;
public:
explicit JSAutoNullableCompartment(JSContext* cx, JSObject* targetOrNull);
explicit JSAutoNullableCompartment(JSContext* cx, JSObject* targetOrNull
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
~JSAutoNullableCompartment();
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};
/* NB: This API is infallible; a nullptr return value does not indicate error. */