MachineStackMarker.h [plain text]
#ifndef MachineThreads_h
#define MachineThreads_h
#include <setjmp.h>
#include <wtf/Noncopyable.h>
#include <wtf/ThreadSpecific.h>
#include <wtf/ThreadingPrimitives.h>
namespace JSC {
class CodeBlockSet;
class ConservativeRoots;
class Heap;
class JITStubRoutineSet;
class MachineThreads {
WTF_MAKE_NONCOPYABLE(MachineThreads);
public:
typedef jmp_buf RegisterState;
MachineThreads(Heap*);
~MachineThreads();
void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&, void* stackOrigin, void* stackTop, RegisterState& calleeSavedRegisters);
JS_EXPORT_PRIVATE void addCurrentThread();
private:
class Thread;
void gatherFromCurrentThread(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&, void* stackOrigin, void* stackTop, RegisterState& calleeSavedRegisters);
void tryCopyOtherThreadStack(Thread*, void*, size_t capacity, size_t*);
bool tryCopyOtherThreadStacks(MutexLocker&, void*, size_t capacity, size_t*);
static void removeThread(void*);
template<typename PlatformThread>
void removeThreadIfFound(PlatformThread);
Mutex m_registeredThreadsMutex;
Thread* m_registeredThreads;
WTF::ThreadSpecificKey m_threadSpecific;
#if !ASSERT_DISABLED
Heap* m_heap;
#endif
};
}
#if COMPILER(GCC)
#define REGISTER_BUFFER_ALIGNMENT __attribute__ ((aligned (sizeof(void*))))
#else
#define REGISTER_BUFFER_ALIGNMENT
#endif
#if COMPILER(MSVC)
#pragma warning(push)
#pragma warning(disable: 4611)
#define ALLOCATE_AND_GET_REGISTER_STATE(registers) \
MachineThreads::RegisterState registers REGISTER_BUFFER_ALIGNMENT; \
setjmp(registers)
#pragma warning(pop)
#else
#define ALLOCATE_AND_GET_REGISTER_STATE(registers) \
MachineThreads::RegisterState registers REGISTER_BUFFER_ALIGNMENT; \
setjmp(registers)
#endif
#endif // MachineThreads_h