mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 883450 - Assert that we're in a request whenever we create a Rooted<T>. r=terrence
This commit is contained in:
parent
2fa8b1cfb0
commit
68f0e73503
@ -497,6 +497,12 @@ struct GCMethods<T *>
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(DEBUG) && defined(JS_THREADSAFE)
|
||||
/* This helper allows us to assert that Rooted<T> is scoped within a request. */
|
||||
extern JS_PUBLIC_API(bool)
|
||||
IsInRequest(JSContext *cx);
|
||||
#endif
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
namespace JS {
|
||||
@ -513,6 +519,10 @@ template <typename T>
|
||||
class MOZ_STACK_CLASS Rooted : public js::RootedBase<T>
|
||||
{
|
||||
void init(JSContext *cxArg) {
|
||||
MOZ_ASSERT(cxArg);
|
||||
#ifdef JS_THREADSAFE
|
||||
MOZ_ASSERT(js::IsInRequest(cxArg));
|
||||
#endif
|
||||
#if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING)
|
||||
js::ContextFriendFields *cx = js::ContextFriendFields::get(cxArg);
|
||||
commonInit(cx->thingGCRooters);
|
||||
@ -520,6 +530,7 @@ class MOZ_STACK_CLASS Rooted : public js::RootedBase<T>
|
||||
}
|
||||
|
||||
void init(js::PerThreadDataFriendFields *pt) {
|
||||
MOZ_ASSERT(pt);
|
||||
#if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING)
|
||||
commonInit(pt->thingGCRooters);
|
||||
#endif
|
||||
|
@ -1108,3 +1108,11 @@ js_ReportIsNotFunction(JSContext *cx, const JS::Value& v)
|
||||
{
|
||||
return ReportIsNotFunction(cx, v);
|
||||
}
|
||||
|
||||
#if defined(DEBUG) && defined(JS_THREADSAFE)
|
||||
JS_PUBLIC_API(bool)
|
||||
js::IsInRequest(JSContext *cx)
|
||||
{
|
||||
return !!cx->runtime()->requestDepth;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user