Bug 1154923 - Add a version of assertSameCompartment that works in all versions. r=terrence

Use it in initFromOptions and finishParseTask.
This commit is contained in:
Andrew McCreight 2016-06-27 16:06:30 +02:00
Родитель 5e9d303d47
Коммит bb3afa86eb
3 изменённых файлов: 9 добавлений и 4 удалений

Просмотреть файл

@ -21,7 +21,6 @@
namespace js {
#ifdef JS_CRASH_DIAGNOSTICS
class CompartmentChecker
{
JSCompartment* compartment;
@ -135,7 +134,6 @@ class CompartmentChecker
check(desc.value());
}
};
#endif /* JS_CRASH_DIAGNOSTICS */
/*
* Don't perform these checks when called from a finalizer. The checking
@ -146,6 +144,13 @@ class CompartmentChecker
return; \
CompartmentChecker c(cx)
template <class T1> inline void
releaseAssertSameCompartment(ExclusiveContext* cx, const T1& t1)
{
START_ASSERT_SAME_COMPARTMENT();
c.check(t1);
}
template <class T1> inline void
assertSameCompartment(ExclusiveContext* cx, const T1& t1)
{

Просмотреть файл

@ -1684,7 +1684,7 @@ ScriptSourceObject::create(ExclusiveContext* cx, ScriptSource* source)
ScriptSourceObject::initFromOptions(JSContext* cx, HandleScriptSource source,
const ReadOnlyCompileOptions& options)
{
assertSameCompartment(cx, source);
releaseAssertSameCompartment(cx, source);
MOZ_ASSERT(source->getReservedSlot(ELEMENT_SLOT).isMagic(JS_GENERIC_MAGIC));
MOZ_ASSERT(source->getReservedSlot(ELEMENT_PROPERTY_SLOT).isMagic(JS_GENERIC_MAGIC));
MOZ_ASSERT(source->getReservedSlot(INTRODUCTION_SCRIPT_SLOT).isMagic(JS_GENERIC_MAGIC));

Просмотреть файл

@ -1171,7 +1171,7 @@ GlobalHelperThreadState::finishParseTask(JSContext* maybecx, JSRuntime* rt, Pars
return nullptr;
RootedScript script(rt, parseTask->script);
assertSameCompartment(cx, script);
releaseAssertSameCompartment(cx, script);
// Report out of memory errors eagerly, or errors could be malformed.
if (parseTask->outOfMemory) {