Commit 69f7fb09 authored by zerny@chromium.org's avatar zerny@chromium.org

Oilpan: Ensure that left-most vtable is the first thing to be initialized for...

Oilpan: Ensure that left-most vtable is the first thing to be initialized for polymorphic classes with trace methods.
    
This is done by ensuring one of two properties for any polymorphic class with a trace method.
1. If the trace method is virtual, then the left-most base class must define a virtual trace method too.
2. If the trace method is non-virtual, then the left-most base class must define some virtual method.
    
The Blink GC plugin statically checks these properties.

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

git-svn-id: svn://svn.chromium.org/blink/trunk@180281 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 5941f39b
......@@ -5787,6 +5787,7 @@ void Document::trace(Visitor* visitor)
TreeScope::trace(visitor);
ContainerNode::trace(visitor);
ExecutionContext::trace(visitor);
LifecycleContext<Document>::trace(visitor);
}
} // namespace blink
......
......@@ -204,7 +204,7 @@ public:
void setObservedDocument(Document&);
protected:
void trace(Visitor*);
virtual void trace(Visitor*);
private:
void registerObserver(Document&);
......
......@@ -329,6 +329,7 @@ void ExecutionContext::trace(Visitor* visitor)
visitor->trace(m_pendingExceptions);
#endif
WillBeHeapSupplementable<ExecutionContext>::trace(visitor);
LifecycleContext<ExecutionContext>::trace(visitor);
}
} // namespace blink
......@@ -1917,6 +1917,7 @@ void LocalDOMWindow::trace(Visitor* visitor)
visitor->trace(m_eventQueue);
WillBeHeapSupplementable<LocalDOMWindow>::trace(visitor);
EventTargetWithInlineData::trace(visitor);
LifecycleContext<LocalDOMWindow>::trace(visitor);
}
} // namespace blink
......@@ -94,7 +94,7 @@ public:
protected:
FormAssociatedElement();
void trace(Visitor*);
virtual void trace(Visitor*);
void insertedInto(ContainerNode*);
void removedFrom(ContainerNode*);
void didMoveToNewDocument(Document& oldDocument);
......
......@@ -596,6 +596,7 @@ void Page::trace(Visitor* visitor)
visitor->trace(m_frameHost);
#endif
WillBeHeapSupplementable<Page>::trace(visitor);
LifecycleContext<Page>::trace(visitor);
}
void Page::willBeDestroyed()
......
......@@ -58,6 +58,11 @@ public:
AbstractWorker(ExecutionContext*);
virtual ~AbstractWorker();
virtual void trace(Visitor* visitor)
{
EventTargetWithInlineData::trace(visitor);
}
protected:
// Helper function that converts a URL to an absolute URL and checks the result for validity.
KURL resolveURL(const String& url, ExceptionState&);
......
......@@ -38,7 +38,7 @@ class ExecutionContext;
class IndexedDBClient : public GarbageCollected<IndexedDBClient> {
public:
static IndexedDBClient* create();
void trace(Visitor*) { }
virtual void trace(Visitor*) { }
virtual bool allowIndexedDB(ExecutionContext*, const String& name) = 0;
};
......
......@@ -36,6 +36,8 @@
namespace blink {
class Visitor;
template <typename T>
class LifecycleContext {
public:
......@@ -53,6 +55,8 @@ public:
// Called from the destructor of observers.
void wasUnobservedBy(Observer*);
virtual void trace(Visitor*) { }
protected:
Notifier& lifecycleNotifier();
......
......@@ -119,6 +119,7 @@ template<>
class SupplementTracing<false> {
public:
virtual ~SupplementTracing() { }
virtual void trace(Visitor*) { }
};
template<typename T, bool isGarbageCollected = false>
......@@ -143,26 +144,16 @@ public:
return host ? host->requireSupplement(key) : 0;
}
virtual void trace(Visitor*) { }
virtual void willBeDestroyed() { }
// FIXME: Oilpan: Remove this callback once PersistentHeapSupplementable is removed again.
virtual void persistentHostHasBeenDestroyed() { }
};
template<typename T, bool>
class SupplementableTracing;
template<typename T>
class SupplementableTracing<T, true> { };
template<typename T>
class SupplementableTracing<T, false> { };
// Helper class for implementing Supplementable, HeapSupplementable, and
// PersistentHeapSupplementable.
template<typename T, bool isGarbageCollected = false>
class SupplementableBase : public SupplementableTracing<T, isGarbageCollected> {
class SupplementableBase {
public:
void provideSupplement(const char* key, typename SupplementableTraits<T, isGarbageCollected>::SupplementArgumentType supplement)
{
......
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