Backed out changeset 0e35830f4a25 (bug 1679736) for rust failure CLOSED TREE

This commit is contained in:
Bogdan Tara 2020-12-03 07:23:55 +02:00
Родитель 5669c53aa8
Коммит 5e1d8e41d2
3 изменённых файлов: 29 добавлений и 44 удалений

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

@ -925,22 +925,15 @@ 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
// Our instantiations of Rooted<void*> and PersistentRooted<void*> require an
// instantiation of MapTypeToRootKind.
template <>
struct MapTypeToRootKind<detail::RootListEntry*> {
struct MapTypeToRootKind<void*> {
static const RootKind kind = RootKind::Traceable;
};
using RootedListHeads =
mozilla::EnumeratedArray<RootKind, RootKind::Limit,
Rooted<detail::RootListEntry*>*>;
mozilla::EnumeratedArray<RootKind, RootKind::Limit, Rooted<void*>*>;
using AutoRooterListHeads =
mozilla::EnumeratedArray<AutoGCRooterKind, AutoGCRooterKind::Limit,
@ -1080,7 +1073,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 = reinterpret_cast<Rooted<detail::RootListEntry*>*>(this);
*stack = reinterpret_cast<Rooted<void*>*>(this);
}
inline RootedListHeads& rootLists(RootingContext* cx) {
@ -1130,8 +1123,7 @@ class MOZ_RAII Rooted : public js::RootedBase<T, Rooted<T>> {
}
~Rooted() {
MOZ_ASSERT(*stack ==
reinterpret_cast<Rooted<detail::RootListEntry*>*>(this));
MOZ_ASSERT(*stack == reinterpret_cast<Rooted<void*>*>(this));
*stack = prev;
}
@ -1163,12 +1155,12 @@ class MOZ_RAII Rooted : public js::RootedBase<T, Rooted<T>> {
private:
/*
* 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.
* These need to be templated on void* 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;
Rooted<void*>** stack;
Rooted<void*>* prev;
Ptr ptr;
@ -1297,13 +1289,11 @@ inline MutableHandle<T>::MutableHandle(PersistentRooted<T>* root) {
ptr = root->address();
}
JS_PUBLIC_API void AddPersistentRoot(
RootingContext* cx, RootKind kind,
PersistentRooted<detail::RootListEntry*>* root);
JS_PUBLIC_API void AddPersistentRoot(RootingContext* cx, RootKind kind,
PersistentRooted<void*>* root);
JS_PUBLIC_API void AddPersistentRoot(
JSRuntime* rt, RootKind kind,
PersistentRooted<detail::RootListEntry*>* root);
JS_PUBLIC_API void AddPersistentRoot(JSRuntime* rt, RootKind kind,
PersistentRooted<void*>* root);
/**
* A copyable, assignable global GC root type with arbitrary lifetime, an
@ -1352,17 +1342,15 @@ class PersistentRooted
void registerWithRootLists(RootingContext* cx) {
MOZ_ASSERT(!initialized());
JS::RootKind kind = JS::MapTypeToRootKind<T>::kind;
AddPersistentRoot(
cx, kind,
reinterpret_cast<JS::PersistentRooted<detail::RootListEntry*>*>(this));
AddPersistentRoot(cx, kind,
reinterpret_cast<JS::PersistentRooted<void*>*>(this));
}
void registerWithRootLists(JSRuntime* rt) {
MOZ_ASSERT(!initialized());
JS::RootKind kind = JS::MapTypeToRootKind<T>::kind;
AddPersistentRoot(
rt, kind,
reinterpret_cast<JS::PersistentRooted<detail::RootListEntry*>*>(this));
AddPersistentRoot(rt, kind,
reinterpret_cast<JS::PersistentRooted<void*>*>(this));
}
public:

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

@ -75,9 +75,9 @@ inline void JS::PersistentRooted<T>::trace(JSTracer* trc, const char* name) {
}
template <typename T>
static inline void TraceExactStackRootList(
JSTracer* trc, JS::Rooted<JS::detail::RootListEntry*>* listHead,
const char* name) {
static inline void TraceExactStackRootList(JSTracer* trc,
JS::Rooted<void*>* 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,8 +112,7 @@ static void TraceExactStackRoots(JSContext* cx, JSTracer* trc) {
template <typename T>
static inline void TracePersistentRootedList(
JSTracer* trc,
LinkedList<PersistentRooted<JS::detail::RootListEntry*>>& list,
JSTracer* trc, LinkedList<PersistentRooted<void*>>& list,
const char* name) {
auto& typedList = reinterpret_cast<LinkedList<PersistentRooted<T>>&>(list);
for (PersistentRooted<T>* root : typedList) {
@ -145,7 +144,7 @@ static void TracePersistentRooted(JSRuntime* rt, JSTracer* trc) {
template <typename T>
static void FinishPersistentRootedChain(
LinkedList<PersistentRooted<JS::detail::RootListEntry*>>& listArg) {
LinkedList<PersistentRooted<void*>>& listArg) {
auto& list = reinterpret_cast<LinkedList<PersistentRooted<T>>&>(listArg);
while (!list.isEmpty()) {
list.getFirst()->reset();
@ -635,15 +634,13 @@ void GCRuntime::resetBufferedGrayRoots() {
}
}
JS_PUBLIC_API void JS::AddPersistentRoot(
JS::RootingContext* cx, RootKind kind,
PersistentRooted<JS::detail::RootListEntry*>* root) {
JS_PUBLIC_API void JS::AddPersistentRoot(JS::RootingContext* cx, RootKind kind,
PersistentRooted<void*>* root) {
static_cast<JSContext*>(cx)->runtime()->heapRoots.ref()[kind].insertBack(
root);
}
JS_PUBLIC_API void JS::AddPersistentRoot(
JSRuntime* rt, RootKind kind,
PersistentRooted<JS::detail::RootListEntry*>* root) {
JS_PUBLIC_API void JS::AddPersistentRoot(JSRuntime* rt, RootKind kind,
PersistentRooted<void*>* root) {
rt->heapRoots.ref()[kind].insertBack(root);
}

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

@ -394,7 +394,7 @@ struct JSRuntime {
// Heap GC roots for PersistentRooted pointers.
js::MainThreadData<mozilla::EnumeratedArray<
JS::RootKind, JS::RootKind::Limit,
mozilla::LinkedList<JS::PersistentRooted<JS::detail::RootListEntry*>>>>
mozilla::LinkedList<JS::PersistentRooted<void*>>>>
heapRoots;
void tracePersistentRoots(JSTracer* trc);