[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

jorlow at chromium.org jorlow at chromium.org
Thu Apr 8 01:59:20 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 7f4936955b67657f56189b690d1fb7e3c8d032c0
Author: jorlow at chromium.org <jorlow at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Feb 25 18:27:45 2010 +0000

    Make the context that was passed to the ThreadFunction accessible.
    https://bugs.webkit.org/show_bug.cgi?id=35379
    
    Patch by Jochen Eisinger <jochen at chromium.org> on 2010-02-25
    Reviewed by Jeremy Orlow.
    
    When a database is opened, right now you
    don't have any context from where it is opened. The problem is that
    the actual calls that open a database go through the sqlite3 vfs
    layer, so there's no easy way to pass this function down to to
    platform/sql/chromium/SQLFileSystemChromium*.cpp
    
    This patch will allow you to get from anywhere within webkit a pointer
    to the Thread object that actually created the thread you're currently
    on (in case of the database, this can be either a thread forked of
    from the main thread or from a worker thread), and query the object
    for context information.
    
    * wtf/Threading.h:
    * wtf/ThreadingNone.cpp:
    (WTF::threadContext):
    * wtf/ThreadingPthreads.cpp:
    (WTF::):
    (WTF::identifierByPthreadHandle):
    (WTF::establishIdentifierForPthreadHandle):
    (WTF::pthreadHandleForIdentifier):
    (WTF::contextForIdentifier):
    (WTF::createThreadInternal):
    (WTF::currentThread):
    (WTF::threadContext):
    * wtf/ThreadingWin.cpp:
    (WTF::):
    (WTF::threadMap):
    (WTF::storeThreadHandleByIdentifier):
    (WTF::threadHandleForIdentifier):
    (WTF::contextForIdentifier):
    (WTF::createThreadInternal):
    (WTF::threadContext):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55247 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index a76e480..58eeee8 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,43 @@
+2010-02-25  Jochen Eisinger  <jochen at chromium.org>
+ 
+        Reviewed by Jeremy Orlow.
+ 
+        Make the context that was passed to the ThreadFunction accessible.
+        https://bugs.webkit.org/show_bug.cgi?id=35379
+
+        When a database is opened, right now you
+        don't have any context from where it is opened. The problem is that
+        the actual calls that open a database go through the sqlite3 vfs
+        layer, so there's no easy way to pass this function down to to
+        platform/sql/chromium/SQLFileSystemChromium*.cpp
+
+        This patch will allow you to get from anywhere within webkit a pointer
+        to the Thread object that actually created the thread you're currently
+        on (in case of the database, this can be either a thread forked of
+        from the main thread or from a worker thread), and query the object
+        for context information.
+
+        * wtf/Threading.h:
+        * wtf/ThreadingNone.cpp:
+        (WTF::threadContext):
+        * wtf/ThreadingPthreads.cpp:
+        (WTF::):
+        (WTF::identifierByPthreadHandle):
+        (WTF::establishIdentifierForPthreadHandle):
+        (WTF::pthreadHandleForIdentifier):
+        (WTF::contextForIdentifier):
+        (WTF::createThreadInternal):
+        (WTF::currentThread):
+        (WTF::threadContext):
+        * wtf/ThreadingWin.cpp:
+        (WTF::):
+        (WTF::threadMap):
+        (WTF::storeThreadHandleByIdentifier):
+        (WTF::threadHandleForIdentifier):
+        (WTF::contextForIdentifier):
+        (WTF::createThreadInternal):
+        (WTF::threadContext):
+
 2010-02-25  Jeremy Orlow  <jorlow at chromium.org>
 
         Reverting to re-submit with better change log.
diff --git a/JavaScriptCore/wtf/Threading.h b/JavaScriptCore/wtf/Threading.h
index b7a2f08..b522915 100644
--- a/JavaScriptCore/wtf/Threading.h
+++ b/JavaScriptCore/wtf/Threading.h
@@ -127,6 +127,7 @@ ThreadIdentifier currentThread();
 bool isMainThread();
 int waitForThreadCompletion(ThreadIdentifier, void**);
 void detachThread(ThreadIdentifier);
+void* threadContext(ThreadIdentifier);
 
 #if USE(PTHREADS)
 typedef pthread_mutex_t PlatformMutex;
diff --git a/JavaScriptCore/wtf/ThreadingNone.cpp b/JavaScriptCore/wtf/ThreadingNone.cpp
index 2e8a259..cfc9d31 100644
--- a/JavaScriptCore/wtf/ThreadingNone.cpp
+++ b/JavaScriptCore/wtf/ThreadingNone.cpp
@@ -41,6 +41,7 @@ int waitForThreadCompletion(ThreadIdentifier, void**) { return 0; }
 void detachThread(ThreadIdentifier) { }
 ThreadIdentifier currentThread() { return ThreadIdentifier(); }
 bool isMainThread() { return true; }
+void* threadContext(ThreadIdentifier) { return 0; }
 
 Mutex::Mutex() { }
 Mutex::~Mutex() { }
diff --git a/JavaScriptCore/wtf/ThreadingPthreads.cpp b/JavaScriptCore/wtf/ThreadingPthreads.cpp
index 2feb808..e841f62 100644
--- a/JavaScriptCore/wtf/ThreadingPthreads.cpp
+++ b/JavaScriptCore/wtf/ThreadingPthreads.cpp
@@ -53,7 +53,12 @@
 
 namespace WTF {
 
-typedef HashMap<ThreadIdentifier, pthread_t> ThreadMap;
+typedef struct {
+    pthread_t handle;
+    void* context;
+} ThreadInfo;
+
+typedef HashMap<ThreadIdentifier, ThreadInfo> ThreadMap;
 
 static Mutex* atomicallyInitializedStaticMutex;
 
@@ -105,14 +110,14 @@ static ThreadIdentifier identifierByPthreadHandle(const pthread_t& pthreadHandle
 
     ThreadMap::iterator i = threadMap().begin();
     for (; i != threadMap().end(); ++i) {
-        if (pthread_equal(i->second, pthreadHandle))
+        if (pthread_equal(i->second.handle, pthreadHandle))
             return i->first;
     }
 
     return 0;
 }
 
-static ThreadIdentifier establishIdentifierForPthreadHandle(const pthread_t& pthreadHandle)
+static ThreadIdentifier establishIdentifierForPthreadHandle(const pthread_t& pthreadHandle, void* context)
 {
     ASSERT(!identifierByPthreadHandle(pthreadHandle));
 
@@ -120,7 +125,10 @@ static ThreadIdentifier establishIdentifierForPthreadHandle(const pthread_t& pth
 
     static ThreadIdentifier identifierCount = 1;
 
-    threadMap().add(identifierCount, pthreadHandle);
+    ThreadInfo info;
+    info.handle = pthreadHandle;
+    info.context = context;
+    threadMap().add(identifierCount, info);
 
     return identifierCount++;
 }
@@ -129,9 +137,17 @@ static pthread_t pthreadHandleForIdentifier(ThreadIdentifier id)
 {
     MutexLocker locker(threadMapMutex());
 
-    return threadMap().get(id);
+    return threadMap().get(id).handle;
+}
+
+static void* contextForIdentifier(ThreadIdentifier id)
+{
+    MutexLocker locker(threadMapMutex());
+
+    return threadMap().get(id).context;
 }
 
+
 void clearPthreadHandleForIdentifier(ThreadIdentifier id)
 {
     MutexLocker locker(threadMapMutex());
@@ -174,7 +190,7 @@ ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, con
         delete threadData;
         return 0;
     }
-    return establishIdentifierForPthreadHandle(threadHandle);
+    return establishIdentifierForPthreadHandle(threadHandle, data);
 }
 #else
 ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, const char*)
@@ -185,7 +201,7 @@ ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, con
         return 0;
     }
 
-    return establishIdentifierForPthreadHandle(threadHandle);
+    return establishIdentifierForPthreadHandle(threadHandle, data);
 }
 #endif
 
@@ -235,7 +251,7 @@ ThreadIdentifier currentThread()
         return id;
 
     // Not a WTF-created thread, ThreadIdentifier is not established yet.
-    id = establishIdentifierForPthreadHandle(pthread_self());
+    id = establishIdentifierForPthreadHandle(pthread_self(), 0);
     ThreadIdentifierData::initialize(id);
     return id;
 }
@@ -249,6 +265,11 @@ bool isMainThread()
 #endif
 }
 
+void* threadContext(ThreadIdentifier id)
+{
+    return contextForIdentifier(id); 
+}
+
 Mutex::Mutex()
 {
     pthread_mutex_init(&m_mutex, NULL);
diff --git a/JavaScriptCore/wtf/ThreadingWin.cpp b/JavaScriptCore/wtf/ThreadingWin.cpp
index 73c3f0c..75da7b4 100644
--- a/JavaScriptCore/wtf/ThreadingWin.cpp
+++ b/JavaScriptCore/wtf/ThreadingWin.cpp
@@ -118,6 +118,11 @@ typedef struct tagTHREADNAME_INFO {
 } THREADNAME_INFO;
 #pragma pack(pop)
 
+typedef struct {
+    HANDLE handle;
+    void* context;
+} ThreadInfo;
+
 void initializeCurrentThreadInternal(const char* szThreadName)
 {
     THREADNAME_INFO info;
@@ -165,23 +170,32 @@ void initializeThreading()
     }
 }
 
-static HashMap<DWORD, HANDLE>& threadMap()
+static HashMap<DWORD, ThreadInfo>& threadMap()
 {
-    static HashMap<DWORD, HANDLE> map;
+    static HashMap<DWORD, ThreadInfo> map;
     return map;
 }
 
-static void storeThreadHandleByIdentifier(DWORD threadID, HANDLE threadHandle)
+static void storeThreadHandleByIdentifier(DWORD threadID, HANDLE threadHandle, void* context)
 {
     MutexLocker locker(threadMapMutex());
     ASSERT(!threadMap().contains(threadID));
-    threadMap().add(threadID, threadHandle);
+    ThreadInfo info;
+    info.handle = threadHandle;
+    info.context = context;
+    threadMap().add(threadID, info);
 }
 
 static HANDLE threadHandleForIdentifier(ThreadIdentifier id)
 {
     MutexLocker locker(threadMapMutex());
-    return threadMap().get(id);
+    return threadMap().get(id).handle;
+}
+
+static void* contextForIdentifier(ThreadIdentifier id)
+{
+    MutexLocker locker(threadMapMutex());
+    return threadMap().get(id).context;
 }
 
 static void clearThreadHandleForIdentifier(ThreadIdentifier id)
@@ -237,7 +251,7 @@ ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, con
     }
 
     threadID = static_cast<ThreadIdentifier>(threadIdentifier);
-    storeThreadHandleByIdentifier(threadIdentifier, threadHandle);
+    storeThreadHandleByIdentifier(threadIdentifier, threadHandle, data);
 
     return threadID;
 }
@@ -280,6 +294,11 @@ bool isMainThread()
     return currentThread() == mainThreadIdentifier;
 }
 
+void* threadContext(ThreadIdentifier threadID)
+{
+    return contextForIdentifier(threadID);
+}
+
 Mutex::Mutex()
 {
     m_mutex.m_recursionCount = 0;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list