summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/v8/V8GCController.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/bindings/v8/V8GCController.cpp')
-rw-r--r--WebCore/bindings/v8/V8GCController.cpp89
1 files changed, 38 insertions, 51 deletions
diff --git a/WebCore/bindings/v8/V8GCController.cpp b/WebCore/bindings/v8/V8GCController.cpp
index b478636..61b2a88 100644
--- a/WebCore/bindings/v8/V8GCController.cpp
+++ b/WebCore/bindings/v8/V8GCController.cpp
@@ -31,11 +31,18 @@
#include "config.h"
#include "V8GCController.h"
+#include "ActiveDOMObject.h"
+#include "Attr.h"
#include "DOMDataStore.h"
-#include "DOMObjectsInclude.h"
+#include "Frame.h"
+#include "HTMLImageElement.h"
+#include "HTMLNames.h"
+#include "MessagePort.h"
+#include "SVGElement.h"
#include "V8DOMMap.h"
-#include "V8Index.h"
+#include "V8MessagePort.h"
#include "V8Proxy.h"
+#include "WrapperTypeInfo.h"
#include <algorithm>
#include <utility>
@@ -112,7 +119,7 @@ static void enumerateDOMObjectMap(DOMObjectMap& wrapperMap)
{
for (DOMObjectMap::iterator it = wrapperMap.begin(), end = wrapperMap.end(); it != end; ++it) {
v8::Persistent<v8::Object> wrapper(it->second);
- V8ClassIndex::V8WrapperType type = V8DOMWrapper::domWrapperType(wrapper);
+ WrapperTypeInfo* type = V8DOMWrapper::domWrapperType(wrapper);
void* object = it->first;
UNUSED_PARAM(type);
UNUSED_PARAM(object);
@@ -123,7 +130,7 @@ class DOMObjectVisitor : public DOMWrapperMap<void>::Visitor {
public:
void visitDOMWrapper(void* object, v8::Persistent<v8::Object> wrapper)
{
- V8ClassIndex::V8WrapperType type = V8DOMWrapper::domWrapperType(wrapper);
+ WrapperTypeInfo* type = V8DOMWrapper::domWrapperType(wrapper);
UNUSED_PARAM(type);
UNUSED_PARAM(object);
}
@@ -181,36 +188,26 @@ class GCPrologueVisitor : public DOMWrapperMap<void>::Visitor {
public:
void visitDOMWrapper(void* object, v8::Persistent<v8::Object> wrapper)
{
- ASSERT(wrapper.IsWeak());
- V8ClassIndex::V8WrapperType type = V8DOMWrapper::domWrapperType(wrapper);
- switch (type) {
-#define MAKE_CASE(TYPE, NAME) \
- case V8ClassIndex::TYPE: { \
- NAME* impl = static_cast<NAME*>(object); \
- if (impl->hasPendingActivity()) \
- wrapper.ClearWeak(); \
- break; \
- }
- ACTIVE_DOM_OBJECT_TYPES(MAKE_CASE)
- default:
- ASSERT_NOT_REACHED();
-#undef MAKE_CASE
+ WrapperTypeInfo* typeInfo = V8DOMWrapper::domWrapperType(wrapper);
+
+ // Additional handling of message port ensuring that entangled ports also
+ // have their wrappers entangled. This should ideally be handled when the
+ // ports are actually entangled in MessagePort::entangle, but to avoid
+ // forking MessagePort.* this is postponed to GC time. Having this postponed
+ // has the drawback that the wrappers are "entangled/unentangled" for each
+ // GC even though their entaglement most likely is still the same.
+ if (V8MessagePort::info.equals(typeInfo)) {
+ // Mark each port as in-use if it's entangled. For simplicity's sake, we assume all ports are remotely entangled,
+ // since the Chromium port implementation can't tell the difference.
+ MessagePort* port1 = static_cast<MessagePort*>(object);
+ if (port1->isEntangled() || port1->hasPendingActivity())
+ wrapper.ClearWeak();
+ } else {
+ ActiveDOMObject* activeDOMObject = typeInfo->toActiveDOMObject(wrapper);
+ if (activeDOMObject && activeDOMObject->hasPendingActivity())
+ wrapper.ClearWeak();
}
-
- // Additional handling of message port ensuring that entangled ports also
- // have their wrappers entangled. This should ideally be handled when the
- // ports are actually entangled in MessagePort::entangle, but to avoid
- // forking MessagePort.* this is postponed to GC time. Having this postponed
- // has the drawback that the wrappers are "entangled/unentangled" for each
- // GC even though their entaglement most likely is still the same.
- if (type == V8ClassIndex::MESSAGEPORT) {
- // Mark each port as in-use if it's entangled. For simplicity's sake, we assume all ports are remotely entangled,
- // since the Chromium port implementation can't tell the difference.
- MessagePort* port1 = static_cast<MessagePort*>(object);
- if (port1->isEntangled())
- wrapper.ClearWeak();
}
-}
};
class GrouperItem {
@@ -369,30 +366,20 @@ class GCEpilogueVisitor : public DOMWrapperMap<void>::Visitor {
public:
void visitDOMWrapper(void* object, v8::Persistent<v8::Object> wrapper)
{
- V8ClassIndex::V8WrapperType type = V8DOMWrapper::domWrapperType(wrapper);
- switch (type) {
-#define MAKE_CASE(TYPE, NAME) \
- case V8ClassIndex::TYPE: { \
- NAME* impl = static_cast<NAME*>(object); \
- if (impl->hasPendingActivity()) { \
- ASSERT(!wrapper.IsWeak()); \
- wrapper.MakeWeak(impl, &DOMDataStore::weakActiveDOMObjectCallback); \
- } \
- break; \
- }
-ACTIVE_DOM_OBJECT_TYPES(MAKE_CASE)
- default:
- ASSERT_NOT_REACHED();
-#undef MAKE_CASE
- }
-
- if (type == V8ClassIndex::MESSAGEPORT) {
+ WrapperTypeInfo* typeInfo = V8DOMWrapper::domWrapperType(wrapper);
+ if (V8MessagePort::info.equals(typeInfo)) {
MessagePort* port1 = static_cast<MessagePort*>(object);
// We marked this port as reachable in GCPrologueVisitor. Undo this now since the
// port could be not reachable in the future if it gets disentangled (and also
// GCPrologueVisitor expects to see all handles marked as weak).
- if (!wrapper.IsWeak() && !wrapper.IsNearDeath())
+ if ((!wrapper.IsWeak() && !wrapper.IsNearDeath()) || port1->hasPendingActivity())
wrapper.MakeWeak(port1, &DOMDataStore::weakActiveDOMObjectCallback);
+ } else {
+ ActiveDOMObject* activeDOMObject = typeInfo->toActiveDOMObject(wrapper);
+ if (activeDOMObject && activeDOMObject->hasPendingActivity()) {
+ ASSERT(!wrapper.IsWeak());
+ wrapper.MakeWeak(activeDOMObject, &DOMDataStore::weakActiveDOMObjectCallback);
+ }
}
}
};