mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 1297244 - Assert on the type given as a parameter to Heap. r=terrence
--HG-- extra : rebase_source : 2523f190a45bf3669f40392226df6a0b6fbc9806
This commit is contained in:
parent
85000b8d09
commit
2df9fd1853
@ -116,6 +116,12 @@ struct BarrierMethods<nsXBLMaybeCompiled<UncompiledT>>
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct IsHeapConstructibleType<nsXBLMaybeCompiled<T>>
|
||||
{ // Yes, this is the exception to the rule. Sorry.
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
template <class UncompiledT>
|
||||
class HeapBase<nsXBLMaybeCompiled<UncompiledT>>
|
||||
{
|
||||
|
@ -45,6 +45,23 @@
|
||||
#include "js/TraceKind.h"
|
||||
#include "js/TracingAPI.h"
|
||||
|
||||
// Expand the given macro D for each public GC pointer.
|
||||
#define FOR_EACH_PUBLIC_GC_POINTER_TYPE(D) \
|
||||
D(JS::Symbol*) \
|
||||
D(JSAtom*) \
|
||||
D(JSFunction*) \
|
||||
D(JSObject*) \
|
||||
D(JSScript*) \
|
||||
D(JSString*)
|
||||
|
||||
// Expand the given macro D for each public tagged GC pointer type.
|
||||
#define FOR_EACH_PUBLIC_TAGGED_GC_POINTER_TYPE(D) \
|
||||
D(JS::Value) \
|
||||
D(jsid)
|
||||
|
||||
#define FOR_EACH_PUBLIC_AGGREGATE_GC_POINTER_TYPE(D) \
|
||||
D(JSPropertyDescriptor)
|
||||
|
||||
class JSAtom;
|
||||
class JSFunction;
|
||||
class JSObject;
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include "mozilla/Move.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "jspubtd.h"
|
||||
|
||||
#include "js/GCAnnotations.h"
|
||||
@ -123,6 +125,14 @@ class MutableHandleBase {};
|
||||
template <typename T>
|
||||
class HeapBase {};
|
||||
|
||||
// Cannot use FOR_EACH_HEAP_ABLE_GC_POINTER_TYPE, as this would import too many macros into scope
|
||||
template <typename T> struct IsHeapConstructibleType { static constexpr bool value = false; };
|
||||
#define DECLARE_IS_HEAP_CONSTRUCTIBLE_TYPE(T) \
|
||||
template <> struct IsHeapConstructibleType<T> { static constexpr bool value = true; };
|
||||
FOR_EACH_PUBLIC_GC_POINTER_TYPE(DECLARE_IS_HEAP_CONSTRUCTIBLE_TYPE)
|
||||
FOR_EACH_PUBLIC_TAGGED_GC_POINTER_TYPE(DECLARE_IS_HEAP_CONSTRUCTIBLE_TYPE)
|
||||
#undef DECLARE_IS_HEAP_CONSTRUCTIBLE_TYPE
|
||||
|
||||
template <typename T>
|
||||
class PersistentRootedBase {};
|
||||
|
||||
@ -214,11 +224,14 @@ AssertGCThingIsNotAnObjectSubclass(js::gc::Cell* cell) {}
|
||||
* Heap<T> objects should only be used on the heap. GC references stored on the
|
||||
* C/C++ stack must use Rooted/Handle/MutableHandle instead.
|
||||
*
|
||||
* Type T must be one of: JS::Value, jsid, JSObject*, JSString*, JSScript*
|
||||
* Type T must be a public GC pointer type.
|
||||
*/
|
||||
template <typename T>
|
||||
class Heap : public js::HeapBase<T>
|
||||
{
|
||||
// Please note: this can actually also be used by nsXBLMaybeCompiled<T>, for legacy reasons.
|
||||
static_assert(js::IsHeapConstructibleType<T>::value,
|
||||
"Type T must be a public GC pointer type");
|
||||
public:
|
||||
Heap() {
|
||||
static_assert(sizeof(T) == sizeof(Heap<T>),
|
||||
|
@ -2791,9 +2791,12 @@ EdgeNeedsSweep(JS::Heap<T>* thingp)
|
||||
template bool IsMarked<type>(WriteBarrieredBase<type>*); \
|
||||
template bool IsAboutToBeFinalizedUnbarriered<type>(type*); \
|
||||
template bool IsAboutToBeFinalized<type>(WriteBarrieredBase<type>*); \
|
||||
template bool IsAboutToBeFinalized<type>(ReadBarrieredBase<type>*); \
|
||||
template bool IsAboutToBeFinalized<type>(ReadBarrieredBase<type>*);
|
||||
#define INSTANTIATE_ALL_VALID_HEAP_TRACE_FUNCTIONS(type) \
|
||||
template JS_PUBLIC_API(bool) EdgeNeedsSweep<type>(JS::Heap<type>*);
|
||||
FOR_EACH_GC_POINTER_TYPE(INSTANTIATE_ALL_VALID_TRACE_FUNCTIONS)
|
||||
FOR_EACH_PUBLIC_GC_POINTER_TYPE(INSTANTIATE_ALL_VALID_HEAP_TRACE_FUNCTIONS)
|
||||
FOR_EACH_PUBLIC_TAGGED_GC_POINTER_TYPE(INSTANTIATE_ALL_VALID_HEAP_TRACE_FUNCTIONS)
|
||||
#undef INSTANTIATE_ALL_VALID_TRACE_FUNCTIONS
|
||||
|
||||
} /* namespace gc */
|
||||
|
@ -58,23 +58,6 @@ class JitCode;
|
||||
} // namespace jit
|
||||
} // namespace js
|
||||
|
||||
// Expand the given macro D for each public GC pointer.
|
||||
#define FOR_EACH_PUBLIC_GC_POINTER_TYPE(D) \
|
||||
D(JS::Symbol*) \
|
||||
D(JSAtom*) \
|
||||
D(JSFunction*) \
|
||||
D(JSObject*) \
|
||||
D(JSScript*) \
|
||||
D(JSString*)
|
||||
|
||||
// Expand the given macro D for each public tagged GC pointer type.
|
||||
#define FOR_EACH_PUBLIC_TAGGED_GC_POINTER_TYPE(D) \
|
||||
D(JS::Value) \
|
||||
D(jsid)
|
||||
|
||||
#define FOR_EACH_PUBLIC_AGGREGATE_GC_POINTER_TYPE(D) \
|
||||
D(JSPropertyDescriptor)
|
||||
|
||||
// Expand the given macro D for each valid GC reference type.
|
||||
#define FOR_EACH_INTERNAL_GC_POINTER_TYPE(D) \
|
||||
D(JSFlatString*) \
|
||||
|
Loading…
Reference in New Issue
Block a user