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