Ignore:
Timestamp:
Apr 26, 2010, 3:38:55 PM (15 years ago)
Author:
[email protected]
Message:

Fix for https://bugs.webkit.org/show_bug.cgi?id=38097
Disentangle initializing the main thread from initializing threading

Reviewed by Maciej Stachowiak.

JavaScriptCore:

This is the first step in getting rid of the WEB_THREAD #define and
paving the way to allowing mac both WebKit and WebKit2 to use the same
WebCore.

  • JavaScriptCore.exp: Export initializeMainThread and initializeMainThreadToProcessMainThread.
  • JavaScriptCore.xcodeproj/project.pbxproj: Sort files.
  • wtf/MainThread.cpp:

(WTF::mainThreadInitializationMutex):
(WTF::mainThreadFunctionQueueMutex):
(WTF::initializeMainThread):
(WTF::deprecatedInitializeMainThread):

  • wtf/MainThread.h:

Added Mac only initializeMainThreadToProcessMainThread which sets up callOnMainThread
and isMainThead calls to assume that WebCore's main thread is also the
process's main thread. Since it is possible that both initializeMainThread
and initializeMainThreadToProcessMainThread could be called, the first one called
wins (either will work).

  • wtf/Threading.h: Moved to top of file.
  • wtf/ThreadingPthreads.cpp:

(WTF::initializeThreading): Remove call to initializeMainThread.

  • wtf/ThreadingWin.cpp:

(WTF::initializeThreading): Ditto.

  • wtf/gtk/ThreadingGtk.cpp:

(WTF::initializeThreading): Ditto.

  • wtf/mac/MainThreadMac.mm:

(WTF::initializeMainThreadPlatform):
(WTF::initializeMainThreadToProcessMainThread):
(WTF::scheduleDispatchFunctionsOnMainThread):
(WTF::isMainThread):
Add runtime switch between the old behavior of using the system's main
thread and a stored pointer to the main thread. Tiger always uses the
system's main thread.

  • wtf/qt/ThreadingQt.cpp:

(WTF::initializeThreading): Remove call to initializeMainThread.

  • wtf/win/MainThreadWin.cpp:

(WTF::initializeMainThreadPlatform): Add call to initializeCurrentThreadInternal
removed from initializeThreading.

WebCore:

  • WebCore.xcodeproj/project.pbxproj: Sort files.
  • accessibility/mac/AccessibilityObjectWrapper.mm: Remove unnessary

+initialize method. The AccessibilityObjectWrapper has no data members
that need to be derefed, so it does not need to be finalized on the main
thread.

  • bindings/js/ScriptController.cpp:

(WebCore::ScriptController::initializeThreading): Add call to initializeMainThread.

  • bindings/objc/WebScriptObject.mm:

(+[WebScriptObject initialize]): Add call to initializeMainThreadToProcessMainThread.

  • bindings/v8/ScriptController.cpp:

(WebCore::ScriptController::initializeThreading): Add call to initializeMainThread.

  • platform/mac/SharedBufferMac.mm:

(+[WebCoreSharedBufferData initialize]): Add call to initializeMainThreadToProcessMainThread.

WebKit/chromium:

  • src/WebKit.cpp:

(WebKit::initialize): Add call to initializeMainThread.

  • src/WebViewImpl.cpp:

(WebKit::WebViewImpl::WebViewImpl): Ditto.

WebKit/gtk:

  • webkit/webkitprivate.cpp:

(webkit_init): Add call to initializeMainThread.

WebKit/mac:

Calls initializeMainThreadToProcessMainThread since there is no way to ensure
that the initialize method will be called on the main thread.

  • Carbon/CarbonWindowAdapter.mm:

(+[CarbonWindowAdapter initialize]): Add call to initializeMainThreadToProcessMainThread.

  • History/WebBackForwardList.mm:

(+[WebBackForwardList initialize]): Ditto.

  • History/WebHistoryItem.mm:

(+[WebHistoryItem initialize]): Ditto.

  • Misc/WebElementDictionary.mm:

(+[WebElementDictionary initialize]): Ditto.

  • Misc/WebIconDatabase.mm:

(+[WebIconDatabase initialize]): Ditto.

  • Plugins/Hosted/WebHostedNetscapePluginView.mm:

(+[WebHostedNetscapePluginView initialize]): Ditto.

  • Plugins/WebBaseNetscapePluginView.mm:

(+[WebBaseNetscapePluginView initialize]): Ditto.

  • Plugins/WebBasePluginPackage.mm:

(+[WebBasePluginPackage initialize]): Ditto.

  • Plugins/WebNetscapePluginView.mm:

(+[WebNetscapePluginView initialize]): Ditto.

  • WebCoreSupport/WebEditorClient.mm:

(+[WebEditCommand initialize]): Ditto.

  • WebCoreSupport/WebFrameLoaderClient.mm:

(+[WebFramePolicyListener initialize]): Ditto.

  • WebView/WebArchive.mm:

(+[WebArchivePrivate initialize]): Ditto.

  • WebView/WebDataSource.mm:

(+[WebDataSourcePrivate initialize]): Ditto.

  • WebView/WebHTMLView.mm:

(+[WebHTMLViewPrivate initialize]): Ditto.
(+[WebHTMLView initialize]): Ditto.

  • WebView/WebResource.mm:

(+[WebResourcePrivate initialize]): Ditto.

  • WebView/WebTextIterator.mm:

(+[WebTextIteratorPrivate initialize]): Ditto.

  • WebView/WebView.mm:
  • WebView/WebViewData.mm: Ditto.

(+[WebViewPrivate initialize]): Ditto.

WebKit/qt:

  • Api/qwebpage.cpp:

(QWebPagePrivate::QWebPagePrivate): Add call to initializeMainThread.

WebKit/win:

  • WebKitClassFactory.cpp:

(WebKitClassFactory::WebKitClassFactory): Add call to initializeMainThread.

  • WebView.cpp:

(WebView::WebView): Ditto.

WebKit/wx:

  • WebView.cpp:

(wxWebView::Create): Add call to initializeMainThread.

WebKit2:

  • UIProcess/Launcher/mac/WebProcessLauncher.mm:

(WebKit::webThreadBody): Add call to initializeMainThread.

  • UIProcess/Launcher/win/WebProcessLauncher.cpp:

(WebKit::webThreadBody): Ditto.

  • WebProcess/Launching/mac/WebProcessMain.mm:

(main): Ditto.

  • WebProcess/win/WebProcessMain.cpp:

(WebKit::WebProcessMain): Ditto.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/Threading.h

    r58206 r58266  
    8282typedef void* (*ThreadFunction)(void* argument);
    8383
     84// This function must be called from the main thread. It is safe to call it repeatedly.
     85// Darwin is an exception to this rule: it is OK to call it from any thread, the only
     86// requirement is that the calls are not reentrant.
     87void initializeThreading();
     88
    8489// Returns 0 if thread creation failed.
    8590// The thread name must be a literal since on some platforms it's passed in to the thread.
     
    97102void detachThread(ThreadIdentifier);
    98103
    99 // This function must be called from the main thread. It is safe to call it repeatedly.
    100 // Darwin is an exception to this rule: it is OK to call it from any thread, the only requirement is that the calls are not reentrant.
    101 void initializeThreading();
    102104
    103105void lockAtomicallyInitializedStaticMutex();
Note: See TracChangeset for help on using the changeset viewer.