Ignore:
Timestamp:
Oct 2, 2008, 9:18:56 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Darin Adler.

https://bugs.webkit.org/show_bug.cgi?id=21304
Stop using a static wrapper map for WebCore JS bindings

The static domObjects map was not thread safe.

  • dom/Document.h: (WebCore::Document::messagePorts): Added an accessor for JSDocument to iterate over message ports. (WebCore::Document::xmlHttpRequests): Ditto for XMLHttpRequests.
  • dom/Document.cpp: (WebCore::Document::createdXMLHttpRequest): (WebCore::Document::destroyedXMLHttpRequest): Moved XMLHttpRequest tracking from a global map to Document.
  • GNUmakefile.am:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • WebCoreSources.bkl:
  • webcore-base.bkl:
  • bindings/DOMProtect.cpp: Removed.
  • bindings/DOMProtect.h: Removed. Removed gcProtect(Unprotect)DOMObject - its callers do not have a JSGlobalData reference, so they can no longer protect bindings objects.
  • dom/MessagePort.cpp: (WebCore::CloseMessagePortTimer::CloseMessagePortTimer): (WebCore::CloseMessagePortTimer::fired): (WebCore::MessagePort::MessagePort): (WebCore::MessagePort::queueCloseEvent): (WebCore::MessagePort::setPendingActivity): (WebCore::MessagePort::unsetPendingActivity):
  • dom/MessagePort.h: (WebCore::MessagePort::hasPendingActivity): MessagePort now counts outstanding async events, so JSDocument::mark can decide whether to protect it.
  • xml/XMLHttpRequest.h: (WebCore::XMLHttpRequest::hasPendingActivity):
  • xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::XMLHttpRequest): (WebCore::XMLHttpRequest::~XMLHttpRequest): (WebCore::XMLHttpRequest::loadRequestAsynchronously): (WebCore::XMLHttpRequest::dropProtection): (WebCore::XMLHttpRequest::didFinishLoadingPreflight): (WebCore::XMLHttpRequest::cancelRequests): (WebCore::XMLHttpRequest::detachRequests): (WebCore::XMLHttpRequest::setPendingActivity): (WebCore::XMLHttpRequest::unsetPendingActivity): Moved XMLHttpRequest tracking from a global map to Document.
  • bindings/js/JSDOMBinding.cpp: (WebCore::wrapperSet): (WebCore::DOMObjectWrapperMap::mapFor): (WebCore::DOMObjectWrapperMap::get): (WebCore::DOMObjectWrapperMap::set): (WebCore::DOMObjectWrapperMap::remove): (WebCore::getCachedDOMObjectWrapper): (WebCore::cacheDOMObjectWrapper): (WebCore::forgetDOMObject): (WebCore::getCachedDOMNodeWrapper): (WebCore::forgetDOMNode): (WebCore::cacheDOMNodeWrapper): (WebCore::markActiveObjectsForDocument):
  • bindings/js/JSDOMBinding.h: (WebCore::createDOMObjectWrapper): (WebCore::getDOMObjectWrapper): Wrapper map is now kept as JSGlobalData::clientData. Also changed debug-only wrapperSet to be per-thread (this is slower than going to JSGlobalData, but fast enough for debug). WebCore objects can never migrate between threads.
  • bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::mark): Call markActiveObjectsForDocument() from JSDOMBinding.
  • bindings/js/JSCSSRuleCustom.cpp: (WebCore::toJS):
  • bindings/js/JSCSSValueCustom.cpp: (WebCore::toJS):
  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::markDOMObjectWrapper): (WebCore::JSDOMWindow::mark):
  • bindings/js/JSEventCustom.cpp: (WebCore::toJS):
  • bindings/js/JSEventTarget.cpp: (WebCore::toJS):
  • bindings/js/JSHTMLCollectionCustom.cpp: (WebCore::toJS):
  • bindings/js/JSImageDataCustom.cpp: (WebCore::toJS):
  • bindings/js/JSMessageChannelCustom.cpp: (WebCore::JSMessageChannel::mark):
  • bindings/js/JSMessagePortCustom.cpp: (WebCore::JSMessagePort::mark):
  • bindings/js/JSNodeCustom.cpp: (WebCore::JSNode::mark):
  • bindings/js/JSSVGPathSegCustom.cpp: (WebCore::toJS):
  • bindings/js/JSStyleSheetCustom.cpp: (WebCore::toJS):
  • bindings/js/JSXMLHttpRequestCustom.cpp: (WebCore::JSXMLHttpRequest::mark):
  • bindings/js/JSXMLHttpRequestUploadCustom.cpp: (WebCore::JSXMLHttpRequestUpload::mark):
  • bindings/js/ScriptController.cpp: (WebCore::ScriptController::finishedWithEvent):
  • bindings/scripts/CodeGeneratorJS.pm: Pass a JSGlobalData reference to functions that track JS wrapper objects.

JavaScriptCore:

  • kjs/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData): (JSC::JSGlobalData::~JSGlobalData): (JSC::JSGlobalData::ClientData::~ClientData):
  • kjs/JSGlobalData.h: Added a client data member to JSGlobalData. WebCore will use it to store bindings-related global data.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/JSGlobalData.cpp

    r37175 r37190  
    8989    , head(0)
    9090    , isSharedInstance(isShared)
     91    , clientData(0)
    9192{
    9293}
     
    131132    delete newParserObjects;
    132133    delete parserObjectExtraRefCounts;
     134   
     135    delete clientData;
    133136}
    134137
     
    158161}
    159162
     163JSGlobalData::ClientData::~ClientData()
     164{
    160165}
     166
     167}
Note: See TracChangeset for help on using the changeset viewer.