mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-09 04:25:38 +00:00
Bug 935800 - Assert that we do not GC in the lifetime of a ForkJoinSlice; r=shu
--HG-- extra : rebase_source : ec2dc1db758e5bef4720b5442e006e9df44c165b
This commit is contained in:
parent
09b5ae9027
commit
ff9029bd4e
@ -215,15 +215,18 @@ GetGCNumber();
|
||||
class JS_PUBLIC_API(AutoAssertNoGC)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
JSRuntime *runtime;
|
||||
size_t gcNumber;
|
||||
|
||||
public:
|
||||
AutoAssertNoGC();
|
||||
AutoAssertNoGC(JSRuntime *rt);
|
||||
~AutoAssertNoGC();
|
||||
#else
|
||||
public:
|
||||
/* Prevent unreferenced local warnings in opt builds. */
|
||||
AutoAssertNoGC() {}
|
||||
AutoAssertNoGC(JSRuntime *) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -5323,15 +5323,18 @@ JS::GetGCNumber()
|
||||
}
|
||||
|
||||
JS::AutoAssertNoGC::AutoAssertNoGC()
|
||||
: runtime(js::TlsPerThreadData.get()->runtimeFromMainThread())
|
||||
{
|
||||
gcNumber = runtime->gcNumber;
|
||||
}
|
||||
|
||||
JS::AutoAssertNoGC::AutoAssertNoGC(JSRuntime *rt)
|
||||
: runtime(rt), gcNumber(rt->gcNumber)
|
||||
{
|
||||
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");
|
||||
MOZ_ASSERT(gcNumber == runtime->gcNumber, "GC ran inside an AutoAssertNoGC scope.");
|
||||
}
|
||||
#endif
|
||||
|
@ -1683,7 +1683,8 @@ ForkJoinSlice::ForkJoinSlice(PerThreadData *perThreadData,
|
||||
numSlices(numSlices),
|
||||
bailoutRecord(bailoutRecord),
|
||||
shared(shared),
|
||||
acquiredContext_(false)
|
||||
acquiredContext_(false),
|
||||
nogc_(shared->runtime())
|
||||
{
|
||||
/*
|
||||
* Unsafely set the zone. This is used to track malloc counters and to
|
||||
|
@ -390,6 +390,10 @@ class ForkJoinSlice : public ThreadSafeContext
|
||||
ForkJoinShared *const shared;
|
||||
|
||||
bool acquiredContext_;
|
||||
|
||||
// ForkJoinSlice is allocated on the stack. It would be dangerous to GC
|
||||
// with it live because of the GC pointer fields stored in the context.
|
||||
JS::AutoAssertNoGC nogc_;
|
||||
};
|
||||
|
||||
// Locks a JSContext for its scope. Be very careful, because locking a
|
||||
|
Loading…
x
Reference in New Issue
Block a user