From 81ca016581003c6eea67b88af071af7d22d7e9c5 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Tue, 19 Mar 2024 02:30:22 +0100 Subject: [DYNAREC] This should fix some issue with dynarec, like #1366 (but should be revisited soon, to many bytes writen there) --- src/dynarec/dynarec_native.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/dynarec/dynarec_native.c b/src/dynarec/dynarec_native.c index 84e5d3dc..77badf62 100644 --- a/src/dynarec/dynarec_native.c +++ b/src/dynarec/dynarec_native.c @@ -393,6 +393,11 @@ static int updateNeed(dynarec_native_t* dyn, int ninst, uint8_t need) { } void* current_helper = NULL; +static int static_jmps[MAX_INSTS+2]; +static uintptr_t static_next[MAX_INSTS+2]; +static uint64_t static_table64[(MAX_INSTS+3)/4]; +static instruction_native_t static_insts[MAX_INSTS+2] = {0}; +// TODO: ninst could be a uint16_t instead of an int, that could same some temp. memory void CancelBlock64(int need_lock) { @@ -401,6 +406,7 @@ void CancelBlock64(int need_lock) dynarec_native_t* helper = (dynarec_native_t*)current_helper; current_helper = NULL; if(helper) { + memset(static_insts, 0, sizeof(static_insts)); if(helper->dynablock && helper->dynablock->actual_block) { FreeDynarecMap((uintptr_t)helper->dynablock->actual_block); helper->dynablock->actual_block = NULL; @@ -438,12 +444,6 @@ void* CreateEmptyBlock(dynablock_t* block, uintptr_t addr) { return block; } -static int static_jmps[MAX_INSTS+2]; -static uintptr_t static_next[MAX_INSTS+2]; -static uint64_t static_table64[(MAX_INSTS+3)/4]; -static instruction_native_t static_insts[MAX_INSTS+2] = {0}; -// TODO: ninst could be a uint16_t instead of an int, that could same some temp. memory - void* FillBlock64(dynablock_t* block, uintptr_t addr, int alternate, int is32bits) { /* A Block must have this layout: @@ -674,6 +674,7 @@ void* FillBlock64(dynablock_t* block, uintptr_t addr, int alternate, int is32bit } // ok, free the helper now //dynaFree(helper.insts); + memset(static_insts, 0, sizeof(static_insts)); helper.insts = NULL; if(insts_rsize/sizeof(instsize_t)