#define APIShims_h
#include "CallFrame.h"
+#include "GCActivityCallback.h"
+#include "IncrementalSweeper.h"
#include "JSLock.h"
+#include <wtf/WTFThreadData.h>
namespace JSC {
class APIEntryShimWithoutLock {
protected:
- APIEntryShimWithoutLock(JSGlobalData* globalData, bool registerThread)
- : m_globalData(globalData)
- , m_entryIdentifierTable(setCurrentIdentifierTable(globalData->identifierTable))
+ APIEntryShimWithoutLock(VM* vm, bool registerThread)
+ : m_vm(vm)
+ , m_entryIdentifierTable(wtfThreadData().setCurrentIdentifierTable(vm->identifierTable))
{
if (registerThread)
- globalData->heap.registerThread();
- m_globalData->timeoutChecker.start();
+ vm->heap.machineThreads().addCurrentThread();
}
~APIEntryShimWithoutLock()
{
- m_globalData->timeoutChecker.stop();
- setCurrentIdentifierTable(m_entryIdentifierTable);
+ wtfThreadData().setCurrentIdentifierTable(m_entryIdentifierTable);
}
-private:
- JSGlobalData* m_globalData;
+protected:
+ RefPtr<VM> m_vm;
IdentifierTable* m_entryIdentifierTable;
};
public:
// Normal API entry
APIEntryShim(ExecState* exec, bool registerThread = true)
- : APIEntryShimWithoutLock(&exec->globalData(), registerThread)
- , m_lock(exec)
+ : APIEntryShimWithoutLock(&exec->vm(), registerThread)
+ , m_lockHolder(exec)
+ {
+ }
+
+ // JSPropertyNameAccumulator only has a vm.
+ APIEntryShim(VM* vm, bool registerThread = true)
+ : APIEntryShimWithoutLock(vm, registerThread)
+ , m_lockHolder(vm)
{
}
- // JSPropertyNameAccumulator only has a globalData.
- APIEntryShim(JSGlobalData* globalData, bool registerThread = true)
- : APIEntryShimWithoutLock(globalData, registerThread)
- , m_lock(globalData->isSharedInstance ? LockForReal : SilenceAssertionsOnly)
+ ~APIEntryShim()
{
+ // Destroying our JSLockHolder should also destroy the VM.
+ m_vm.clear();
}
private:
- JSLock m_lock;
+ JSLockHolder m_lockHolder;
};
class APICallbackShim {
public:
APICallbackShim(ExecState* exec)
: m_dropAllLocks(exec)
- , m_globalData(&exec->globalData())
+ , m_vm(&exec->vm())
{
- resetCurrentIdentifierTable();
- m_globalData->timeoutChecker.start();
+ wtfThreadData().resetCurrentIdentifierTable();
}
~APICallbackShim()
{
- m_globalData->timeoutChecker.stop();
- setCurrentIdentifierTable(m_globalData->identifierTable);
+ wtfThreadData().setCurrentIdentifierTable(m_vm->identifierTable);
}
private:
JSLock::DropAllLocks m_dropAllLocks;
- JSGlobalData* m_globalData;
+ VM* m_vm;
};
}