зеркало из https://github.com/mozilla/gecko-dev.git
Bug 916986 - Implement a JSAutoAssertNoGC for the analysis to pay attention to, r=terrence
This commit is contained in:
Родитель
d4b22fae39
Коммит
016400d5a3
|
@ -208,6 +208,19 @@ PokeGC(JSRuntime *rt);
|
|||
extern JS_FRIEND_API(bool)
|
||||
WasIncrementalGC(JSRuntime *rt);
|
||||
|
||||
extern JS_FRIEND_API(size_t)
|
||||
GetGCNumber();
|
||||
|
||||
class AutoAssertNoGC {
|
||||
#ifdef DEBUG
|
||||
size_t gcNumber;
|
||||
|
||||
public:
|
||||
AutoAssertNoGC();
|
||||
~AutoAssertNoGC();
|
||||
#endif
|
||||
};
|
||||
|
||||
class JS_PUBLIC_API(ObjectPtr)
|
||||
{
|
||||
Heap<JSObject *> value;
|
||||
|
|
|
@ -5219,4 +5219,26 @@ JS::AssertGCThingMustBeTenured(JSObject *obj)
|
|||
JS_ASSERT((!IsNurseryAllocable(obj->tenuredGetAllocKind()) || obj->getClass()->finalize) &&
|
||||
obj->isTenured());
|
||||
}
|
||||
|
||||
JS_FRIEND_API(size_t)
|
||||
JS::GetGCNumber()
|
||||
{
|
||||
JSRuntime *rt = js::TlsPerThreadData.get()->runtimeFromMainThread();
|
||||
if (!rt)
|
||||
return 0;
|
||||
return rt->gcNumber;
|
||||
}
|
||||
|
||||
JS::AutoAssertNoGC::AutoAssertNoGC()
|
||||
{
|
||||
JSRuntime *rt = js::TlsPerThreadData.get()->runtimeFromMainThread();
|
||||
gcNumber = rt ? rt->gcNumber : size_t(-1);
|
||||
}
|
||||
|
||||
JS::AutoAssertNoGC::~AutoAssertNoGC()
|
||||
{
|
||||
JSRuntime *rt = js::TlsPerThreadData.get()->runtimeFromMainThread();
|
||||
if (rt)
|
||||
MOZ_ASSERT(gcNumber == rt->gcNumber, "GC ran inside an AutoAssertNoGC scope");
|
||||
}
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче