arm64 rec: get rid of setjmp()

This commit is contained in:
Flyinghead 2021-01-31 11:55:22 +01:00
parent 80782475da
commit 8e22116a17
2 changed files with 25 additions and 13 deletions

View File

@ -25,7 +25,7 @@
#else
#include "hw/sh4/dyna/ssa_regalloc.h"
#endif
#include "deps/vixl/aarch64/macro-assembler-aarch64.h"
#include <aarch64/macro-assembler-aarch64.h>
using namespace vixl::aarch64;
enum eReg {

View File

@ -23,9 +23,8 @@
#include <unistd.h>
#include <map>
#include <setjmp.h>
#include "deps/vixl/aarch64/macro-assembler-aarch64.h"
#include <aarch64/macro-assembler-aarch64.h>
using namespace vixl::aarch64;
//#define NO_BLOCK_LINKING
@ -67,12 +66,13 @@ struct DynaRBI : RuntimeBlockInfo
double host_cpu_time;
u64 guest_cpu_cycles;
static jmp_buf jmp_env;
static u32 cycle_counter;
static u64 jmp_stack;
static void (*mainloop)(void *context);
static int (*arm64_intc_sched)();
static void (*arm64_no_update)();
static void (*handleException)();
#ifdef PROFILING
#include <time.h>
@ -188,7 +188,7 @@ static T ReadMemNoEx(u32 addr, u32, u32 pc)
if (ex)
{
spc = pc;
longjmp(jmp_env, 1);
handleException();
}
return rv;
#else
@ -204,7 +204,7 @@ static void WriteMemNoEx(u32 addr, T data, u32 pc)
if (ex)
{
spc = pc;
longjmp(jmp_env, 1);
handleException();
}
#endif
}
@ -221,7 +221,7 @@ static void interpreter_fallback(u16 op, OpCallFP *oph, u32 pc)
pc--;
}
Do_Exception(pc, ex.expEvn, ex.callVect);
longjmp(jmp_env, 1);
handleException();
}
}
@ -237,7 +237,7 @@ static void do_sqw_mmu_no_ex(u32 addr, u32 pc)
pc--;
}
Do_Exception(pc, ex.expEvn, ex.callVect);
longjmp(jmp_env, 1);
handleException();
}
}
@ -1468,6 +1468,7 @@ public:
Stp(x29, x30, MemOperand(sp, 144));
Sub(x0, x0, sizeof(Sh4Context));
Label reenterLabel;
if (mmu_enabled())
{
Ldr(x1, reinterpret_cast<uintptr_t>(&cycle_counter));
@ -1476,10 +1477,11 @@ public:
Mov(w0, SH4_TIMESLICE);
Str(w0, MemOperand(x1));
Ldr(x0, reinterpret_cast<uintptr_t>(jmp_env));
Ldr(x1, reinterpret_cast<uintptr_t>(&setjmp));
Blr(x1);
Ldr(x0, reinterpret_cast<uintptr_t>(&jmp_stack));
Mov(x1, sp);
Str(x1, MemOperand(x0));
Bind(&reenterLabel);
Ldr(x28, MemOperand(sp)); // Set context
}
else
@ -1540,10 +1542,21 @@ public:
Ldp(x19, x20, MemOperand(sp, 160, PostIndex));
Ret();
Label handleExceptionLabel;
Bind(&handleExceptionLabel);
if (mmu_enabled())
{
Ldr(x0, reinterpret_cast<uintptr_t>(&jmp_stack));
Ldr(x1, MemOperand(x0));
Mov(sp, x1);
B(&reenterLabel);
}
FinalizeCode();
emit_Skip(GetBuffer()->GetSizeInBytes());
arm64_no_update = GetLabelAddress<void (*)()>(&no_update);
handleException = GetLabelAddress<void (*)()>(&handleExceptionLabel);
// Flush and invalidate caches
vmem_platform_flush_cache(
@ -2289,8 +2302,7 @@ RuntimeBlockInfo* ngen_AllocateBlock()
void ngen_HandleException(host_context_t &context)
{
// TODO
longjmp(jmp_env, 1);
context.pc = (uintptr_t)handleException;
}
u32 DynaRBI::Relink()