[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.22-985-g3c00f00
weinig at apple.com
weinig at apple.com
Wed Mar 17 18:26:41 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit cbc8fb33365778598919c3ecd2ebe97c3bf3a1a1
Author: weinig at apple.com <weinig at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sun Mar 7 03:31:52 2010 +0000
Move debug only JS wrapper-set tracking code into its own file.
https://bugs.webkit.org/show_bug.cgi?id=35839
Reviewed by Dan Bernstein.
* GNUmakefile.am: Added new files.
* WebCore.gypi: Ditto.
* WebCore.pro: Ditto.
* WebCore.vcproj/WebCore.vcproj: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* bindings/js/JSDOMBinding.cpp:
(WebCore::cacheDOMObjectWrapper):
(WebCore::forgetDOMObject):
(WebCore::forgetDOMNode):
(WebCore::cacheDOMNodeWrapper):
(WebCore::takeWrappers):
(WebCore::updateDOMNodeDocument):
Updated for new signature for willCacheWrapper and didUncacheWrapper.
* bindings/js/JSDOMWrapper.cpp: Added.
(WebCore::DOMObject::~DOMObject):
(WebCore::DOMObject::defineOwnProperty):
Moved from JSDOMBinding.cpp.
* bindings/js/JSDebugWrapperSet.cpp: Added.
(WebCore::JSDebugWrapperSet::shared):
(WebCore::JSDebugWrapperSet::JSDebugWrapperSet):
* bindings/js/JSDebugWrapperSet.h: Added.
(WebCore::JSDebugWrapperSet::add):
(WebCore::JSDebugWrapperSet::remove):
(WebCore::JSDebugWrapperSet::contains):
(WebCore::JSDebugWrapperSet::willCacheWrapper):
(WebCore::JSDebugWrapperSet::didUncacheWrapper):
Moved from JSDOMBinding.cpp.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55632 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 551f54d..633f6f5 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,5 +1,43 @@
2010-03-06 Sam Weinig <sam at webkit.org>
+ Reviewed by Dan Bernstein.
+
+ Move debug only JS wrapper-set tracking code into its own file.
+ https://bugs.webkit.org/show_bug.cgi?id=35839
+
+ * GNUmakefile.am: Added new files.
+ * WebCore.gypi: Ditto.
+ * WebCore.pro: Ditto.
+ * WebCore.vcproj/WebCore.vcproj: Ditto.
+ * WebCore.xcodeproj/project.pbxproj: Ditto.
+
+ * bindings/js/JSDOMBinding.cpp:
+ (WebCore::cacheDOMObjectWrapper):
+ (WebCore::forgetDOMObject):
+ (WebCore::forgetDOMNode):
+ (WebCore::cacheDOMNodeWrapper):
+ (WebCore::takeWrappers):
+ (WebCore::updateDOMNodeDocument):
+ Updated for new signature for willCacheWrapper and didUncacheWrapper.
+
+ * bindings/js/JSDOMWrapper.cpp: Added.
+ (WebCore::DOMObject::~DOMObject):
+ (WebCore::DOMObject::defineOwnProperty):
+ Moved from JSDOMBinding.cpp.
+
+ * bindings/js/JSDebugWrapperSet.cpp: Added.
+ (WebCore::JSDebugWrapperSet::shared):
+ (WebCore::JSDebugWrapperSet::JSDebugWrapperSet):
+ * bindings/js/JSDebugWrapperSet.h: Added.
+ (WebCore::JSDebugWrapperSet::add):
+ (WebCore::JSDebugWrapperSet::remove):
+ (WebCore::JSDebugWrapperSet::contains):
+ (WebCore::JSDebugWrapperSet::willCacheWrapper):
+ (WebCore::JSDebugWrapperSet::didUncacheWrapper):
+ Moved from JSDOMBinding.cpp.
+
+2010-03-06 Sam Weinig <sam at webkit.org>
+
Rubber-stamped by Dan Bernstein.
Move DOMObjectHashTableMap, DOMWrapperWorld and WebCoreJSClientData into
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 43bbffe..f5ef0d1 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -355,6 +355,8 @@ webcore_sources += \
WebCore/bindings/js/JSDataGridColumnListCustom.cpp \
WebCore/bindings/js/JSDataGridDataSource.cpp \
WebCore/bindings/js/JSDataGridDataSource.h \
+ WebCore/bindings/js/JSDebugWrapperSet.cpp \
+ WebCore/bindings/js/JSDebugWrapperSet.h \
WebCore/bindings/js/JSCSSRuleCustom.cpp \
WebCore/bindings/js/JSCSSRuleListCustom.cpp \
WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp \
@@ -385,6 +387,7 @@ webcore_sources += \
WebCore/bindings/js/JSDOMWindowCustom.h \
WebCore/bindings/js/JSDOMWindowShell.cpp \
WebCore/bindings/js/JSDOMWindowShell.h \
+ WebCore/bindings/js/JSDOMWrapper.cpp \
WebCore/bindings/js/JSDOMWrapper.h \
WebCore/bindings/js/JSDocumentCustom.cpp \
WebCore/bindings/js/JSDocumentFragmentCustom.cpp \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 2b04481..b2cf393 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -505,6 +505,8 @@
'bindings/js/JSDataGridDataSource.cpp',
'bindings/js/JSDataGridDataSource.h',
'bindings/js/JSDedicatedWorkerContextCustom.cpp',
+ 'bindings/js/JSDebugWrapperSet.cpp',
+ 'bindings/js/JSDebugWrapperSet.h',
'bindings/js/JSDocumentCustom.cpp',
'bindings/js/JSDocumentFragmentCustom.cpp',
'bindings/js/JSDOMApplicationCacheCustom.cpp',
@@ -518,6 +520,7 @@
'bindings/js/JSDOMWindowCustom.h',
'bindings/js/JSDOMWindowShell.cpp',
'bindings/js/JSDOMWindowShell.h',
+ 'bindings/js/JSDOMWrapper.cpp',
'bindings/js/JSDOMWrapper.h',
'bindings/js/JSElementCustom.cpp',
'bindings/js/JSEventCustom.cpp',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index b498673..e47fec6 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -286,12 +286,14 @@ SOURCES += \
bindings/js/JSCustomXPathNSResolver.cpp \
bindings/js/JSDataGridColumnListCustom.cpp \
bindings/js/JSDataGridDataSource.cpp \
+ bindings/js/JSDebugWrapperSet.cpp \
bindings/js/JSDocumentCustom.cpp \
bindings/js/JSDocumentFragmentCustom.cpp \
bindings/js/JSDOMGlobalObject.cpp \
bindings/js/JSDOMWindowBase.cpp \
bindings/js/JSDOMWindowCustom.cpp \
bindings/js/JSDOMWindowShell.cpp \
+ bindings/js/JSDOMWrapper.cpp \
bindings/js/JSElementCustom.cpp \
bindings/js/JSEventCustom.cpp \
bindings/js/JSEventSourceConstructor.cpp \
@@ -1018,6 +1020,7 @@ HEADERS += \
bindings/js/JSCustomXPathNSResolver.h \
bindings/js/JSDatabaseCallback.h \
bindings/js/JSDataGridDataSource.h \
+ bindings/js/JSDebugWrapperSet.h \
bindings/js/JSDOMBinding.h \
bindings/js/JSDOMGlobalObject.h \
bindings/js/JSDOMWindowBase.h \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index 6e5ff35..c48945d 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -35808,6 +35808,14 @@
</FileConfiguration>
</File>
<File
+ RelativePath="..\bindings\js\JSDebugWrapperSet.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\bindings\js\JSDebugWrapperSet.h"
+ >
+ </File>
+ <File
RelativePath="..\bindings\js\JSDOMBinding.cpp"
>
<FileConfiguration
@@ -36032,6 +36040,10 @@
>
</File>
<File
+ RelativePath="..\bindings\js\JSDOMWrapper.cpp"
+ >
+ </File>
+ <File
RelativePath="..\bindings\js\JSDOMWrapper.h"
>
</File>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 629b8ad..b66d3f7 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -4263,6 +4263,9 @@
BC53DA481143134D000D817E /* DOMWrapperWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC53DA471143134D000D817E /* DOMWrapperWorld.cpp */; };
BC53DA601143141A000D817E /* DOMObjectHashTableMap.h in Headers */ = {isa = PBXBuildFile; fileRef = BC53DA5F1143141A000D817E /* DOMObjectHashTableMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
BC53DA62114314BD000D817E /* DOMObjectHashTableMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC53DA61114314BD000D817E /* DOMObjectHashTableMap.cpp */; };
+ BC53DAC211432EEE000D817E /* JSDebugWrapperSet.h in Headers */ = {isa = PBXBuildFile; fileRef = BC53DAC111432EEE000D817E /* JSDebugWrapperSet.h */; };
+ BC53DAC511432FD9000D817E /* JSDebugWrapperSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC53DAC411432FD9000D817E /* JSDebugWrapperSet.cpp */; };
+ BC53DAC711433064000D817E /* JSDOMWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC53DAC611433064000D817E /* JSDOMWrapper.cpp */; };
BC56CB2110D5AC8000A77C64 /* GeolocationController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC56CB1C10D5AC8000A77C64 /* GeolocationController.cpp */; };
BC56CB2210D5AC8000A77C64 /* GeolocationController.h in Headers */ = {isa = PBXBuildFile; fileRef = BC56CB1D10D5AC8000A77C64 /* GeolocationController.h */; settings = {ATTRIBUTES = (Private, ); }; };
BC56CB2310D5AC8000A77C64 /* GeolocationControllerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = BC56CB1E10D5AC8000A77C64 /* GeolocationControllerClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9547,6 +9550,9 @@
BC53DA471143134D000D817E /* DOMWrapperWorld.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWrapperWorld.cpp; sourceTree = "<group>"; };
BC53DA5F1143141A000D817E /* DOMObjectHashTableMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMObjectHashTableMap.h; sourceTree = "<group>"; };
BC53DA61114314BD000D817E /* DOMObjectHashTableMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMObjectHashTableMap.cpp; sourceTree = "<group>"; };
+ BC53DAC111432EEE000D817E /* JSDebugWrapperSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDebugWrapperSet.h; sourceTree = "<group>"; };
+ BC53DAC411432FD9000D817E /* JSDebugWrapperSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDebugWrapperSet.cpp; sourceTree = "<group>"; };
+ BC53DAC611433064000D817E /* JSDOMWrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMWrapper.cpp; sourceTree = "<group>"; };
BC56CB1C10D5AC8000A77C64 /* GeolocationController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeolocationController.cpp; sourceTree = "<group>"; };
BC56CB1D10D5AC8000A77C64 /* GeolocationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationController.h; sourceTree = "<group>"; };
BC56CB1E10D5AC8000A77C64 /* GeolocationControllerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationControllerClient.h; sourceTree = "<group>"; };
@@ -14696,8 +14702,8 @@
BC53DA2D1143121E000D817E /* DOMWrapperWorld.h */,
1432E8480C51493F00B1500F /* GCController.cpp */,
1432E8460C51493800B1500F /* GCController.h */,
- B5D3601E112F8BA80048DEA8 /* JSDatabaseCallback.cpp */,
- B5D3601C112F8BA00048DEA8 /* JSDatabaseCallback.h */,
+ BC53DAC411432FD9000D817E /* JSDebugWrapperSet.cpp */,
+ BC53DAC111432EEE000D817E /* JSDebugWrapperSet.h */,
93B70D4709EB0C7C009D8468 /* JSDOMBinding.cpp */,
93B70D4809EB0C7C009D8468 /* JSDOMBinding.h */,
E1C36CBC0EB08062007410BC /* JSDOMGlobalObject.cpp */,
@@ -14706,6 +14712,7 @@
BC6932720D7E293900AE44D1 /* JSDOMWindowBase.h */,
BCBFB53A0DCD29CF0019B3E5 /* JSDOMWindowShell.cpp */,
BCBFB53B0DCD29CF0019B3E5 /* JSDOMWindowShell.h */,
+ BC53DAC611433064000D817E /* JSDOMWrapper.cpp */,
65E0E9431133C89F00B4CB10 /* JSDOMWrapper.h */,
BC60901E0E91B8EC000C68B5 /* JSEventTarget.cpp */,
BC60901D0E91B8EC000C68B5 /* JSEventTarget.h */,
@@ -14835,20 +14842,6 @@
BC5825F20C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp */,
BC20FB7E0C0E8E6C00D1447F /* JSCSSValueCustom.cpp */,
BC20FB7E0C0E8E6C00D1447F /* JSCSSValueCustom.cpp */,
- FE80D7A20E9C1ED2000D6F75 /* JSCustomPositionCallback.cpp */,
- FE80D7A30E9C1ED2000D6F75 /* JSCustomPositionCallback.h */,
- FE80D7A40E9C1ED2000D6F75 /* JSCustomPositionErrorCallback.cpp */,
- FE80D7A50E9C1ED2000D6F75 /* JSCustomPositionErrorCallback.h */,
- 51EC925B0CE90DD400F90308 /* JSCustomSQLStatementCallback.cpp */,
- 51EC925C0CE90DD400F90308 /* JSCustomSQLStatementCallback.h */,
- 51EC925D0CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp */,
- 51EC925E0CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.h */,
- 51EC925F0CE90DD400F90308 /* JSCustomSQLTransactionCallback.cpp */,
- 51EC92600CE90DD400F90308 /* JSCustomSQLTransactionCallback.h */,
- 51EC92610CE90DD400F90308 /* JSCustomSQLTransactionErrorCallback.cpp */,
- 51EC92620CE90DD400F90308 /* JSCustomSQLTransactionErrorCallback.h */,
- 1A3417C80CECFF250049CBDE /* JSCustomVoidCallback.cpp */,
- 1A3417C70CECFF250049CBDE /* JSCustomVoidCallback.h */,
BCCE58AB1061E8CF008FB35A /* JSDatabaseCustom.cpp */,
BC77D1510FF19C730070887B /* JSDataGridColumnListCustom.cpp */,
4162A453101145E300DFF3ED /* JSDedicatedWorkerContextCustom.cpp */,
@@ -15175,6 +15168,8 @@
1A3417C70CECFF250049CBDE /* JSCustomVoidCallback.h */,
E10B93C20B73C291003ED890 /* JSCustomXPathNSResolver.cpp */,
E10B937B0B73C00A003ED890 /* JSCustomXPathNSResolver.h */,
+ B5D3601E112F8BA80048DEA8 /* JSDatabaseCallback.cpp */,
+ B5D3601C112F8BA00048DEA8 /* JSDatabaseCallback.h */,
BCBCAE3A0FF19399000762AE /* JSDataGridDataSource.cpp */,
BCBCAE3B0FF19399000762AE /* JSDataGridDataSource.h */,
93B70D4D09EB0C7C009D8468 /* JSEventListener.cpp */,
@@ -15183,6 +15178,20 @@
935F45410F7C3B5F00D7C1FB /* JSLazyEventListener.h */,
BCB7735E0C17853D00132BA4 /* JSNodeFilterCondition.cpp */,
BCB7735F0C17853D00132BA4 /* JSNodeFilterCondition.h */,
+ FE80D7A20E9C1ED2000D6F75 /* JSCustomPositionCallback.cpp */,
+ FE80D7A30E9C1ED2000D6F75 /* JSCustomPositionCallback.h */,
+ FE80D7A40E9C1ED2000D6F75 /* JSCustomPositionErrorCallback.cpp */,
+ FE80D7A50E9C1ED2000D6F75 /* JSCustomPositionErrorCallback.h */,
+ 51EC925B0CE90DD400F90308 /* JSCustomSQLStatementCallback.cpp */,
+ 51EC925C0CE90DD400F90308 /* JSCustomSQLStatementCallback.h */,
+ 51EC925D0CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp */,
+ 51EC925E0CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.h */,
+ 51EC925F0CE90DD400F90308 /* JSCustomSQLTransactionCallback.cpp */,
+ 51EC92600CE90DD400F90308 /* JSCustomSQLTransactionCallback.h */,
+ 51EC92610CE90DD400F90308 /* JSCustomSQLTransactionErrorCallback.cpp */,
+ 51EC92620CE90DD400F90308 /* JSCustomSQLTransactionErrorCallback.h */,
+ 1A3417C80CECFF250049CBDE /* JSCustomVoidCallback.cpp */,
+ 1A3417C70CECFF250049CBDE /* JSCustomVoidCallback.h */,
);
name = "Callback Objects";
sourceTree = "<group>";
@@ -18662,6 +18671,7 @@
BC53D911114310CC000D817E /* WebCoreJSClientData.h in Headers */,
BC53DA2E1143121E000D817E /* DOMWrapperWorld.h in Headers */,
BC53DA601143141A000D817E /* DOMObjectHashTableMap.h in Headers */,
+ BC53DAC211432EEE000D817E /* JSDebugWrapperSet.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -20859,6 +20869,8 @@
B5D3601F112F8BA80048DEA8 /* JSDatabaseCallback.cpp in Sources */,
BC53DA481143134D000D817E /* DOMWrapperWorld.cpp in Sources */,
BC53DA62114314BD000D817E /* DOMObjectHashTableMap.cpp in Sources */,
+ BC53DAC511432FD9000D817E /* JSDebugWrapperSet.cpp in Sources */,
+ BC53DAC711433064000D817E /* JSDOMWrapper.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/WebCore/bindings/js/JSDOMBinding.cpp b/WebCore/bindings/js/JSDOMBinding.cpp
index bc68c3f..f294dad 100644
--- a/WebCore/bindings/js/JSDOMBinding.cpp
+++ b/WebCore/bindings/js/JSDOMBinding.cpp
@@ -34,14 +34,14 @@
#include "HTMLAudioElement.h"
#include "HTMLCanvasElement.h"
#include "HTMLImageElement.h"
-#include "HTMLScriptElement.h"
#include "HTMLNames.h"
+#include "HTMLScriptElement.h"
#include "JSDOMCoreException.h"
#include "JSDOMWindowCustom.h"
+#include "JSDebugWrapperSet.h"
#include "JSEventException.h"
#include "JSExceptionBase.h"
#include "JSNode.h"
-#include "WebCoreJSClientData.h"
#include "JSRangeException.h"
#include "JSXMLHttpRequestException.h"
#include "KURL.h"
@@ -50,6 +50,7 @@
#include "ScriptCachedFrameData.h"
#include "ScriptController.h"
#include "Settings.h"
+#include "WebCoreJSClientData.h"
#include "XMLHttpRequestException.h"
#include <runtime/DateInstance.h>
#include <runtime/Error.h>
@@ -68,11 +69,6 @@
#include "XPathException.h"
#endif
-#if ENABLE(WORKERS)
-#include <wtf/ThreadSpecific.h>
-using namespace WTF;
-#endif
-
using namespace JSC;
namespace WebCore {
@@ -82,58 +78,6 @@ using namespace HTMLNames;
typedef Document::JSWrapperCache JSWrapperCache;
typedef Document::JSWrapperCacheMap JSWrapperCacheMap;
-// For debugging, keep a set of wrappers currently cached, and check that
-// all are uncached before they are destroyed. This helps us catch bugs like:
-// - wrappers being deleted without being removed from the cache
-// - wrappers being cached twice
-
-static void willCacheWrapper(DOMObject* wrapper);
-static void didUncacheWrapper(DOMObject* wrapper);
-
-#ifdef NDEBUG
-
-static inline void willCacheWrapper(DOMObject*)
-{
-}
-
-static inline void didUncacheWrapper(DOMObject*)
-{
-}
-
-#else
-
-static HashSet<DOMObject*>& wrapperSet()
-{
-#if ENABLE(WORKERS)
- DEFINE_STATIC_LOCAL(ThreadSpecific<HashSet<DOMObject*> >, staticWrapperSet, ());
- return *staticWrapperSet;
-#else
- DEFINE_STATIC_LOCAL(HashSet<DOMObject*>, staticWrapperSet, ());
- return staticWrapperSet;
-#endif
-}
-
-static void willCacheWrapper(DOMObject* wrapper)
-{
- ASSERT(!wrapperSet().contains(wrapper));
- wrapperSet().add(wrapper);
-}
-
-static void didUncacheWrapper(DOMObject* wrapper)
-{
- if (!wrapper)
- return;
- ASSERT(wrapperSet().contains(wrapper));
- wrapperSet().remove(wrapper);
-}
-
-DOMObject::~DOMObject()
-{
- ASSERT(!wrapperSet().contains(this));
-}
-
-#endif
-
class JSGlobalDataWorldIterator {
public:
JSGlobalDataWorldIterator(JSGlobalData* globalData)
@@ -200,7 +144,7 @@ DOMObject* getCachedDOMObjectWrapper(JSC::ExecState* exec, void* objectHandle)
void cacheDOMObjectWrapper(JSC::ExecState* exec, void* objectHandle, DOMObject* wrapper)
{
- willCacheWrapper(wrapper);
+ JSDebugWrapperSet::willCacheWrapper(wrapper);
domObjectWrapperMapFor(exec).set(objectHandle, wrapper);
}
@@ -226,7 +170,7 @@ void forgetDOMObject(DOMObject* wrapper, void* objectHandle)
ASSERT(clientData);
DOMObjectWrapperMap& wrappers = static_cast<WebCoreJSClientData*>(clientData)->normalWorld()->m_wrappers;
if (wrappers.uncheckedRemove(objectHandle, wrapper)) {
- didUncacheWrapper(wrapper);
+ JSDebugWrapperSet::didUncacheWrapper(wrapper);
return;
}
@@ -236,7 +180,7 @@ void forgetDOMObject(DOMObject* wrapper, void* objectHandle)
if (worldIter->m_wrappers.uncheckedRemove(objectHandle, wrapper))
break;
}
- didUncacheWrapper(wrapper);
+ JSDebugWrapperSet::didUncacheWrapper(wrapper);
}
void forgetDOMNode(JSNode* wrapper, Node* node, Document* document)
@@ -255,12 +199,12 @@ void forgetDOMNode(JSNode* wrapper, Node* node, Document* document)
if (wrappersIter->second->uncheckedRemove(node, wrapper))
break;
}
- didUncacheWrapper(wrapper);
+ JSDebugWrapperSet::didUncacheWrapper(wrapper);
}
void cacheDOMNodeWrapper(JSC::ExecState* exec, Document* document, Node* node, JSNode* wrapper)
{
- willCacheWrapper(wrapper);
+ JSDebugWrapperSet::willCacheWrapper(wrapper);
if (!document)
domObjectWrapperMapFor(exec).set(node, wrapper);
@@ -403,7 +347,7 @@ static inline void takeWrappers(Node* node, Document* document, WrapperSet& wrap
JSWrapperCacheMap& wrapperCacheMap = document->wrapperCacheMap();
for (JSWrapperCacheMap::iterator iter = wrapperCacheMap.begin(); iter != wrapperCacheMap.end(); ++iter) {
if (JSNode* wrapper = iter->second->take(node)) {
- didUncacheWrapper(wrapper);
+ JSDebugWrapperSet::didUncacheWrapper(wrapper);
wrapperSet.append(WrapperAndWorld(wrapper, iter->first));
}
}
@@ -411,7 +355,7 @@ static inline void takeWrappers(Node* node, Document* document, WrapperSet& wrap
for (JSGlobalDataWorldIterator worldIter(JSDOMWindow::commonJSGlobalData()); worldIter; ++worldIter) {
DOMWrapperWorld* world = *worldIter;
if (JSNode* wrapper = static_cast<JSNode*>(world->m_wrappers.take(node))) {
- didUncacheWrapper(wrapper);
+ JSDebugWrapperSet::didUncacheWrapper(wrapper);
wrapperSet.append(WrapperAndWorld(wrapper, world));
}
}
@@ -427,7 +371,7 @@ void updateDOMNodeDocument(Node* node, Document* oldDocument, Document* newDocum
for (unsigned i = 0; i < wrapperSet.size(); ++i) {
JSNode* wrapper = wrapperSet[i].first;
- willCacheWrapper(wrapper);
+ JSDebugWrapperSet::willCacheWrapper(wrapper);
if (newDocument)
newDocument->getWrapperCache(wrapperSet[i].second)->set(node, wrapper);
else
@@ -791,10 +735,4 @@ JSC::JSObject* toJSSequence(ExecState* exec, JSValue value, unsigned& length)
return object;
}
-bool DOMObject::defineOwnProperty(ExecState* exec, const Identifier&, PropertyDescriptor&, bool)
-{
- throwError(exec, TypeError, "defineProperty is not supported on DOM Objects");
- return false;
-}
-
} // namespace WebCore
diff --git a/WebCore/bindings/js/JSDOMWrapper.cpp b/WebCore/bindings/js/JSDOMWrapper.cpp
new file mode 100644
index 0000000..3fcdcc1
--- /dev/null
+++ b/WebCore/bindings/js/JSDOMWrapper.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSDOMWrapper.h"
+
+#include "JSDebugWrapperSet.h"
+#include <runtime/Error.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+#ifndef NDEBUG
+
+DOMObject::~DOMObject()
+{
+ ASSERT(!JSDebugWrapperSet::shared().contains(this));
+}
+
+#endif
+
+bool DOMObject::defineOwnProperty(ExecState* exec, const Identifier&, PropertyDescriptor&, bool)
+{
+ throwError(exec, TypeError, "defineProperty is not supported on DOM Objects");
+ return false;
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/js/JSDebugWrapperSet.cpp b/WebCore/bindings/js/JSDebugWrapperSet.cpp
new file mode 100644
index 0000000..b0d6ca9
--- /dev/null
+++ b/WebCore/bindings/js/JSDebugWrapperSet.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSDebugWrapperSet.h"
+
+#include <wtf/StdLibExtras.h>
+
+#if ENABLE(WORKERS)
+#include <wtf/ThreadSpecific.h>
+#endif
+
+namespace WebCore {
+
+JSDebugWrapperSet& JSDebugWrapperSet::shared()
+{
+#if ENABLE(WORKERS)
+ DEFINE_STATIC_LOCAL(WTF::ThreadSpecific<JSDebugWrapperSet>, staticWrapperSet, ());
+ return *staticWrapperSet;
+#else
+ DEFINE_STATIC_LOCAL(JSDebugWrapperSet, staticWrapperSet, ());
+ return staticWrapperSet;
+#endif
+}
+
+JSDebugWrapperSet::JSDebugWrapperSet()
+{
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/js/JSDebugWrapperSet.h b/WebCore/bindings/js/JSDebugWrapperSet.h
new file mode 100644
index 0000000..94b6f78
--- /dev/null
+++ b/WebCore/bindings/js/JSDebugWrapperSet.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef JSDebugWrapperSet_h
+#define JSDebugWrapperSet_h
+
+#include "JSDOMWrapper.h"
+#include <wtf/HashSet.h>
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+
+// For debugging, keep a set of wrappers currently cached, and check that
+// all are uncached before they are destroyed. This helps us catch bugs like:
+// - wrappers being deleted without being removed from the cache
+// - wrappers being cached twice
+
+class JSDebugWrapperSet : public Noncopyable {
+ friend class WTF::ThreadSpecific<JSDebugWrapperSet>;
+public:
+ static JSDebugWrapperSet& shared();
+
+ void add(DOMObject* object) { m_wrapperSet.add(object); }
+ void remove(DOMObject* object) { m_wrapperSet.remove(object); }
+ bool contains(DOMObject* object) const { return m_wrapperSet.contains(object); }
+
+ static void willCacheWrapper(DOMObject*);
+ static void didUncacheWrapper(DOMObject*);
+
+private:
+ JSDebugWrapperSet();
+
+ HashSet<DOMObject*> m_wrapperSet;
+};
+
+#ifdef NDEBUG
+
+inline void JSDebugWrapperSet::willCacheWrapper(DOMObject*)
+{
+}
+
+inline void JSDebugWrapperSet::didUncacheWrapper(DOMObject*)
+{
+}
+
+#else
+
+inline void JSDebugWrapperSet::willCacheWrapper(DOMObject* wrapper)
+{
+ ASSERT(!JSDebugWrapperSet::shared().contains(wrapper));
+ JSDebugWrapperSet::shared().add(wrapper);
+}
+
+inline void JSDebugWrapperSet::didUncacheWrapper(DOMObject* wrapper)
+{
+ if (!wrapper)
+ return;
+ ASSERT(JSDebugWrapperSet::shared().contains(wrapper));
+ JSDebugWrapperSet::shared().remove(wrapper);
+}
+
+#endif
+
+} // namespace WebCore
+
+#endif // JSDebugWrapperSet_h
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list