diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-07-11 13:45:28 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-07-11 13:45:28 +0200 |
commit | d6a599dbc9d824a462b2b206316e102bf8136446 (patch) | |
tree | ecb257a5e55b2239d74b90fdad62fccd661cf286 /Source/JavaScriptCore/API/APIShims.h | |
parent | 3ccc3a85f09a83557b391aae380d3bf5f81a2911 (diff) | |
download | qtwebkit-d6a599dbc9d824a462b2b206316e102bf8136446.tar.gz |
Imported WebKit commit 8ff1f22783a32de82fee915abd55bd1b298f2644 (http://svn.webkit.org/repository/webkit/trunk@122325)
New snapshot that should work with the latest Qt build system changes
Diffstat (limited to 'Source/JavaScriptCore/API/APIShims.h')
-rw-r--r-- | Source/JavaScriptCore/API/APIShims.h | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/Source/JavaScriptCore/API/APIShims.h b/Source/JavaScriptCore/API/APIShims.h index 02495110b..ef5f10466 100644 --- a/Source/JavaScriptCore/API/APIShims.h +++ b/Source/JavaScriptCore/API/APIShims.h @@ -28,31 +28,40 @@ #include "CallFrame.h" #include "GCActivityCallback.h" +#include "IncrementalSweeper.h" #include "JSLock.h" #include <wtf/WTFThreadData.h> namespace JSC { class APIEntryShimWithoutLock { +public: + enum RefGlobalDataTag { DontRefGlobalData = 0, RefGlobalData }; + protected: - APIEntryShimWithoutLock(JSGlobalData* globalData, bool registerThread) - : m_globalData(globalData) + APIEntryShimWithoutLock(JSGlobalData* globalData, bool registerThread, RefGlobalDataTag shouldRefGlobalData) + : m_shouldRefGlobalData(shouldRefGlobalData) + , m_globalData(globalData) , m_entryIdentifierTable(wtfThreadData().setCurrentIdentifierTable(globalData->identifierTable)) { + if (shouldRefGlobalData) + m_globalData->ref(); UNUSED_PARAM(registerThread); if (registerThread) globalData->heap.machineThreads().addCurrentThread(); m_globalData->heap.activityCallback()->synchronize(); - m_globalData->timeoutChecker.start(); + m_globalData->heap.sweeper()->synchronize(); } ~APIEntryShimWithoutLock() { - m_globalData->timeoutChecker.stop(); wtfThreadData().setCurrentIdentifierTable(m_entryIdentifierTable); + if (m_shouldRefGlobalData) + m_globalData->deref(); } -private: +protected: + RefGlobalDataTag m_shouldRefGlobalData; JSGlobalData* m_globalData; IdentifierTable* m_entryIdentifierTable; }; @@ -61,20 +70,38 @@ class APIEntryShim : public APIEntryShimWithoutLock { public: // Normal API entry APIEntryShim(ExecState* exec, bool registerThread = true) - : APIEntryShimWithoutLock(&exec->globalData(), registerThread) - , m_lock(exec) + : APIEntryShimWithoutLock(&exec->globalData(), registerThread, RefGlobalData) + { + init(); + } + + // This constructor is necessary for HeapTimer to prevent it from accidentally resurrecting + // the ref count of a "dead" JSGlobalData. + APIEntryShim(JSGlobalData* globalData, RefGlobalDataTag refGlobalData, bool registerThread = true) + : APIEntryShimWithoutLock(globalData, registerThread, refGlobalData) { + init(); } // JSPropertyNameAccumulator only has a globalData. APIEntryShim(JSGlobalData* globalData, bool registerThread = true) - : APIEntryShimWithoutLock(globalData, registerThread) - , m_lock(globalData->isSharedInstance() ? LockForReal : SilenceAssertionsOnly) + : APIEntryShimWithoutLock(globalData, registerThread, RefGlobalData) { + init(); + } + + ~APIEntryShim() + { + m_globalData->timeoutChecker.stop(); + m_globalData->apiLock().unlock(); } private: - JSLock m_lock; + void init() + { + m_globalData->apiLock().lock(); + m_globalData->timeoutChecker.start(); + } }; class APICallbackShim { @@ -88,7 +115,6 @@ public: ~APICallbackShim() { - m_globalData->heap.activityCallback()->synchronize(); wtfThreadData().setCurrentIdentifierTable(m_globalData->identifierTable); } |