X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/81345200c95645a1b0d2635520f96ad55dfde63f..ed1e77d3adeb83d26fd1dfb16dd84cabdcefd250:/heap/MachineStackMarker.h?ds=sidebyside diff --git a/heap/MachineStackMarker.h b/heap/MachineStackMarker.h index 33b72c8..9b6b732 100644 --- a/heap/MachineStackMarker.h +++ b/heap/MachineStackMarker.h @@ -22,6 +22,7 @@ #ifndef MachineThreads_h #define MachineThreads_h +#include #include #include #include @@ -36,23 +37,27 @@ namespace JSC { class MachineThreads { WTF_MAKE_NONCOPYABLE(MachineThreads); public: + typedef jmp_buf RegisterState; + MachineThreads(Heap*); ~MachineThreads(); - void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&, void* stackCurrent); + void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&, void* stackOrigin, void* stackTop, RegisterState& calleeSavedRegisters); - JS_EXPORT_PRIVATE void makeUsableFromMultipleThreads(); JS_EXPORT_PRIVATE void addCurrentThread(); // Only needs to be called by clients that can use the same heap from multiple threads. private: - void gatherFromCurrentThread(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&, void* stackCurrent); - 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*); - void removeCurrentThread(); - void gatherFromOtherThread(ConservativeRoots&, Thread*, JITStubRoutineSet&, CodeBlockSet&); + template + void removeThreadIfFound(PlatformThread); Mutex m_registeredThreadsMutex; Thread* m_registeredThreads; @@ -64,4 +69,24 @@ namespace JSC { } // namespace JSC +#if COMPILER(GCC) +#define REGISTER_BUFFER_ALIGNMENT __attribute__ ((aligned (sizeof(void*)))) +#else +#define REGISTER_BUFFER_ALIGNMENT +#endif + +// ALLOCATE_AND_GET_REGISTER_STATE() is a macro so that it is always "inlined" even in debug builds. +#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