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