зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1690111 - Add JS::AutoCheckCannotGC::reset. r=peterv
Depends on D131301 Differential Revision: https://phabricator.services.mozilla.com/D185069
This commit is contained in:
Родитель
e980e4478d
Коммит
7eea5225b7
|
@ -1045,16 +1045,25 @@ class JS_PUBLIC_API AutoRequireNoGC {
|
||||||
class JS_PUBLIC_API AutoAssertNoGC : public AutoRequireNoGC {
|
class JS_PUBLIC_API AutoAssertNoGC : public AutoRequireNoGC {
|
||||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||||
protected:
|
protected:
|
||||||
JSContext* cx_;
|
JSContext* cx_; // nullptr if inactive.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// This gets the context from TLS if it is not passed in.
|
// Nullptr here means get the context from TLS. It does not mean inactive
|
||||||
|
// (though cx_ may end up nullptr, and thus inactive, if TLS has not yet been
|
||||||
|
// initialized.)
|
||||||
explicit AutoAssertNoGC(JSContext* cx = nullptr);
|
explicit AutoAssertNoGC(JSContext* cx = nullptr);
|
||||||
|
AutoAssertNoGC(AutoAssertNoGC&& other) : cx_(other.cx_) {
|
||||||
|
other.cx_ = nullptr;
|
||||||
|
}
|
||||||
~AutoAssertNoGC();
|
~AutoAssertNoGC();
|
||||||
|
|
||||||
|
void reset();
|
||||||
#else
|
#else
|
||||||
public:
|
public:
|
||||||
explicit AutoAssertNoGC(JSContext* cx = nullptr) {}
|
explicit AutoAssertNoGC(JSContext* cx = nullptr) {}
|
||||||
~AutoAssertNoGC() {}
|
~AutoAssertNoGC() {}
|
||||||
|
|
||||||
|
void reset() {}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1125,11 +1134,15 @@ class JS_PUBLIC_API AutoCheckCannotGC : public AutoAssertNoGC {
|
||||||
# else
|
# else
|
||||||
AutoCheckCannotGC(const AutoCheckCannotGC& other) : AutoCheckCannotGC() {}
|
AutoCheckCannotGC(const AutoCheckCannotGC& other) : AutoCheckCannotGC() {}
|
||||||
# endif
|
# endif
|
||||||
|
AutoCheckCannotGC(AutoCheckCannotGC&& other)
|
||||||
|
: AutoAssertNoGC(std::forward<AutoAssertNoGC>(other)) {}
|
||||||
#else
|
#else
|
||||||
class JS_PUBLIC_API AutoCheckCannotGC : public AutoRequireNoGC {
|
class JS_PUBLIC_API AutoCheckCannotGC : public AutoRequireNoGC {
|
||||||
public:
|
public:
|
||||||
explicit AutoCheckCannotGC(JSContext* cx = nullptr) {}
|
explicit AutoCheckCannotGC(JSContext* cx = nullptr) {}
|
||||||
AutoCheckCannotGC(const AutoCheckCannotGC& other) : AutoCheckCannotGC() {}
|
AutoCheckCannotGC(const AutoCheckCannotGC& other) : AutoCheckCannotGC() {}
|
||||||
|
AutoCheckCannotGC(AutoCheckCannotGC&& other) : AutoCheckCannotGC() {}
|
||||||
|
void reset() {}
|
||||||
#endif
|
#endif
|
||||||
} JS_HAZ_GC_INVALIDATED JS_HAZ_GC_REF;
|
} JS_HAZ_GC_INVALIDATED JS_HAZ_GC_REF;
|
||||||
|
|
||||||
|
|
|
@ -157,10 +157,13 @@ JS::AutoAssertNoGC::AutoAssertNoGC(JSContext* maybecx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::AutoAssertNoGC::~AutoAssertNoGC() {
|
JS::AutoAssertNoGC::~AutoAssertNoGC() { reset(); }
|
||||||
|
|
||||||
|
void JS::AutoAssertNoGC::reset() {
|
||||||
if (cx_) {
|
if (cx_) {
|
||||||
MOZ_ASSERT(cx_->inUnsafeRegion > 0);
|
MOZ_ASSERT(cx_->inUnsafeRegion > 0);
|
||||||
cx_->inUnsafeRegion--;
|
cx_->inUnsafeRegion--;
|
||||||
|
cx_ = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче