Do not get the globaldata for the APIShim via the
authorbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Apr 2010 00:07:38 +0000 (00:07 +0000)
committerbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Apr 2010 00:07:38 +0000 (00:07 +0000)
global object; global object construction creates identifiers
which results in the ASSERTs checking the thread data's
identifierTable has been set failing.

Rubber stamped by Sam Weinig

* JSUtils.cpp:
(unprotectGlobalObject):
(getThreadGlobalData):
(getThreadGlobalObject):
(JSGlueAPIEntry::JSGlueAPIEntry):
(JSGlueAPICallback::~JSGlueAPICallback):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@58131 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptGlue/ChangeLog
JavaScriptGlue/JSUtils.cpp

index 69a8208..02a2d07 100644 (file)
@@ -1,3 +1,19 @@
+2010-04-22  Gavin Barraclough  <barraclough@apple.com>
+
+        Rubber stamped by Sam Weinig
+
+        Do not get the globaldata for the APIShim via the
+        global object; global object construction creates identifiers
+        which results in the ASSERTs checking the thread data's
+        identifierTable has been set failing.
+
+        * JSUtils.cpp:
+        (unprotectGlobalObject):
+        (getThreadGlobalData):
+        (getThreadGlobalObject):
+        (JSGlueAPIEntry::JSGlueAPIEntry):
+        (JSGlueAPICallback::~JSGlueAPICallback):
+
 2010-04-21  Geoffrey Garen  <ggaren@apple.com>
 
         Reviewed by Sam Weinig.
index f2b7e64..b83ac52 100644 (file)
@@ -395,9 +395,8 @@ static pthread_once_t globalObjectKeyOnce = PTHREAD_ONCE_INIT;
 
 static void unprotectGlobalObject(void* data) 
 {
-    JSGlobalObject* jsGlobalObject = static_cast<JSGlueGlobalObject*>(data);
-    JSGlueAPIEntry entry(jsGlobalObject);
-    gcUnprotect(jsGlobalObject);
+    JSGlueAPIEntry entry;
+    gcUnprotect(static_cast<JSGlueGlobalObject*>(data));
 }
 
 static void initializeGlobalObjectKey()
@@ -405,19 +404,18 @@ static void initializeGlobalObjectKey()
     pthread_key_create(&globalObjectKey, unprotectGlobalObject);
 }
 
+JSGlobalData* getThreadGlobalData()
+{
+    return &JSGlobalData::sharedInstance();
+}
+
 static JSGlueGlobalObject* getThreadGlobalObject()
 {
     pthread_once(&globalObjectKeyOnce, initializeGlobalObjectKey);
     JSGlueGlobalObject* globalObject = static_cast<JSGlueGlobalObject*>(pthread_getspecific(globalObjectKey));
     if (!globalObject) {
-        JSGlobalData& globalData = JSGlobalData::sharedInstance();
-
-        IdentifierTable* storedIdentifierTable = wtfThreadData().currentIdentifierTable();
-        wtfThreadData().setCurrentIdentifierTable(globalData.identifierTable);
-        globalObject = new (&globalData) JSGlueGlobalObject(JSGlueGlobalObject::createStructure(jsNull()));
+        globalObject = new (getThreadGlobalData()) JSGlueGlobalObject(JSGlueGlobalObject::createStructure(jsNull()));
         gcProtect(globalObject);
-        wtfThreadData().setCurrentIdentifierTable(storedIdentifierTable);
-
         pthread_setspecific(globalObjectKey, globalObject);
     }
     return globalObject;
@@ -437,14 +435,7 @@ JSGlueAPIEntry::JSGlueAPIEntry()
     : m_lock(LockForReal)
     , m_storedIdentifierTable(wtfThreadData().currentIdentifierTable())
 {
-    wtfThreadData().setCurrentIdentifierTable(getThreadGlobalObject()->globalExec()->globalData().identifierTable);
-}
-
-JSGlueAPIEntry::JSGlueAPIEntry(JSGlobalObject* jsGlobalObject)
-    : m_lock(LockForReal)
-    , m_storedIdentifierTable(wtfThreadData().currentIdentifierTable())
-{
-    wtfThreadData().setCurrentIdentifierTable(jsGlobalObject->globalExec()->globalData().identifierTable);
+    wtfThreadData().setCurrentIdentifierTable(getThreadGlobalData()->identifierTable);
 }
 
 JSGlueAPIEntry::~JSGlueAPIEntry()
@@ -460,5 +451,5 @@ JSGlueAPICallback::JSGlueAPICallback(ExecState* exec)
 
 JSGlueAPICallback::~JSGlueAPICallback()
 {
-    wtfThreadData().setCurrentIdentifierTable(getThreadGlobalObject()->globalExec()->globalData().identifierTable);
+    wtfThreadData().setCurrentIdentifierTable(getThreadGlobalData()->identifierTable);
 }