Changeset 55632 in webkit


Ignore:
Timestamp:
Mar 6, 2010 7:31:52 PM (14 years ago)
Author:
weinig@apple.com
Message:

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.

Location:
trunk/WebCore
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r55631 r55632  
     12010-03-06  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Move debug only JS wrapper-set tracking code into its own file.
     6        https://bugs.webkit.org/show_bug.cgi?id=35839
     7
     8        * GNUmakefile.am: Added new files.
     9        * WebCore.gypi: Ditto.
     10        * WebCore.pro: Ditto.
     11        * WebCore.vcproj/WebCore.vcproj: Ditto.
     12        * WebCore.xcodeproj/project.pbxproj: Ditto.
     13
     14        * bindings/js/JSDOMBinding.cpp:
     15        (WebCore::cacheDOMObjectWrapper):
     16        (WebCore::forgetDOMObject):
     17        (WebCore::forgetDOMNode):
     18        (WebCore::cacheDOMNodeWrapper):
     19        (WebCore::takeWrappers):
     20        (WebCore::updateDOMNodeDocument):
     21        Updated for new signature for willCacheWrapper and didUncacheWrapper.
     22
     23        * bindings/js/JSDOMWrapper.cpp: Added.
     24        (WebCore::DOMObject::~DOMObject):
     25        (WebCore::DOMObject::defineOwnProperty):
     26        Moved from JSDOMBinding.cpp.
     27
     28        * bindings/js/JSDebugWrapperSet.cpp: Added.
     29        (WebCore::JSDebugWrapperSet::shared):
     30        (WebCore::JSDebugWrapperSet::JSDebugWrapperSet):
     31        * bindings/js/JSDebugWrapperSet.h: Added.
     32        (WebCore::JSDebugWrapperSet::add):
     33        (WebCore::JSDebugWrapperSet::remove):
     34        (WebCore::JSDebugWrapperSet::contains):
     35        (WebCore::JSDebugWrapperSet::willCacheWrapper):
     36        (WebCore::JSDebugWrapperSet::didUncacheWrapper):
     37        Moved from JSDOMBinding.cpp.
     38
    1392010-03-06  Sam Weinig  <sam@webkit.org>
    240
  • trunk/WebCore/GNUmakefile.am

    r55631 r55632  
    356356        WebCore/bindings/js/JSDataGridDataSource.cpp \
    357357        WebCore/bindings/js/JSDataGridDataSource.h \
     358        WebCore/bindings/js/JSDebugWrapperSet.cpp \
     359        WebCore/bindings/js/JSDebugWrapperSet.h \
    358360        WebCore/bindings/js/JSCSSRuleCustom.cpp \
    359361        WebCore/bindings/js/JSCSSRuleListCustom.cpp \
     
    386388        WebCore/bindings/js/JSDOMWindowShell.cpp \
    387389        WebCore/bindings/js/JSDOMWindowShell.h \
     390        WebCore/bindings/js/JSDOMWrapper.cpp \
    388391        WebCore/bindings/js/JSDOMWrapper.h \
    389392        WebCore/bindings/js/JSDocumentCustom.cpp \
  • trunk/WebCore/WebCore.gypi

    r55631 r55632  
    506506            'bindings/js/JSDataGridDataSource.h',
    507507            'bindings/js/JSDedicatedWorkerContextCustom.cpp',
     508            'bindings/js/JSDebugWrapperSet.cpp',
     509            'bindings/js/JSDebugWrapperSet.h',
    508510            'bindings/js/JSDocumentCustom.cpp',
    509511            'bindings/js/JSDocumentFragmentCustom.cpp',
     
    519521            'bindings/js/JSDOMWindowShell.cpp',
    520522            'bindings/js/JSDOMWindowShell.h',
     523            'bindings/js/JSDOMWrapper.cpp',
    521524            'bindings/js/JSDOMWrapper.h',
    522525            'bindings/js/JSElementCustom.cpp',
  • trunk/WebCore/WebCore.pro

    r55631 r55632  
    287287    bindings/js/JSDataGridColumnListCustom.cpp \
    288288    bindings/js/JSDataGridDataSource.cpp \
     289    bindings/js/JSDebugWrapperSet.cpp \
    289290    bindings/js/JSDocumentCustom.cpp \
    290291    bindings/js/JSDocumentFragmentCustom.cpp \
     
    293294    bindings/js/JSDOMWindowCustom.cpp \
    294295    bindings/js/JSDOMWindowShell.cpp \
     296    bindings/js/JSDOMWrapper.cpp \
    295297    bindings/js/JSElementCustom.cpp \
    296298    bindings/js/JSEventCustom.cpp \
     
    10191021    bindings/js/JSDatabaseCallback.h \
    10201022    bindings/js/JSDataGridDataSource.h \
     1023    bindings/js/JSDebugWrapperSet.h \
    10211024    bindings/js/JSDOMBinding.h \
    10221025    bindings/js/JSDOMGlobalObject.h \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r55631 r55632  
    3580935809                                </File>
    3581035810                                <File
     35811                                        RelativePath="..\bindings\js\JSDebugWrapperSet.cpp"
     35812                                        >
     35813                                </File>
     35814                                <File
     35815                                        RelativePath="..\bindings\js\JSDebugWrapperSet.h"
     35816                                        >
     35817                                </File>
     35818                                <File
    3581135819                                        RelativePath="..\bindings\js\JSDOMBinding.cpp"
    3581235820                                        >
     
    3603036038                                <File
    3603136039                                        RelativePath="..\bindings\js\JSDOMWindowCustom.h"
     36040                                        >
     36041                                </File>
     36042                                <File
     36043                                        RelativePath="..\bindings\js\JSDOMWrapper.cpp"
    3603236044                                        >
    3603336045                                </File>
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r55631 r55632  
    42644264                BC53DA601143141A000D817E /* DOMObjectHashTableMap.h in Headers */ = {isa = PBXBuildFile; fileRef = BC53DA5F1143141A000D817E /* DOMObjectHashTableMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
    42654265                BC53DA62114314BD000D817E /* DOMObjectHashTableMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC53DA61114314BD000D817E /* DOMObjectHashTableMap.cpp */; };
     4266                BC53DAC211432EEE000D817E /* JSDebugWrapperSet.h in Headers */ = {isa = PBXBuildFile; fileRef = BC53DAC111432EEE000D817E /* JSDebugWrapperSet.h */; };
     4267                BC53DAC511432FD9000D817E /* JSDebugWrapperSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC53DAC411432FD9000D817E /* JSDebugWrapperSet.cpp */; };
     4268                BC53DAC711433064000D817E /* JSDOMWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC53DAC611433064000D817E /* JSDOMWrapper.cpp */; };
    42664269                BC56CB2110D5AC8000A77C64 /* GeolocationController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC56CB1C10D5AC8000A77C64 /* GeolocationController.cpp */; };
    42674270                BC56CB2210D5AC8000A77C64 /* GeolocationController.h in Headers */ = {isa = PBXBuildFile; fileRef = BC56CB1D10D5AC8000A77C64 /* GeolocationController.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    95489551                BC53DA5F1143141A000D817E /* DOMObjectHashTableMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMObjectHashTableMap.h; sourceTree = "<group>"; };
    95499552                BC53DA61114314BD000D817E /* DOMObjectHashTableMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMObjectHashTableMap.cpp; sourceTree = "<group>"; };
     9553                BC53DAC111432EEE000D817E /* JSDebugWrapperSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDebugWrapperSet.h; sourceTree = "<group>"; };
     9554                BC53DAC411432FD9000D817E /* JSDebugWrapperSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDebugWrapperSet.cpp; sourceTree = "<group>"; };
     9555                BC53DAC611433064000D817E /* JSDOMWrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMWrapper.cpp; sourceTree = "<group>"; };
    95509556                BC56CB1C10D5AC8000A77C64 /* GeolocationController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeolocationController.cpp; sourceTree = "<group>"; };
    95519557                BC56CB1D10D5AC8000A77C64 /* GeolocationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationController.h; sourceTree = "<group>"; };
     
    1469714703                                1432E8480C51493F00B1500F /* GCController.cpp */,
    1469814704                                1432E8460C51493800B1500F /* GCController.h */,
    14699                                 B5D3601E112F8BA80048DEA8 /* JSDatabaseCallback.cpp */,
    14700                                 B5D3601C112F8BA00048DEA8 /* JSDatabaseCallback.h */,
     14705                                BC53DAC411432FD9000D817E /* JSDebugWrapperSet.cpp */,
     14706                                BC53DAC111432EEE000D817E /* JSDebugWrapperSet.h */,
    1470114707                                93B70D4709EB0C7C009D8468 /* JSDOMBinding.cpp */,
    1470214708                                93B70D4809EB0C7C009D8468 /* JSDOMBinding.h */,
     
    1470714713                                BCBFB53A0DCD29CF0019B3E5 /* JSDOMWindowShell.cpp */,
    1470814714                                BCBFB53B0DCD29CF0019B3E5 /* JSDOMWindowShell.h */,
     14715                                BC53DAC611433064000D817E /* JSDOMWrapper.cpp */,
    1470914716                                65E0E9431133C89F00B4CB10 /* JSDOMWrapper.h */,
    1471014717                                BC60901E0E91B8EC000C68B5 /* JSEventTarget.cpp */,
     
    1483614843                                BC20FB7E0C0E8E6C00D1447F /* JSCSSValueCustom.cpp */,
    1483714844                                BC20FB7E0C0E8E6C00D1447F /* JSCSSValueCustom.cpp */,
    14838                                 FE80D7A20E9C1ED2000D6F75 /* JSCustomPositionCallback.cpp */,
    14839                                 FE80D7A30E9C1ED2000D6F75 /* JSCustomPositionCallback.h */,
    14840                                 FE80D7A40E9C1ED2000D6F75 /* JSCustomPositionErrorCallback.cpp */,
    14841                                 FE80D7A50E9C1ED2000D6F75 /* JSCustomPositionErrorCallback.h */,
    14842                                 51EC925B0CE90DD400F90308 /* JSCustomSQLStatementCallback.cpp */,
    14843                                 51EC925C0CE90DD400F90308 /* JSCustomSQLStatementCallback.h */,
    14844                                 51EC925D0CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp */,
    14845                                 51EC925E0CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.h */,
    14846                                 51EC925F0CE90DD400F90308 /* JSCustomSQLTransactionCallback.cpp */,
    14847                                 51EC92600CE90DD400F90308 /* JSCustomSQLTransactionCallback.h */,
    14848                                 51EC92610CE90DD400F90308 /* JSCustomSQLTransactionErrorCallback.cpp */,
    14849                                 51EC92620CE90DD400F90308 /* JSCustomSQLTransactionErrorCallback.h */,
    14850                                 1A3417C80CECFF250049CBDE /* JSCustomVoidCallback.cpp */,
    14851                                 1A3417C70CECFF250049CBDE /* JSCustomVoidCallback.h */,
    1485214845                                BCCE58AB1061E8CF008FB35A /* JSDatabaseCustom.cpp */,
    1485314846                                BC77D1510FF19C730070887B /* JSDataGridColumnListCustom.cpp */,
     
    1517615169                                E10B93C20B73C291003ED890 /* JSCustomXPathNSResolver.cpp */,
    1517715170                                E10B937B0B73C00A003ED890 /* JSCustomXPathNSResolver.h */,
     15171                                B5D3601E112F8BA80048DEA8 /* JSDatabaseCallback.cpp */,
     15172                                B5D3601C112F8BA00048DEA8 /* JSDatabaseCallback.h */,
    1517815173                                BCBCAE3A0FF19399000762AE /* JSDataGridDataSource.cpp */,
    1517915174                                BCBCAE3B0FF19399000762AE /* JSDataGridDataSource.h */,
     
    1518415179                                BCB7735E0C17853D00132BA4 /* JSNodeFilterCondition.cpp */,
    1518515180                                BCB7735F0C17853D00132BA4 /* JSNodeFilterCondition.h */,
     15181                                FE80D7A20E9C1ED2000D6F75 /* JSCustomPositionCallback.cpp */,
     15182                                FE80D7A30E9C1ED2000D6F75 /* JSCustomPositionCallback.h */,
     15183                                FE80D7A40E9C1ED2000D6F75 /* JSCustomPositionErrorCallback.cpp */,
     15184                                FE80D7A50E9C1ED2000D6F75 /* JSCustomPositionErrorCallback.h */,
     15185                                51EC925B0CE90DD400F90308 /* JSCustomSQLStatementCallback.cpp */,
     15186                                51EC925C0CE90DD400F90308 /* JSCustomSQLStatementCallback.h */,
     15187                                51EC925D0CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp */,
     15188                                51EC925E0CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.h */,
     15189                                51EC925F0CE90DD400F90308 /* JSCustomSQLTransactionCallback.cpp */,
     15190                                51EC92600CE90DD400F90308 /* JSCustomSQLTransactionCallback.h */,
     15191                                51EC92610CE90DD400F90308 /* JSCustomSQLTransactionErrorCallback.cpp */,
     15192                                51EC92620CE90DD400F90308 /* JSCustomSQLTransactionErrorCallback.h */,
     15193                                1A3417C80CECFF250049CBDE /* JSCustomVoidCallback.cpp */,
     15194                                1A3417C70CECFF250049CBDE /* JSCustomVoidCallback.h */,
    1518615195                        );
    1518715196                        name = "Callback Objects";
     
    1866318672                                BC53DA2E1143121E000D817E /* DOMWrapperWorld.h in Headers */,
    1866418673                                BC53DA601143141A000D817E /* DOMObjectHashTableMap.h in Headers */,
     18674                                BC53DAC211432EEE000D817E /* JSDebugWrapperSet.h in Headers */,
    1866518675                        );
    1866618676                        runOnlyForDeploymentPostprocessing = 0;
     
    2086020870                                BC53DA481143134D000D817E /* DOMWrapperWorld.cpp in Sources */,
    2086120871                                BC53DA62114314BD000D817E /* DOMObjectHashTableMap.cpp in Sources */,
     20872                                BC53DAC511432FD9000D817E /* JSDebugWrapperSet.cpp in Sources */,
     20873                                BC53DAC711433064000D817E /* JSDOMWrapper.cpp in Sources */,
    2086220874                        );
    2086320875                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/bindings/js/JSDOMBinding.cpp

    r55631 r55632  
    3535#include "HTMLCanvasElement.h"
    3636#include "HTMLImageElement.h"
     37#include "HTMLNames.h"
    3738#include "HTMLScriptElement.h"
    38 #include "HTMLNames.h"
    3939#include "JSDOMCoreException.h"
    4040#include "JSDOMWindowCustom.h"
     41#include "JSDebugWrapperSet.h"
    4142#include "JSEventException.h"
    4243#include "JSExceptionBase.h"
    4344#include "JSNode.h"
    44 #include "WebCoreJSClientData.h"
    4545#include "JSRangeException.h"
    4646#include "JSXMLHttpRequestException.h"
     
    5151#include "ScriptController.h"
    5252#include "Settings.h"
     53#include "WebCoreJSClientData.h"
    5354#include "XMLHttpRequestException.h"
    5455#include <runtime/DateInstance.h>
     
    6970#endif
    7071
    71 #if ENABLE(WORKERS)
    72 #include <wtf/ThreadSpecific.h>
    73 using namespace WTF;
    74 #endif
    75 
    7672using namespace JSC;
    7773
     
    8278typedef Document::JSWrapperCache JSWrapperCache;
    8379typedef Document::JSWrapperCacheMap JSWrapperCacheMap;
    84 
    85 // For debugging, keep a set of wrappers currently cached, and check that
    86 // all are uncached before they are destroyed. This helps us catch bugs like:
    87 //     - wrappers being deleted without being removed from the cache
    88 //     - wrappers being cached twice
    89 
    90 static void willCacheWrapper(DOMObject* wrapper);
    91 static void didUncacheWrapper(DOMObject* wrapper);
    92 
    93 #ifdef NDEBUG
    94 
    95 static inline void willCacheWrapper(DOMObject*)
    96 {
    97 }
    98 
    99 static inline void didUncacheWrapper(DOMObject*)
    100 {
    101 }
    102 
    103 #else
    104 
    105 static HashSet<DOMObject*>& wrapperSet()
    106 {
    107 #if ENABLE(WORKERS)
    108     DEFINE_STATIC_LOCAL(ThreadSpecific<HashSet<DOMObject*> >, staticWrapperSet, ());
    109     return *staticWrapperSet;
    110 #else
    111     DEFINE_STATIC_LOCAL(HashSet<DOMObject*>, staticWrapperSet, ());
    112     return staticWrapperSet;
    113 #endif
    114 }
    115 
    116 static void willCacheWrapper(DOMObject* wrapper)
    117 {
    118     ASSERT(!wrapperSet().contains(wrapper));
    119     wrapperSet().add(wrapper);
    120 }
    121 
    122 static void didUncacheWrapper(DOMObject* wrapper)
    123 {
    124     if (!wrapper)
    125         return;
    126     ASSERT(wrapperSet().contains(wrapper));
    127     wrapperSet().remove(wrapper);
    128 }
    129 
    130 DOMObject::~DOMObject()
    131 {
    132     ASSERT(!wrapperSet().contains(this));
    133 }
    134 
    135 #endif
    13680
    13781class JSGlobalDataWorldIterator {
     
    201145void cacheDOMObjectWrapper(JSC::ExecState* exec, void* objectHandle, DOMObject* wrapper)
    202146{
    203     willCacheWrapper(wrapper);
     147    JSDebugWrapperSet::willCacheWrapper(wrapper);
    204148    domObjectWrapperMapFor(exec).set(objectHandle, wrapper);
    205149}
     
    227171    DOMObjectWrapperMap& wrappers = static_cast<WebCoreJSClientData*>(clientData)->normalWorld()->m_wrappers;
    228172    if (wrappers.uncheckedRemove(objectHandle, wrapper)) {
    229         didUncacheWrapper(wrapper);
     173        JSDebugWrapperSet::didUncacheWrapper(wrapper);
    230174        return;
    231175    }
     
    237181            break;
    238182    }
    239     didUncacheWrapper(wrapper);
     183    JSDebugWrapperSet::didUncacheWrapper(wrapper);
    240184}
    241185
     
    256200            break;
    257201    }
    258     didUncacheWrapper(wrapper);
     202    JSDebugWrapperSet::didUncacheWrapper(wrapper);
    259203}
    260204
    261205void cacheDOMNodeWrapper(JSC::ExecState* exec, Document* document, Node* node, JSNode* wrapper)
    262206{
    263     willCacheWrapper(wrapper);
     207    JSDebugWrapperSet::willCacheWrapper(wrapper);
    264208
    265209    if (!document)
     
    404348        for (JSWrapperCacheMap::iterator iter = wrapperCacheMap.begin(); iter != wrapperCacheMap.end(); ++iter) {
    405349            if (JSNode* wrapper = iter->second->take(node)) {
    406                 didUncacheWrapper(wrapper);
     350                JSDebugWrapperSet::didUncacheWrapper(wrapper);
    407351                wrapperSet.append(WrapperAndWorld(wrapper, iter->first));
    408352            }
     
    412356            DOMWrapperWorld* world = *worldIter;
    413357            if (JSNode* wrapper = static_cast<JSNode*>(world->m_wrappers.take(node))) {
    414                 didUncacheWrapper(wrapper);
     358                JSDebugWrapperSet::didUncacheWrapper(wrapper);
    415359                wrapperSet.append(WrapperAndWorld(wrapper, world));
    416360            }
     
    428372    for (unsigned i = 0; i < wrapperSet.size(); ++i) {
    429373        JSNode* wrapper = wrapperSet[i].first;
    430         willCacheWrapper(wrapper);
     374        JSDebugWrapperSet::willCacheWrapper(wrapper);
    431375        if (newDocument)
    432376            newDocument->getWrapperCache(wrapperSet[i].second)->set(node, wrapper);
     
    792736}
    793737
    794 bool DOMObject::defineOwnProperty(ExecState* exec, const Identifier&, PropertyDescriptor&, bool)
    795 {
    796     throwError(exec, TypeError, "defineProperty is not supported on DOM Objects");
    797     return false;
    798 }
    799 
    800738} // namespace WebCore
Note: See TracChangeset for help on using the changeset viewer.