Bug 1189112 - Part 2: simplify rooting of ScriptsAndCountsVector with PersistentRooted; r=nbp

--HG--
extra : rebase_source : 3f80f8fcdcbee534c53171683d211e0ed5e25add
This commit is contained in:
Terrence Cole 2015-07-29 14:59:49 -07:00
Родитель 49c3cba496
Коммит b921a75b71
4 изменённых файлов: 38 добавлений и 23 удалений

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

@ -141,46 +141,63 @@ class MutableTraceableVectorOperations
void erase(T* aBegin, T* aEnd) { vec().erase(aBegin, aEnd); }
};
template <typename A, size_t B, typename C, typename D>
class RootedBase<TraceableVector<A,B,C,D>>
: public MutableTraceableVectorOperations<JS::Rooted<TraceableVector<A,B,C,D>>, A,B,C,D>
template <typename T, size_t N, typename AP, typename TP>
class RootedBase<TraceableVector<T,N,AP,TP>>
: public MutableTraceableVectorOperations<JS::Rooted<TraceableVector<T,N,AP,TP>>, T,N,AP,TP>
{
using Vec = TraceableVector<A,B,C,D>;
using Vec = TraceableVector<T,N,AP,TP>;
friend class TraceableVectorOperations<JS::Rooted<Vec>, A,B,C,D>;
friend class TraceableVectorOperations<JS::Rooted<Vec>, T,N,AP,TP>;
const Vec& extract() const { return *static_cast<const JS::Rooted<Vec>*>(this)->address(); }
friend class MutableTraceableVectorOperations<JS::Rooted<Vec>, A,B,C,D>;
friend class MutableTraceableVectorOperations<JS::Rooted<Vec>, T,N,AP,TP>;
Vec& extract() { return *static_cast<JS::Rooted<Vec>*>(this)->address(); }
};
template <typename A, size_t B, typename C, typename D>
class MutableHandleBase<TraceableVector<A,B,C,D>>
: public MutableTraceableVectorOperations<JS::MutableHandle<TraceableVector<A,B,C,D>>, A,B,C,D>
template <typename T, size_t N, typename AP, typename TP>
class MutableHandleBase<TraceableVector<T,N,AP,TP>>
: public MutableTraceableVectorOperations<JS::MutableHandle<TraceableVector<T,N,AP,TP>>,
T,N,AP,TP>
{
using Vec = TraceableVector<A,B,C,D>;
using Vec = TraceableVector<T,N,AP,TP>;
friend class TraceableVectorOperations<JS::MutableHandle<Vec>, A,B,C,D>;
friend class TraceableVectorOperations<JS::MutableHandle<Vec>, T,N,AP,TP>;
const Vec& extract() const {
return *static_cast<const JS::MutableHandle<Vec>*>(this)->address();
}
friend class MutableTraceableVectorOperations<JS::MutableHandle<Vec>, A,B,C,D>;
friend class MutableTraceableVectorOperations<JS::MutableHandle<Vec>, T,N,AP,TP>;
Vec& extract() { return *static_cast<JS::MutableHandle<Vec>*>(this)->address(); }
};
template <typename A, size_t B, typename C, typename D>
class HandleBase<TraceableVector<A,B,C,D>>
: public TraceableVectorOperations<JS::Handle<TraceableVector<A,B,C,D>>, A,B,C,D>
template <typename T, size_t N, typename AP, typename TP>
class HandleBase<TraceableVector<T,N,AP,TP>>
: public TraceableVectorOperations<JS::Handle<TraceableVector<T,N,AP,TP>>, T,N,AP,TP>
{
using Vec = TraceableVector<A,B,C,D>;
using Vec = TraceableVector<T,N,AP,TP>;
friend class TraceableVectorOperations<JS::Handle<Vec>, A,B,C,D>;
friend class TraceableVectorOperations<JS::Handle<Vec>, T,N,AP,TP>;
const Vec& extract() const {
return *static_cast<const JS::Handle<Vec>*>(this)->address();
}
};
template <typename T, size_t N, typename AP, typename TP>
class PersistentRootedBase<TraceableVector<T,N,AP,TP>>
: public MutableTraceableVectorOperations<JS::PersistentRooted<TraceableVector<T,N,AP,TP>>,
T,N,AP,TP>
{
using Vec = TraceableVector<T,N,AP,TP>;
friend class TraceableVectorOperations<JS::PersistentRooted<Vec>, T,N,AP,TP>;
const Vec& extract() const {
return *static_cast<const JS::PersistentRooted<Vec>*>(this)->address();
}
friend class MutableTraceableVectorOperations<JS::PersistentRooted<Vec>, T,N,AP,TP>;
Vec& extract() { return *static_cast<JS::PersistentRooted<Vec>*>(this)->address(); }
};
} // namespace js
#endif // js_TraceableVector_h

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

@ -320,9 +320,6 @@ js::gc::GCRuntime::markRuntime(JSTracer* trc, TraceOrMarkRuntime traceOrMark)
MarkPersistentRootedChains(trc);
}
if (rt->scriptAndCountsVector)
rt->scriptAndCountsVector->trace(trc);
if (!rt->isBeingDestroyed() && !rt->isHeapMinorCollecting()) {
gcstats::AutoPhase ap(stats, gcstats::PHASE_MARK_RUNTIME_DATA);

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

@ -1606,7 +1606,7 @@ ReleaseScriptCounts(FreeOp* fop)
JSRuntime* rt = fop->runtime();
MOZ_ASSERT(rt->scriptAndCountsVector);
ScriptAndCountsVector& vec = *rt->scriptAndCountsVector;
ScriptAndCountsVector& vec = rt->scriptAndCountsVector->get();
for (size_t i = 0; i < vec.length(); i++)
vec[i].scriptCounts.destroy(fop);
@ -1642,7 +1642,8 @@ js::StopPCCountProfiling(JSContext* cx)
ReleaseAllJITCode(rt->defaultFreeOp());
ScriptAndCountsVector* vec = cx->new_<ScriptAndCountsVector>(SystemAllocPolicy());
auto* vec = cx->new_<PersistentRooted<ScriptAndCountsVector>>(cx,
ScriptAndCountsVector(SystemAllocPolicy()));
if (!vec)
return;

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

@ -1053,7 +1053,7 @@ struct JSRuntime : public JS::shadow::Runtime,
#endif
/* Strong references on scripts held for PCCount profiling API. */
js::ScriptAndCountsVector* scriptAndCountsVector;
JS::PersistentRooted<js::ScriptAndCountsVector>* scriptAndCountsVector;
/* Well-known numbers held for use by this runtime's contexts. */
const js::Value NaNValue;