Play-/Source/ee/EeExecutor.h

68 lines
1.7 KiB
C
Raw Permalink Normal View History

#pragma once
2015-06-09 02:49:54 -04:00
#ifdef _WIN32
2025-01-13 18:15:07 -05:00
#define NOMINMAX
#include <Windows.h>
2015-06-09 02:49:54 -04:00
#elif defined(__APPLE__)
2024-03-07 00:53:29 -05:00
#include <TargetConditionals.h>
2015-06-09 02:49:54 -04:00
#include <mach/mach.h>
#include <thread>
2016-08-12 02:06:12 +01:00
#elif defined(__unix__)
#include <signal.h>
2015-06-08 01:39:23 -04:00
#endif
#include "../GenericMipsExecutor.h"
class CEeExecutor : public CGenericMipsExecutor<BlockLookupTwoWay>
{
public:
2025-01-14 10:53:33 -05:00
using IdleLoopBlockSet = std::set<uint32>;
using BlockFpRoundingModeMap = std::map<uint32, Jitter::CJitter::ROUNDINGMODE>;
2025-01-13 18:15:07 -05:00
2018-04-30 21:01:23 +01:00
CEeExecutor(CMIPS&, uint8*);
virtual ~CEeExecutor() = default;
2025-01-14 10:53:33 -05:00
void SetBlockFpRoundingModes(BlockFpRoundingModeMap);
void SetIdleLoopBlocks(IdleLoopBlockSet);
2025-01-13 18:15:07 -05:00
2018-04-30 21:01:23 +01:00
void AddExceptionHandler();
void RemoveExceptionHandler();
2020-12-02 18:43:42 -05:00
void AttachExceptionHandlerToThread();
2018-04-30 21:01:23 +01:00
void Reset() override;
2018-07-21 20:49:58 -04:00
void ClearActiveBlocksInRange(uint32, uint32, bool) override;
2018-04-30 21:01:23 +01:00
BasicBlockPtr BlockFactory(CMIPS&, uint32, uint32) override;
private:
2022-10-21 09:42:16 +01:00
typedef std::pair<uint128, uint32> CachedBlockKey;
typedef std::map<CachedBlockKey, BasicBlockPtr> CachedBlockMap;
2018-07-12 12:54:42 -04:00
CachedBlockMap m_cachedBlocks;
2025-01-14 10:53:33 -05:00
IdleLoopBlockSet m_idleLoopBlocks;
BlockFpRoundingModeMap m_blockFpRoundingModes;
2025-01-13 18:15:07 -05:00
2018-04-30 21:01:23 +01:00
uint8* m_ram = nullptr;
size_t m_pageSize = 0;
bool HandleAccessFault(intptr_t);
void SetMemoryProtected(void*, size_t, bool);
2015-06-08 01:39:23 -04:00
2015-06-09 02:49:54 -04:00
#if defined(_WIN32)
2018-04-30 21:01:23 +01:00
static LONG CALLBACK HandleException(_EXCEPTION_POINTERS*);
LONG HandleExceptionInternal(_EXCEPTION_POINTERS*);
2015-06-08 01:39:23 -04:00
2018-04-30 21:01:23 +01:00
LPVOID m_handler = NULL;
2016-08-12 02:06:12 +01:00
#elif defined(__unix__) || defined(__ANDROID__)
2018-04-30 21:01:23 +01:00
static void HandleException(int, siginfo_t*, void*);
void HandleExceptionInternal(int, siginfo_t*, void*);
2024-03-07 00:53:29 -05:00
#elif defined(__APPLE__) && !TARGET_OS_TV
2018-04-30 21:01:23 +01:00
void HandlerThreadProc();
mach_port_t m_port = MACH_PORT_NULL;
std::thread m_handlerThread;
2020-12-27 19:11:29 -05:00
std::atomic<bool> m_running = false;
2015-06-08 01:39:23 -04:00
#endif
};