Bump CI clang version to 15 + workaround for unsafe fiber optimizations (#982)

This commit is contained in:
Exzap 2023-09-29 17:17:28 +02:00 committed by GitHub
parent 8a4abb8bbb
commit 8bb7ce098c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 150 additions and 132 deletions

View file

@ -210,7 +210,8 @@ void debugger_handleSingleStepException(uint64 dr6)
}
if (catchBP)
{
debugger_createCodeBreakpoint(ppcInterpreterCurrentInstance->instructionPointer + 4, DEBUGGER_BP_T_ONE_SHOT);
PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance();
debugger_createCodeBreakpoint(hCPU->instructionPointer + 4, DEBUGGER_BP_T_ONE_SHOT);
}
}

View file

@ -959,8 +959,9 @@ void GDBServer::HandleAccessException(uint64 dr6)
if (!response.empty())
{
PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance();
cemuLog_logDebug(LogType::Force, "Received matching breakpoint exception: {}", response);
auto nextInstructions = findNextInstruction(ppcInterpreterCurrentInstance->instructionPointer, ppcInterpreterCurrentInstance->spr.LR, ppcInterpreterCurrentInstance->spr.CTR);
auto nextInstructions = findNextInstruction(hCPU->instructionPointer, hCPU->spr.LR, hCPU->spr.CTR);
for (MPTR nextInstr : nextInstructions)
{
auto bpIt = m_patchedInstructions.find(nextInstr);

View file

@ -6,7 +6,6 @@
thread_local PPCInterpreter_t* ppcInterpreterCurrentInstance;
// main thread instruction counter and timing
volatile uint64 ppcMainThreadCycleCounter = 0;
uint64 ppcMainThreadDECCycleValue = 0; // value that was set to dec register
uint64 ppcMainThreadDECCycleStart = 0; // at which cycle the dec register was set, if == 0 -> dec is 0
uint64 ppcCyclesSince2000 = 0;
@ -29,11 +28,16 @@ PPCInterpreter_t* PPCInterpreter_createInstance(unsigned int Entrypoint)
return pData;
}
PPCInterpreter_t* PPCInterpreter_getCurrentInstance()
TLS_WORKAROUND_NOINLINE PPCInterpreter_t* PPCInterpreter_getCurrentInstance()
{
return ppcInterpreterCurrentInstance;
}
TLS_WORKAROUND_NOINLINE void PPCInterpreter_setCurrentInstance(PPCInterpreter_t* hCPU)
{
ppcInterpreterCurrentInstance = hCPU;
}
uint64 PPCInterpreter_getMainCoreCycleCounter()
{
return PPCTimer_getFromRDTSC();
@ -78,24 +82,25 @@ uint32 PPCInterpreter_getCoreIndex(PPCInterpreter_t* hCPU)
uint32 PPCInterpreter_getCurrentCoreIndex()
{
return ppcInterpreterCurrentInstance->spr.UPIR;
return PPCInterpreter_getCurrentInstance()->spr.UPIR;
};
uint8* PPCInterpreterGetStackPointer()
{
return memory_getPointerFromVirtualOffset(ppcInterpreterCurrentInstance->gpr[1]);
return memory_getPointerFromVirtualOffset(PPCInterpreter_getCurrentInstance()->gpr[1]);
}
uint8* PPCInterpreterGetAndModifyStackPointer(sint32 offset)
{
uint8* result = memory_getPointerFromVirtualOffset(ppcInterpreterCurrentInstance->gpr[1] - offset);
ppcInterpreterCurrentInstance->gpr[1] -= offset;
PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance();
uint8* result = memory_getPointerFromVirtualOffset(hCPU->gpr[1] - offset);
hCPU->gpr[1] -= offset;
return result;
}
void PPCInterpreterModifyStackPointer(sint32 offset)
{
ppcInterpreterCurrentInstance->gpr[1] -= offset;
PPCInterpreter_getCurrentInstance()->gpr[1] -= offset;
}
uint32 RPLLoader_MakePPCCallable(void(*ppcCallableExport)(PPCInterpreter_t* hCPU));

View file

@ -18,19 +18,20 @@ uint32 PPCCoreCallback(MPTR function, PPCCoreCallbackData_t& data, T currentArg,
{
cemu_assert_debug(data.gprCount <= 8);
cemu_assert_debug(data.floatCount <= 8);
PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance();
if constexpr (std::is_pointer_v<T>)
{
ppcInterpreterCurrentInstance->gpr[3 + data.gprCount] = MEMPTR(currentArg).GetMPTR();
hCPU->gpr[3 + data.gprCount] = MEMPTR(currentArg).GetMPTR();
data.gprCount++;
}
else if constexpr (std::is_base_of_v<MEMPTRBase, std::remove_reference_t<T>>)
{
ppcInterpreterCurrentInstance->gpr[3 + data.gprCount] = currentArg.GetMPTR();
hCPU->gpr[3 + data.gprCount] = currentArg.GetMPTR();
data.gprCount++;
}
else if constexpr (std::is_reference_v<T>)
{
ppcInterpreterCurrentInstance->gpr[3 + data.gprCount] = MEMPTR(&currentArg).GetMPTR();
hCPU->gpr[3 + data.gprCount] = MEMPTR(&currentArg).GetMPTR();
data.gprCount++;
}
else if constexpr(std::is_enum_v<T>)
@ -40,19 +41,19 @@ uint32 PPCCoreCallback(MPTR function, PPCCoreCallbackData_t& data, T currentArg,
}
else if constexpr (std::is_floating_point_v<T>)
{
ppcInterpreterCurrentInstance->fpr[1 + data.floatCount].fpr = (double)currentArg;
hCPU->fpr[1 + data.floatCount].fpr = (double)currentArg;
data.floatCount++;
}
else if constexpr (std::is_integral_v<T> && sizeof(T) == sizeof(uint64))
{
ppcInterpreterCurrentInstance->gpr[3 + data.gprCount] = (uint32)(currentArg >> 32); // high
ppcInterpreterCurrentInstance->gpr[3 + data.gprCount + 1] = (uint32)currentArg; // low
hCPU->gpr[3 + data.gprCount] = (uint32)(currentArg >> 32); // high
hCPU->gpr[3 + data.gprCount + 1] = (uint32)currentArg; // low
data.gprCount += 2;
}
else
{
ppcInterpreterCurrentInstance->gpr[3 + data.gprCount] = (uint32)currentArg;
hCPU->gpr[3 + data.gprCount] = (uint32)currentArg;
data.gprCount++;
}

View file

@ -11,21 +11,24 @@ uint32 ppcThreadQuantum = 45000; // execute 45000 instructions before thread res
void PPCInterpreter_relinquishTimeslice()
{
if( ppcInterpreterCurrentInstance->remainingCycles >= 0 )
PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance();
if( hCPU->remainingCycles >= 0 )
{
ppcInterpreterCurrentInstance->skippedCycles = ppcInterpreterCurrentInstance->remainingCycles + 1;
ppcInterpreterCurrentInstance->remainingCycles = -1;
hCPU->skippedCycles = hCPU->remainingCycles + 1;
hCPU->remainingCycles = -1;
}
}
void PPCCore_boostQuantum(sint32 numCycles)
{
ppcInterpreterCurrentInstance->remainingCycles += numCycles;
PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance();
hCPU->remainingCycles += numCycles;
}
void PPCCore_deboostQuantum(sint32 numCycles)
{
ppcInterpreterCurrentInstance->remainingCycles -= numCycles;
PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance();
hCPU->remainingCycles -= numCycles;
}
namespace coreinit
@ -36,7 +39,7 @@ namespace coreinit
void PPCCore_switchToScheduler()
{
cemu_assert_debug(__OSHasSchedulerLock() == false); // scheduler lock must not be hold past thread time slice
cemu_assert_debug(ppcInterpreterCurrentInstance->coreInterruptMask != 0 || CafeSystem::GetForegroundTitleId() == 0x000500001019e600);
cemu_assert_debug(PPCInterpreter_getCurrentInstance()->coreInterruptMask != 0 || CafeSystem::GetForegroundTitleId() == 0x000500001019e600);
__OSLockScheduler();
coreinit::__OSThreadSwitchToNext();
__OSUnlockScheduler();
@ -45,7 +48,7 @@ void PPCCore_switchToScheduler()
void PPCCore_switchToSchedulerWithLock()
{
cemu_assert_debug(__OSHasSchedulerLock() == true); // scheduler lock must be hold
cemu_assert_debug(ppcInterpreterCurrentInstance->coreInterruptMask != 0 || CafeSystem::GetForegroundTitleId() == 0x000500001019e600);
cemu_assert_debug(PPCInterpreter_getCurrentInstance()->coreInterruptMask != 0 || CafeSystem::GetForegroundTitleId() == 0x000500001019e600);
coreinit::__OSThreadSwitchToNext();
}
@ -58,7 +61,7 @@ void _PPCCore_callbackExit(PPCInterpreter_t* hCPU)
PPCInterpreter_t* PPCCore_executeCallbackInternal(uint32 functionMPTR)
{
cemu_assert_debug(functionMPTR != 0);
PPCInterpreter_t* hCPU = ppcInterpreterCurrentInstance;
PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance();
// remember LR and instruction pointer
uint32 lr = hCPU->spr.LR;
uint32 ip = hCPU->instructionPointer;

View file

@ -220,7 +220,7 @@ void PPCCoreLLE_startSingleCoreScheduler(uint32 entrypoint)
for (uint32 coreIndex = 0; coreIndex < 3; coreIndex++)
{
PPCInterpreter_t* hCPU = cpuContext->cores+coreIndex;
ppcInterpreterCurrentInstance = hCPU;
PPCInterpreter_setCurrentInstance(hCPU);
if (coreIndex == 1)
{
// check SCR core 1 enable bit

View file

@ -149,6 +149,7 @@ static uint64 PPCInterpreter_getCallParamU64(PPCInterpreter_t* hCPU, uint32 inde
PPCInterpreter_t* PPCInterpreter_createInstance(unsigned int Entrypoint);
PPCInterpreter_t* PPCInterpreter_getCurrentInstance();
void PPCInterpreter_setCurrentInstance(PPCInterpreter_t* hCPU);
uint64 PPCInterpreter_getMainCoreCycleCounter();
@ -192,7 +193,6 @@ uint32 PPCInterpreter_getCurrentCoreIndex();
void PPCInterpreter_setDEC(PPCInterpreter_t* hCPU, uint32 newValue);
// timing for main processor
extern volatile uint64 ppcMainThreadCycleCounter;
extern uint64 ppcCyclesSince2000; // on init this is set to the cycles that passed since 1.1.2000
extern uint64 ppcCyclesSince2000TimerClock; // on init this is set to the cycles that passed since 1.1.2000 / 20
extern uint64 ppcCyclesSince2000_UTC;
@ -213,7 +213,6 @@ void PPCTimer_start();
// core info and control
extern uint32 ppcThreadQuantum;
extern thread_local PPCInterpreter_t *ppcInterpreterCurrentInstance;
uint8* PPCInterpreterGetAndModifyStackPointer(sint32 offset);
uint8* PPCInterpreterGetStackPointer();
void PPCInterpreterModifyStackPointer(sint32 offset);

View file

@ -100,7 +100,7 @@ void* ATTR_MS_ABI PPCRecompiler_virtualHLE(PPCInterpreter_t* hCPU, uint32 hleFun
hCPU->remainingCycles -= 500; // let subtract about 500 cycles for each HLE call
hCPU->gpr[3] = 0;
PPCInterpreter_nextInstruction(hCPU);
return ppcInterpreterCurrentInstance;
return hCPU;
}
else
{
@ -109,7 +109,7 @@ void* ATTR_MS_ABI PPCRecompiler_virtualHLE(PPCInterpreter_t* hCPU, uint32 hleFun
hleCall(hCPU);
}
hCPU->rspTemp = prevRSPTemp;
return ppcInterpreterCurrentInstance;
return PPCInterpreter_getCurrentInstance();
}
void ATTR_MS_ABI PPCRecompiler_getTBL(PPCInterpreter_t* hCPU, uint32 gprIndex)