Commit cb1220f2 authored by kouhei@chromium.org's avatar kouhei@chromium.org

Oilpan: deprecate GCInfo::typeMarker and replace its checks w/ gcInfo ptr compare

BUG=None

Review URL: https://codereview.chromium.org/180533004

git-svn-id: svn://svn.chromium.org/blink/trunk@168616 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 2e4064f9
...@@ -320,9 +320,6 @@ public: ...@@ -320,9 +320,6 @@ public:
NO_SANITIZE_ADDRESS NO_SANITIZE_ADDRESS
const GCInfo* gcInfo() { return m_gcInfo; } const GCInfo* gcInfo() { return m_gcInfo; }
NO_SANITIZE_ADDRESS
const char* typeMarker() { return m_gcInfo->m_typeMarker; }
NO_SANITIZE_ADDRESS NO_SANITIZE_ADDRESS
TraceCallback traceCallback() { return m_gcInfo->m_trace; } TraceCallback traceCallback() { return m_gcInfo->m_trace; }
...@@ -1406,7 +1403,6 @@ struct GCInfoTrait<HashMap<Key, Value, T, U, V, HeapAllocator> > { ...@@ -1406,7 +1403,6 @@ struct GCInfoTrait<HashMap<Key, Value, T, U, V, HeapAllocator> > {
template<typename Key, typename Value, typename T, typename U, typename V> template<typename Key, typename Value, typename T, typename U, typename V>
const GCInfo GCInfoTrait<HashMap<Key, Value, T, U, V, HeapAllocator> >::info = { const GCInfo GCInfoTrait<HashMap<Key, Value, T, U, V, HeapAllocator> >::info = {
"HashMap",
TraceTrait<HashMap<Key, Value, T, U, V, HeapAllocator> >::trace, TraceTrait<HashMap<Key, Value, T, U, V, HeapAllocator> >::trace,
0, 0,
false, // HashMap needs no finalizer. false, // HashMap needs no finalizer.
...@@ -1420,7 +1416,6 @@ struct GCInfoTrait<HashSet<T, U, V, HeapAllocator> > { ...@@ -1420,7 +1416,6 @@ struct GCInfoTrait<HashSet<T, U, V, HeapAllocator> > {
template<typename T, typename U, typename V> template<typename T, typename U, typename V>
const GCInfo GCInfoTrait<HashSet<T, U, V, HeapAllocator> >::info = { const GCInfo GCInfoTrait<HashSet<T, U, V, HeapAllocator> >::info = {
"HashSet",
TraceTrait<HashSet<T, U, V, HeapAllocator> >::trace, TraceTrait<HashSet<T, U, V, HeapAllocator> >::trace,
0, 0,
false, // HashSet needs no finalizer. false, // HashSet needs no finalizer.
...@@ -1434,7 +1429,6 @@ struct GCInfoTrait<Vector<T, 0, HeapAllocator> > { ...@@ -1434,7 +1429,6 @@ struct GCInfoTrait<Vector<T, 0, HeapAllocator> > {
template<typename T> template<typename T>
const GCInfo GCInfoTrait<Vector<T, 0, HeapAllocator> >::info = { const GCInfo GCInfoTrait<Vector<T, 0, HeapAllocator> >::info = {
"Vector",
TraceTrait<Vector<T, 0, HeapAllocator> >::trace, TraceTrait<Vector<T, 0, HeapAllocator> >::trace,
0, 0,
false, // Vector needs no finalizer if it has no inline capacity. false, // Vector needs no finalizer if it has no inline capacity.
...@@ -1451,7 +1445,6 @@ struct FinalizerTrait<Vector<T, inlineCapacity, HeapAllocator> > : public Finali ...@@ -1451,7 +1445,6 @@ struct FinalizerTrait<Vector<T, inlineCapacity, HeapAllocator> > : public Finali
template<typename T, size_t inlineCapacity> template<typename T, size_t inlineCapacity>
const GCInfo GCInfoTrait<Vector<T, inlineCapacity, HeapAllocator> >::info = { const GCInfo GCInfoTrait<Vector<T, inlineCapacity, HeapAllocator> >::info = {
"Vector",
TraceTrait<Vector<T, inlineCapacity, HeapAllocator> >::trace, TraceTrait<Vector<T, inlineCapacity, HeapAllocator> >::trace,
FinalizerTrait<Vector<T, inlineCapacity, HeapAllocator> >::finalize, FinalizerTrait<Vector<T, inlineCapacity, HeapAllocator> >::finalize,
// Finalizer is needed to destruct things stored in the inline capacity. // Finalizer is needed to destruct things stored in the inline capacity.
...@@ -1466,7 +1459,6 @@ struct GCInfoTrait<HeapVectorBacking<T, Traits> > { ...@@ -1466,7 +1459,6 @@ struct GCInfoTrait<HeapVectorBacking<T, Traits> > {
template<typename T, typename Traits> template<typename T, typename Traits>
const GCInfo GCInfoTrait<HeapVectorBacking<T, Traits> >::info = { const GCInfo GCInfoTrait<HeapVectorBacking<T, Traits> >::info = {
"VectorBacking",
TraceTrait<HeapVectorBacking<T, Traits> >::trace, TraceTrait<HeapVectorBacking<T, Traits> >::trace,
FinalizerTrait<HeapVectorBacking<T, Traits> >::finalize, FinalizerTrait<HeapVectorBacking<T, Traits> >::finalize,
Traits::needsDestruction, Traits::needsDestruction,
...@@ -1480,7 +1472,6 @@ struct GCInfoTrait<HeapHashTableBacking<T, U, V, W, X> > { ...@@ -1480,7 +1472,6 @@ struct GCInfoTrait<HeapHashTableBacking<T, U, V, W, X> > {
template<typename T, typename U, typename V, typename Traits, typename W> template<typename T, typename U, typename V, typename Traits, typename W>
const GCInfo GCInfoTrait<HeapHashTableBacking<T, U, V, Traits, W> >::info = { const GCInfo GCInfoTrait<HeapHashTableBacking<T, U, V, Traits, W> >::info = {
"HashTableBacking",
TraceTrait<HeapHashTableBacking<T, U, V, Traits, W> >::trace, TraceTrait<HeapHashTableBacking<T, U, V, Traits, W> >::trace,
FinalizerTrait<HeapHashTableBacking<T, U, V, Traits, W> >::finalize, FinalizerTrait<HeapHashTableBacking<T, U, V, Traits, W> >::finalize,
Traits::needsDestruction, Traits::needsDestruction,
...@@ -1628,10 +1619,10 @@ struct TraceTrait<HeapVectorBacking<T, Traits> > { ...@@ -1628,10 +1619,10 @@ struct TraceTrait<HeapVectorBacking<T, Traits> > {
{ {
visitor->mark(backing, &trace); visitor->mark(backing, &trace);
} }
static void checkTypeMarker(Visitor* visitor, const Backing* backing) static void checkGCInfo(Visitor* visitor, const Backing* backing)
{ {
#ifndef NDEBUG #ifndef NDEBUG
visitor->checkTypeMarker(const_cast<Backing*>(backing), getTypeMarker<Backing>()); visitor->checkGCInfo(const_cast<Backing*>(backing), GCInfoTrait<Backing>::get());
#endif #endif
} }
}; };
...@@ -1657,10 +1648,10 @@ struct TraceTrait<HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTraits> ...@@ -1657,10 +1648,10 @@ struct TraceTrait<HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTraits>
else else
visitor->mark(backing, 0); visitor->mark(backing, 0);
} }
static void checkTypeMarker(Visitor* visitor, const Backing* backing) static void checkGCInfo(Visitor* visitor, const Backing* backing)
{ {
#ifndef NDEBUG #ifndef NDEBUG
visitor->checkTypeMarker(const_cast<Backing*>(backing), getTypeMarker<Backing>()); visitor->checkGCInfo(const_cast<Backing*>(backing), GCInfoTrait<Backing>::get());
#endif #endif
} }
}; };
......
...@@ -37,21 +37,20 @@ ...@@ -37,21 +37,20 @@
namespace WebCore { namespace WebCore {
#ifndef NDEBUG #ifndef NDEBUG
void Visitor::checkTypeMarker(const void* payload, const char* marker) void Visitor::checkGCInfo(const void* payload, const GCInfo* gcInfo)
{ {
FinalizedHeapObjectHeader::fromPayload(payload)->checkHeader(); FinalizedHeapObjectHeader::fromPayload(payload)->checkHeader();
ASSERT(FinalizedHeapObjectHeader::fromPayload(payload)->typeMarker() == marker); ASSERT(FinalizedHeapObjectHeader::fromPayload(payload)->gcInfo() == gcInfo);
} }
#define DEFINE_VISITOR_CHECK_MARKER(Type) \ #define DEFINE_VISITOR_CHECK_MARKER(Type) \
void Visitor::checkTypeMarker(const Type* payload, const char* marker) \ void Visitor::checkGCInfo(const Type* payload, const GCInfo* gcInfo) \
{ \ { \
HeapObjectHeader::fromPayload(payload)->checkHeader(); \ HeapObjectHeader::fromPayload(payload)->checkHeader(); \
Type* object = const_cast<Type*>(payload); \ Type* object = const_cast<Type*>(payload); \
Address addr = pageHeaderAddress(reinterpret_cast<Address>(object)); \ Address addr = pageHeaderAddress(reinterpret_cast<Address>(object)); \
BaseHeapPage* page = reinterpret_cast<BaseHeapPage*>(addr); \ BaseHeapPage* page = reinterpret_cast<BaseHeapPage*>(addr); \
ASSERT(page->gcInfo()); \ ASSERT(page->gcInfo() == gcInfo); \
ASSERT(page->gcInfo()->m_typeMarker == marker); \
} }
FOR_EACH_TYPED_HEAP(DEFINE_VISITOR_CHECK_MARKER) FOR_EACH_TYPED_HEAP(DEFINE_VISITOR_CHECK_MARKER)
...@@ -60,7 +59,6 @@ FOR_EACH_TYPED_HEAP(DEFINE_VISITOR_CHECK_MARKER) ...@@ -60,7 +59,6 @@ FOR_EACH_TYPED_HEAP(DEFINE_VISITOR_CHECK_MARKER)
#define DEFINE_DO_NOTHING_TRAIT(type) \ #define DEFINE_DO_NOTHING_TRAIT(type) \
const GCInfo GCInfoTrait<type>::info = { \ const GCInfo GCInfoTrait<type>::info = { \
#type, \
doNothingTrace, \ doNothingTrace, \
0, /* no finalizer method */ \ 0, /* no finalizer method */ \
false \ false \
......
...@@ -86,7 +86,6 @@ struct TraceMethodDelegate { ...@@ -86,7 +86,6 @@ struct TraceMethodDelegate {
// inherits from GarbageCollected or GarbageCollectedFinalized. // inherits from GarbageCollected or GarbageCollectedFinalized.
struct GCInfo { struct GCInfo {
bool hasFinalizer() const { return m_nonTrivialFinalizer; } bool hasFinalizer() const { return m_nonTrivialFinalizer; }
const char* m_typeMarker;
TraceCallback m_trace; TraceCallback m_trace;
FinalizationCallback m_finalize; FinalizationCallback m_finalize;
bool m_nonTrivialFinalizer; bool m_nonTrivialFinalizer;
...@@ -126,12 +125,6 @@ struct FinalizerTrait { ...@@ -126,12 +125,6 @@ struct FinalizerTrait {
// instances allocated in the Blink garbage-collected heap. // instances allocated in the Blink garbage-collected heap.
template<typename T> struct GCInfoTrait; template<typename T> struct GCInfoTrait;
template<typename T>
const char* getTypeMarker()
{
return GCInfoTrait<T>::get()->m_typeMarker;
}
template<typename T> class GarbageCollected; template<typename T> class GarbageCollected;
class GarbageCollectedMixin; class GarbageCollectedMixin;
template<typename T, bool = WTF::IsSubclassOfTemplate<T, GarbageCollected>::value> class NeedsAdjustAndMark; template<typename T, bool = WTF::IsSubclassOfTemplate<T, GarbageCollected>::value> class NeedsAdjustAndMark;
...@@ -177,9 +170,9 @@ public: ...@@ -177,9 +170,9 @@ public:
} }
#ifndef NDEBUG #ifndef NDEBUG
static void checkTypeMarker(Visitor* visitor, const T* t) static void checkGCInfo(Visitor* visitor, const T* t)
{ {
DefaultTraceTrait<T>::checkTypeMarker(visitor, t); DefaultTraceTrait<T>::checkGCInfo(visitor, t);
} }
#endif #endif
}; };
...@@ -220,7 +213,7 @@ public: ...@@ -220,7 +213,7 @@ public:
if (!t) if (!t)
return; return;
#ifndef NDEBUG #ifndef NDEBUG
TraceTrait<T>::checkTypeMarker(this, t); TraceTrait<T>::checkGCInfo(this, t);
#endif #endif
TraceTrait<T>::mark(this, t); TraceTrait<T>::mark(this, t);
} }
...@@ -369,12 +362,12 @@ public: ...@@ -369,12 +362,12 @@ public:
} }
#ifndef NDEBUG #ifndef NDEBUG
void checkTypeMarker(const void*, const char* marker); void checkGCInfo(const void*, const GCInfo*);
#endif #endif
// Macro to declare methods needed for each typed heap. // Macro to declare methods needed for each typed heap.
#define DECLARE_VISITOR_METHODS(Type) \ #define DECLARE_VISITOR_METHODS(Type) \
DEBUG_ONLY(void checkTypeMarker(const Type*, const char* marker);) \ DEBUG_ONLY(void checkGCInfo(const Type*, const GCInfo*);) \
virtual void mark(const Type*, TraceCallback) = 0; \ virtual void mark(const Type*, TraceCallback) = 0; \
virtual bool isMarked(const Type*) = 0; virtual bool isMarked(const Type*) = 0;
...@@ -490,7 +483,7 @@ inline void doNothingTrace(Visitor*, void*) { } ...@@ -490,7 +483,7 @@ inline void doNothingTrace(Visitor*, void*) { }
template<> \ template<> \
class TraceTrait<type> { \ class TraceTrait<type> { \
public: \ public: \
static void checkTypeMarker(Visitor*, const void*) { } \ static void checkGCInfo(Visitor*, const void*) { } \
static void mark(Visitor* visitor, const type* p) { \ static void mark(Visitor* visitor, const type* p) { \
visitor->mark(p, reinterpret_cast<TraceCallback>(0)); \ visitor->mark(p, reinterpret_cast<TraceCallback>(0)); \
} \ } \
...@@ -516,13 +509,6 @@ ITERATE_DO_NOTHING_TYPES(DECLARE_DO_NOTHING_TRAIT) ...@@ -516,13 +509,6 @@ ITERATE_DO_NOTHING_TYPES(DECLARE_DO_NOTHING_TRAIT)
template<typename T> template<typename T>
class DefaultTraceTrait<T, false> { class DefaultTraceTrait<T, false> {
public: public:
// Default implementation of TraceTrait<T>::trace just statically
// dispatches to the trace method of the class T.
static void trace(Visitor* visitor, void* self)
{
static_cast<T*>(self)->trace(visitor);
}
static void mark(Visitor* visitor, const T* t) static void mark(Visitor* visitor, const T* t)
{ {
// Default mark method of the trait just calls the two-argument mark // Default mark method of the trait just calls the two-argument mark
...@@ -533,9 +519,9 @@ public: ...@@ -533,9 +519,9 @@ public:
} }
#ifndef NDEBUG #ifndef NDEBUG
static void checkTypeMarker(Visitor* visitor, const T* t) static void checkGCInfo(Visitor* visitor, const T* t)
{ {
visitor->checkTypeMarker(const_cast<T*>(t), getTypeMarker<T>()); visitor->checkGCInfo(const_cast<T*>(t), GCInfoTrait<T>::get());
} }
#endif #endif
}; };
...@@ -549,7 +535,7 @@ public: ...@@ -549,7 +535,7 @@ public:
} }
#ifndef NDEBUG #ifndef NDEBUG
static void checkTypeMarker(Visitor*, const T*) { } static void checkGCInfo(Visitor*, const T*) { }
#endif #endif
}; };
...@@ -632,9 +618,7 @@ template<typename T> ...@@ -632,9 +618,7 @@ template<typename T>
struct GCInfoAtBase { struct GCInfoAtBase {
static const GCInfo* get() static const GCInfo* get()
{ {
static char pseudoTypeMarker = 'a';
static const GCInfo gcInfo = { static const GCInfo gcInfo = {
&pseudoTypeMarker,
TraceTrait<T>::trace, TraceTrait<T>::trace,
FinalizerTrait<T>::finalize, FinalizerTrait<T>::finalize,
FinalizerTrait<T>::nonTrivialFinalizer, FinalizerTrait<T>::nonTrivialFinalizer,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment