Backed out 3 changesets (bug 1716247) for causing jsreftest failures. CLOSED TREE

Backed out changeset 58137e59d8fc (bug 1716247)
Backed out changeset 0ea7f627a717 (bug 1716247)
Backed out changeset c52f0e7918ec (bug 1716247)
This commit is contained in:
Sandor Molnar 2021-06-15 21:51:23 +03:00
Родитель 7a16af4434
Коммит 2eb4c5bf69
3 изменённых файлов: 74 добавлений и 43 удалений

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

@ -124,11 +124,8 @@ template <typename Element, typename Wrapper>
class MutableWrappedPtrOperations
: public WrappedPtrOperations<Element, Wrapper> {};
class RootedUntypedBase {};
template <typename T, typename Wrapper>
class RootedBase : public RootedUntypedBase,
public MutableWrappedPtrOperations<T, Wrapper> {};
class RootedBase : public MutableWrappedPtrOperations<T, Wrapper> {};
template <typename T, typename Wrapper>
class HandleBase : public WrappedPtrOperations<T, Wrapper> {};
@ -139,9 +136,6 @@ class MutableHandleBase : public MutableWrappedPtrOperations<T, Wrapper> {};
template <typename T, typename Wrapper>
class HeapBase : public MutableWrappedPtrOperations<T, Wrapper> {};
class PersistentRootedBase
: public mozilla::LinkedListElement<PersistentRootedBase> {};
// Cannot use FOR_EACH_HEAP_ABLE_GC_POINTER_TYPE, as this would import too many
// macros into scope
template <typename T>
@ -157,8 +151,13 @@ JS_FOR_EACH_PUBLIC_GC_POINTER_TYPE(DECLARE_IS_HEAP_CONSTRUCTIBLE_TYPE)
JS_FOR_EACH_PUBLIC_TAGGED_GC_POINTER_TYPE(DECLARE_IS_HEAP_CONSTRUCTIBLE_TYPE)
#undef DECLARE_IS_HEAP_CONSTRUCTIBLE_TYPE
template <typename T, typename Wrapper>
class PersistentRootedBase : public MutableWrappedPtrOperations<T, Wrapper> {};
namespace gc {
struct Cell;
template <typename T>
struct PersistentRootedMarker;
} /* namespace gc */
// Important: Return a reference so passing a Rooted<T>, etc. to
@ -929,8 +928,22 @@ enum class AutoGCRooterKind : uint8_t {
Limit
};
namespace detail {
// Dummy type to store root list entry pointers as. This code does not just use
// the actual type, because then eg JSObject* and JSFunction* would be assumed
// to never alias but they do (they are stored in the same list). Also, do not
// use `void*` so that `Rooted<void*>` is a compile error.
struct RootListEntry;
} // namespace detail
template <>
struct MapTypeToRootKind<detail::RootListEntry*> {
static const RootKind kind = RootKind::Traceable;
};
using RootedListHeads =
mozilla::EnumeratedArray<RootKind, RootKind::Limit, js::RootedUntypedBase*>;
mozilla::EnumeratedArray<RootKind, RootKind::Limit,
Rooted<detail::RootListEntry*>*>;
using AutoRooterListHeads =
mozilla::EnumeratedArray<AutoGCRooterKind, AutoGCRooterKind::Limit,
@ -1098,7 +1111,7 @@ class MOZ_RAII Rooted : public js::RootedBase<T, Rooted<T>> {
inline void registerWithRootLists(RootedListHeads& roots) {
this->stack = &roots[JS::MapTypeToRootKind<T>::kind];
this->prev = *stack;
*stack = this;
*stack = reinterpret_cast<Rooted<detail::RootListEntry*>*>(this);
}
inline RootedListHeads& rootLists(RootingContext* cx) {
@ -1148,7 +1161,8 @@ class MOZ_RAII Rooted : public js::RootedBase<T, Rooted<T>> {
}
~Rooted() {
MOZ_ASSERT(*stack == this);
MOZ_ASSERT(*stack ==
reinterpret_cast<Rooted<detail::RootListEntry*>*>(this));
*stack = prev;
}
@ -1179,8 +1193,13 @@ class MOZ_RAII Rooted : public js::RootedBase<T, Rooted<T>> {
void trace(JSTracer* trc, const char* name);
private:
js::RootedUntypedBase** stack;
js::RootedUntypedBase* prev;
/*
* These need to be templated on RootListEntry* to avoid aliasing issues
* between, for example, Rooted<JSObject*> and Rooted<JSFunction*>, which use
* the same stack head pointer for different classes.
*/
Rooted<detail::RootListEntry*>** stack;
Rooted<detail::RootListEntry*>* prev;
Ptr ptr;
@ -1243,8 +1262,7 @@ inline ProfilingStack* GetContextProfilingStackIfEnabled(JSContext* cx) {
*/
template <typename Container>
class RootedBase<JSObject*, Container>
: public RootedUntypedBase,
public MutableWrappedPtrOperations<JSObject*, Container> {
: public MutableWrappedPtrOperations<JSObject*, Container> {
public:
template <class U>
JS::Handle<U*> as() const;
@ -1310,11 +1328,13 @@ inline MutableHandle<T>::MutableHandle(PersistentRooted<T>* root) {
ptr = root->address();
}
JS_PUBLIC_API void AddPersistentRoot(RootingContext* cx, RootKind kind,
js::PersistentRootedBase* root);
JS_PUBLIC_API void AddPersistentRoot(
RootingContext* cx, RootKind kind,
PersistentRooted<detail::RootListEntry*>* root);
JS_PUBLIC_API void AddPersistentRoot(JSRuntime* rt, RootKind kind,
js::PersistentRootedBase* root);
JS_PUBLIC_API void AddPersistentRoot(
JSRuntime* rt, RootKind kind,
PersistentRooted<detail::RootListEntry*>* root);
/**
* A copyable, assignable global GC root type with arbitrary lifetime, an
@ -1350,8 +1370,10 @@ JS_PUBLIC_API void AddPersistentRoot(JSRuntime* rt, RootKind kind,
* marked when the object itself is marked.
*/
template <typename T>
class PersistentRooted : public js::PersistentRootedBase,
public js::RootedBase<T, PersistentRooted<T>> {
class PersistentRooted
: public js::RootedBase<T, PersistentRooted<T>>,
private mozilla::LinkedListElement<PersistentRooted<T>> {
using ListBase = mozilla::LinkedListElement<PersistentRooted<T>>;
using Ptr = detail::RootedPtr<T>;
using PtrTraits = detail::RootedPtrTraits<T>;
@ -1361,13 +1383,17 @@ class PersistentRooted : public js::PersistentRootedBase,
void registerWithRootLists(RootingContext* cx) {
MOZ_ASSERT(!initialized());
JS::RootKind kind = JS::MapTypeToRootKind<T>::kind;
AddPersistentRoot(cx, kind, this);
AddPersistentRoot(
cx, kind,
reinterpret_cast<JS::PersistentRooted<detail::RootListEntry*>*>(this));
}
void registerWithRootLists(JSRuntime* rt) {
MOZ_ASSERT(!initialized());
JS::RootKind kind = JS::MapTypeToRootKind<T>::kind;
AddPersistentRoot(rt, kind, this);
AddPersistentRoot(
rt, kind,
reinterpret_cast<JS::PersistentRooted<detail::RootListEntry*>*>(this));
}
public:
@ -1404,7 +1430,7 @@ class PersistentRooted : public js::PersistentRootedBase,
}
PersistentRooted(const PersistentRooted& rhs)
: PersistentRootedBase(), ptr(rhs.ptr) {
: mozilla::LinkedListElement<PersistentRooted<T>>(), ptr(rhs.ptr) {
/*
* Copy construction takes advantage of the fact that the original
* is already inserted, and simply adds itself to whatever list the
@ -1416,7 +1442,7 @@ class PersistentRooted : public js::PersistentRootedBase,
const_cast<PersistentRooted&>(rhs).setNext(this);
}
bool initialized() const { return PersistentRootedBase::isInList(); }
bool initialized() const { return ListBase::isInList(); }
void init(RootingContext* cx) { init(cx, SafelyInitialized<T>()); }
void init(JSContext* cx) { init(RootingContext::get(cx)); }
@ -1435,7 +1461,7 @@ class PersistentRooted : public js::PersistentRootedBase,
void reset() {
if (initialized()) {
set(SafelyInitialized<T>());
PersistentRootedBase::remove();
ListBase::remove();
}
}

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

@ -75,10 +75,10 @@ inline void JS::PersistentRooted<T>::trace(JSTracer* trc, const char* name) {
}
template <typename T>
static inline void TraceExactStackRootList(JSTracer* trc,
RootedUntypedBase* listHead,
const char* name) {
auto* typedList = static_cast<JS::Rooted<T>*>(listHead);
static inline void TraceExactStackRootList(
JSTracer* trc, JS::Rooted<JS::detail::RootListEntry*>* listHead,
const char* name) {
auto* typedList = reinterpret_cast<JS::Rooted<T>*>(listHead);
for (JS::Rooted<T>* root = typedList; root; root = root->previous()) {
root->trace(trc, name);
}
@ -112,9 +112,12 @@ static void TraceExactStackRoots(JSContext* cx, JSTracer* trc) {
template <typename T>
static inline void TracePersistentRootedList(
JSTracer* trc, LinkedList<PersistentRootedBase>& list, const char* name) {
for (PersistentRootedBase* root : list) {
static_cast<PersistentRooted<T>*>(root)->trace(trc, name);
JSTracer* trc,
LinkedList<PersistentRooted<JS::detail::RootListEntry*>>& list,
const char* name) {
auto& typedList = reinterpret_cast<LinkedList<PersistentRooted<T>>&>(list);
for (PersistentRooted<T>* root : typedList) {
root->trace(trc, name);
}
}
@ -142,9 +145,10 @@ static void TracePersistentRooted(JSRuntime* rt, JSTracer* trc) {
template <typename T>
static void FinishPersistentRootedChain(
LinkedList<PersistentRootedBase>& listArg) {
while (!listArg.isEmpty()) {
static_cast<PersistentRooted<T>*>(listArg.getFirst())->reset();
LinkedList<PersistentRooted<JS::detail::RootListEntry*>>& listArg) {
auto& list = reinterpret_cast<LinkedList<PersistentRooted<T>>&>(listArg);
while (!list.isEmpty()) {
list.getFirst()->reset();
}
}
@ -617,14 +621,15 @@ void GCRuntime::resetBufferedGrayRoots() {
}
}
JS_PUBLIC_API void JS::AddPersistentRoot(JS::RootingContext* cx,
JS::RootKind kind,
PersistentRootedBase* root) {
JS_PUBLIC_API void JS::AddPersistentRoot(
JS::RootingContext* cx, RootKind kind,
PersistentRooted<JS::detail::RootListEntry*>* root) {
static_cast<JSContext*>(cx)->runtime()->heapRoots.ref()[kind].insertBack(
root);
}
JS_PUBLIC_API void JS::AddPersistentRoot(JSRuntime* rt, JS::RootKind kind,
PersistentRootedBase* root) {
JS_PUBLIC_API void JS::AddPersistentRoot(
JSRuntime* rt, RootKind kind,
PersistentRooted<JS::detail::RootListEntry*>* root) {
rt->heapRoots.ref()[kind].insertBack(root);
}

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

@ -397,9 +397,9 @@ struct JSRuntime {
js::GeckoProfilerRuntime& geckoProfiler() { return geckoProfiler_.ref(); }
// Heap GC roots for PersistentRooted pointers.
js::MainThreadData<
mozilla::EnumeratedArray<JS::RootKind, JS::RootKind::Limit,
mozilla::LinkedList<js::PersistentRootedBase>>>
js::MainThreadData<mozilla::EnumeratedArray<
JS::RootKind, JS::RootKind::Limit,
mozilla::LinkedList<JS::PersistentRooted<JS::detail::RootListEntry*>>>>
heapRoots;
void tracePersistentRoots(JSTracer* trc);