提交 e9e27699 编写于 作者: E Eric Seidel

Remove GarbageCollectedFinalized

This class didn't actually do anything anymore.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/655083003
上级 de0ba17e
......@@ -49,11 +49,10 @@ namespace blink {
// return self->bindToV8Function();
// }
// };
class ScriptFunction : public GarbageCollectedFinalized<ScriptFunction> {
class ScriptFunction {
public:
virtual ~ScriptFunction() { }
ScriptState* scriptState() const { return m_scriptState.get(); }
virtual void trace(Visitor*) { }
protected:
explicit ScriptFunction(ScriptState* scriptState)
......
......@@ -20,7 +20,7 @@ class DOMWrapperWorld;
class ExecutionContext;
class ScriptState;
class ScriptPromisePropertyBase : public GarbageCollectedFinalized<ScriptPromisePropertyBase>, public ContextLifecycleObserver {
class ScriptPromisePropertyBase : public ContextLifecycleObserver {
public:
virtual ~ScriptPromisePropertyBase();
......
......@@ -21,11 +21,4 @@ namespace blink {
{% endfor %}
}
void {{cpp_class}}::trace(Visitor* visitor)
{
{% for member in members if member.is_traceable %}
visitor->trace(m_{{member.name}});
{% endfor %}
}
} // namespace blink
......@@ -13,7 +13,7 @@
namespace blink {
class {{cpp_class}} final : public GarbageCollectedFinalized<{{cpp_class}}> {
class {{cpp_class}} final {
public:
static {{cpp_class}}* create()
{
......@@ -26,8 +26,6 @@ public:
void {{member.setter_name}}({{member.rvalue_cpp_type}} value) { m_{{member.name}} = value; }
{% endfor %}
void trace(Visitor*);
private:
{{cpp_class}}();
......
......@@ -57,15 +57,9 @@ class FontResource;
class FontsReadyPromiseResolver;
class ExecutionContext;
#if ENABLE(OILPAN)
class FontFaceSet final : public GarbageCollectedFinalized<FontFaceSet>, public HeapSupplement<Document>, public ActiveDOMObject, public EventTargetWithInlineData {
USING_GARBAGE_COLLECTED_MIXIN(FontFaceSet);
typedef HeapSupplement<Document> SupplementType;
#else
class FontFaceSet final : public RefCountedSupplement<Document, FontFaceSet>, public ActiveDOMObject, public EventTargetWithInlineData {
DEFINE_EVENT_TARGET_REFCOUNTING(RefCounted<FontFaceSet>);
typedef RefCountedSupplement<Document, FontFaceSet> SupplementType;
#endif
DEFINE_WRAPPERTYPEINFO();
public:
virtual ~FontFaceSet();
......
......@@ -49,15 +49,9 @@ class UniqueElementData;
class ElementData : public RefCounted<ElementData> {
WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
public:
#if ENABLE(OILPAN)
// Override GarbageCollectedFinalized's finalizeGarbageCollectedObject to
// dispatch to the correct subclass destructor.
void finalizeGarbageCollectedObject();
#else
// Override RefCounted's deref() to ensure operator delete is called on
// the appropriate subclass type.
void deref();
#endif
void clearClass() const { m_classNames.clear(); }
void setClass(const AtomicString& className, bool shouldFoldCase) const { m_classNames.set(className, shouldFoldCase); }
......
......@@ -106,13 +106,9 @@ protected:
RenderObject* m_renderer;
};
#if ENABLE(OILPAN)
#define NODE_BASE_CLASSES public GarbageCollectedFinalized<Node>, public EventTarget
#else
// TreeShared should be the last to pack TreeShared::m_refCount and
// Node::m_nodeFlags on 64bit platforms.
#define NODE_BASE_CLASSES public EventTarget, public TreeShared<Node>
#endif
class Node : NODE_BASE_CLASSES {
DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(TreeShared<Node>);
......
......@@ -196,9 +196,6 @@ private:
friend class ThreadState;
};
template<typename T>
class CrossThreadPersistent;
// Persistent handles are used to store pointers into the
// managed heap. As long as the Persistent handle is alive
// the GC will keep the object pointed to alive. Persistent
......@@ -328,97 +325,8 @@ public:
T* get() const { return m_raw; }
private:
#if ENABLE(GC_PROFILE_MARKING)
void recordBacktrace()
{
if (m_raw)
m_tracingName = Heap::createBacktraceString();
}
String m_tracingName;
#else
inline void recordBacktrace() const { }
#endif
T* m_raw;
friend class CrossThreadPersistent<T>;
};
// FIXME: derive affinity based on the collection.
template<typename Collection, ThreadAffinity Affinity = AnyThread>
class PersistentHeapCollectionBase
: public Collection
, public PersistentBase<ThreadLocalPersistents<Affinity>, PersistentHeapCollectionBase<Collection, Affinity> > {
// We overload the various new and delete operators with using the WTF DefaultAllocator to ensure persistent
// heap collections are always allocated off-heap. This allows persistent collections to be used in
// DEFINE_STATIC_LOCAL et. al.
WTF_USE_ALLOCATOR(PersistentHeapCollectionBase, WTF::DefaultAllocator);
public:
PersistentHeapCollectionBase() { }
template<typename OtherCollection>
PersistentHeapCollectionBase(const OtherCollection& other) : Collection(other) { }
void trace(Visitor* visitor)
{
#if ENABLE(GC_PROFILE_MARKING)
visitor->setHostInfo(this, "PersistentHeapCollectionBase");
#endif
visitor->trace(*static_cast<Collection*>(this));
}
};
template<
typename KeyArg,
typename MappedArg,
typename HashArg = typename DefaultHash<KeyArg>::Hash,
typename KeyTraitsArg = HashTraits<KeyArg>,
typename MappedTraitsArg = HashTraits<MappedArg> >
class PersistentHeapHashMap : public PersistentHeapCollectionBase<HeapHashMap<KeyArg, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg> > { };
template<
typename ValueArg,
typename HashArg = typename DefaultHash<ValueArg>::Hash,
typename TraitsArg = HashTraits<ValueArg> >
class PersistentHeapHashSet : public PersistentHeapCollectionBase<HeapHashSet<ValueArg, HashArg, TraitsArg> > { };
template<
typename ValueArg,
typename HashArg = typename DefaultHash<ValueArg>::Hash,
typename TraitsArg = HashTraits<ValueArg> >
class PersistentHeapLinkedHashSet : public PersistentHeapCollectionBase<HeapLinkedHashSet<ValueArg, HashArg, TraitsArg> > { };
template<
typename ValueArg,
size_t inlineCapacity = 0,
typename HashArg = typename DefaultHash<ValueArg>::Hash>
class PersistentHeapListHashSet : public PersistentHeapCollectionBase<HeapListHashSet<ValueArg, inlineCapacity, HashArg> > { };
template<typename T, typename U, typename V>
class PersistentHeapHashCountedSet : public PersistentHeapCollectionBase<HeapHashCountedSet<T, U, V> > { };
template<typename T, size_t inlineCapacity = 0>
class PersistentHeapVector : public PersistentHeapCollectionBase<HeapVector<T, inlineCapacity> > {
public:
PersistentHeapVector() { }
template<size_t otherCapacity>
PersistentHeapVector(const HeapVector<T, otherCapacity>& other)
: PersistentHeapCollectionBase<HeapVector<T, inlineCapacity> >(other)
{
}
};
template<typename T, size_t inlineCapacity = 0>
class PersistentHeapDeque : public PersistentHeapCollectionBase<HeapDeque<T, inlineCapacity> > {
public:
PersistentHeapDeque() { }
template<size_t otherCapacity>
PersistentHeapDeque(const HeapDeque<T, otherCapacity>& other)
: PersistentHeapCollectionBase<HeapDeque<T, inlineCapacity> >(other)
{
}
};
// Members are used in classes to contain strong pointers to other oilpan heap
......@@ -852,14 +760,6 @@ struct PointerParamStorageTraits<T*, false> {
static T* unwrap(const StorageType& value) { return value; }
};
template<typename T>
struct PointerParamStorageTraits<T*, true> {
typedef blink::CrossThreadPersistent<T> StorageType;
static StorageType wrap(T* value) { return value; }
static T* unwrap(const StorageType& value) { return value.get(); }
};
template<typename T>
struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, false> {
};
......
......@@ -109,7 +109,6 @@ class HeapStats;
class PageMemory;
template<ThreadAffinity affinity> class ThreadLocalPersistents;
template<typename T, typename RootsAccessor = ThreadLocalPersistents<ThreadingTrait<T>::Affinity > > class Persistent;
template<typename T> class CrossThreadPersistent;
#if ENABLE(GC_PROFILE_HEAP)
class TracedValue;
......@@ -683,61 +682,6 @@ public:
class HeapDoesNotContainCache : public HeapExtentCache<NegativeEntry> { };
// FIXME: This is currently used by the WebAudio code.
// We should attempt to restructure the WebAudio code so that the main thread
// alone determines life-time and receives messages about life-time from the
// audio thread.
template<typename T>
class ThreadSafeRefCountedGarbageCollected : public GarbageCollectedFinalized<T>, public WTF::ThreadSafeRefCountedBase {
WTF_MAKE_NONCOPYABLE(ThreadSafeRefCountedGarbageCollected);
public:
ThreadSafeRefCountedGarbageCollected()
{
makeKeepAlive();
}
// Override ref to deal with a case where a reference count goes up
// from 0 to 1. This can happen in the following scenario:
// (1) The reference count becomes 0, but on-stack pointers keep references to the object.
// (2) The on-stack pointer is assigned to a RefPtr. The reference count becomes 1.
// In this case, we have to resurrect m_keepAlive.
void ref()
{
MutexLocker lock(m_mutex);
if (UNLIKELY(!refCount())) {
makeKeepAlive();
}
WTF::ThreadSafeRefCountedBase::ref();
}
// Override deref to deal with our own deallocation based on ref counting.
void deref()
{
MutexLocker lock(m_mutex);
if (derefBase()) {
ASSERT(m_keepAlive);
m_keepAlive.clear();
}
}
using GarbageCollectedFinalized<T>::operator new;
using GarbageCollectedFinalized<T>::operator delete;
protected:
~ThreadSafeRefCountedGarbageCollected() { }
private:
void makeKeepAlive()
{
ASSERT(!m_keepAlive);
m_keepAlive = adoptPtr(new CrossThreadPersistent<T>(static_cast<T*>(this)));
}
OwnPtr<CrossThreadPersistent<T> > m_keepAlive;
mutable Mutex m_mutex;
};
template<typename DataType>
class PagePool {
protected:
......@@ -1208,81 +1152,6 @@ private:
bool m_active;
};
// Base class for objects allocated in the Blink garbage-collected
// heap.
//
// Defines a 'new' operator that allocates the memory in the
// heap. 'delete' should not be called on objects that inherit from
// GarbageCollected.
//
// Instances of GarbageCollected will *NOT* get finalized. Their
// destructor will not be called. Therefore, only classes that have
// trivial destructors with no semantic meaning (including all their
// subclasses) should inherit from GarbageCollected. If there are
// non-trival destructors in a given class or any of its subclasses,
// GarbageCollectedFinalized should be used which guarantees that the
// destructor is called on an instance when the garbage collector
// determines that it is no longer reachable.
template<typename T>
class GarbageCollected {
WTF_MAKE_NONCOPYABLE(GarbageCollected);
// For now direct allocation of arrays on the heap is not allowed.
void* operator new[](size_t size);
void operator delete[](void* p);
public:
typedef T GarbageCollectedBase;
void* operator new(size_t size)
{
return Heap::allocate<T>(size);
}
void operator delete(void* p)
{
ASSERT_NOT_REACHED();
}
protected:
GarbageCollected()
{
}
};
// Base class for objects allocated in the Blink garbage-collected
// heap.
//
// Defines a 'new' operator that allocates the memory in the
// heap. 'delete' should not be called on objects that inherit from
// GarbageCollected.
//
// Instances of GarbageCollectedFinalized will have their destructor
// called when the garbage collector determines that the object is no
// longer reachable.
template<typename T>
class GarbageCollectedFinalized : public GarbageCollected<T> {
WTF_MAKE_NONCOPYABLE(GarbageCollectedFinalized);
protected:
// finalizeGarbageCollectedObject is called when the object is
// freed from the heap. By default finalization means calling the
// destructor on the object. finalizeGarbageCollectedObject can be
// overridden to support calling the destructor of a
// subclass. This is useful for objects without vtables that
// require explicit dispatching. The name is intentionally a bit
// long to make name conflicts less likely.
void finalizeGarbageCollectedObject()
{
static_cast<T*>(this)->~T();
}
GarbageCollectedFinalized() { }
~GarbageCollectedFinalized() { }
template<typename U> friend struct HasFinalizer;
template<typename U, bool> friend struct FinalizerTraitImpl;
};
// Base class for objects that are in the Blink garbage-collected heap
// and are still reference counted.
//
......
......@@ -42,27 +42,8 @@
namespace blink {
#if INSIDE_BLINK
enum LifetimeManagementType {
RefCountedLifetime,
GarbageCollectedLifetime,
RefCountedGarbageCollectedLifetime
};
template<typename T>
class LifetimeOf {
static const bool isGarbageCollected = WTF::IsSubclassOfTemplate<T, GarbageCollected>::value;
static const bool isRefCountedGarbageCollected = WTF::IsSubclassOfTemplate<T, RefCountedGarbageCollected>::value;
public:
static const LifetimeManagementType value =
!isGarbageCollected ? RefCountedLifetime :
isRefCountedGarbageCollected ? RefCountedGarbageCollectedLifetime : GarbageCollectedLifetime;
};
template<typename T, LifetimeManagementType lifetime>
class PtrStorageImpl;
template<typename T>
class PtrStorageImpl<T, RefCountedLifetime> {
class PtrStorageImpl {
public:
typedef PassRefPtr<T> BlinkPtrType;
......@@ -93,48 +74,7 @@ private:
};
template<typename T>
class PtrStorageImpl<T, GarbageCollectedLifetime> {
public:
void assign(const RawPtr<T>& val)
{
if (!val) {
release();
return;
}
if (!m_handle)
m_handle = new Persistent<T>();
(*m_handle) = val;
}
void assign(T* ptr) { assign(RawPtr<T>(ptr)); }
template<typename U> void assign(const RawPtr<U>& val) { assign(RawPtr<T>(val)); }
void assign(const PtrStorageImpl& other) { assign(other.get()); }
T* get() const { return m_handle ? m_handle->get() : 0; }
void release()
{
delete m_handle;
m_handle = 0;
}
private:
Persistent<T>* m_handle;
};
template<typename T>
class PtrStorageImpl<T, RefCountedGarbageCollectedLifetime> : public PtrStorageImpl<T, GarbageCollectedLifetime> {
public:
void assign(const PassRefPtr<T>& val) { PtrStorageImpl<T, GarbageCollectedLifetime>::assign(val.get()); }
void assign(const PtrStorageImpl& other) { PtrStorageImpl<T, GarbageCollectedLifetime>::assign(other.get()); }
};
template<typename T>
class PtrStorage : public PtrStorageImpl<T, LifetimeOf<T>::value> {
class PtrStorage : public PtrStorageImpl<T> {
public:
static PtrStorage& fromSlot(void** slot)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册