diff --git a/src/386_dynarec.c b/src/386_dynarec.c index 8954538..1238cc0 100644 --- a/src/386_dynarec.c +++ b/src/386_dynarec.c @@ -602,7 +602,7 @@ void exec386_dynarec(int cycs) { uint32_t phys_addr = get_phys(cs+cpu_state.pc); int hash = HASH(phys_addr); - codeblock_t *block = codeblock_hash[hash]; + codeblock_t *block = &codeblock[codeblock_hash[hash]]; int valid_block = 0; trap = 0; @@ -630,7 +630,10 @@ void exec386_dynarec(int cycs) (new_block->phys == phys_addr) && !((new_block->status ^ cpu_cur_status) & CPU_STATUS_FLAGS) && ((new_block->status & cpu_cur_status & CPU_STATUS_MASK) == (cpu_cur_status & CPU_STATUS_MASK)); if (valid_block) + { block = new_block; + codeblock_hash[hash] = get_block_nr(block); + } } } } @@ -675,7 +678,6 @@ void exec386_dynarec(int cycs) { void (*code)() = (void *)&block->data[BLOCK_START]; - codeblock_hash[hash] = block; // if (output) pclog("Run block at %04x:%04x %04x %04x %04x %04x %04x %04x ESP=%08x %04x %08x %08x %016llx %08x\n", CS, pc, AX, BX, CX, DX, SI, DI, ESP, BP, get_phys(cs+pc), block->phys, block->page_mask, block->endpc); inrecomp=1; diff --git a/src/codegen.c b/src/codegen.c index ba9c06a..7a74756 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -14,7 +14,7 @@ int has_ea; codeblock_t *codeblock; -codeblock_t **codeblock_hash; +uint16_t *codeblock_hash; void (*codegen_timing_start)(); void (*codegen_timing_prefix)(uint8_t prefix, uint32_t fetchdat); diff --git a/src/codegen.h b/src/codegen.h index 72a3820..93657a1 100644 --- a/src/codegen.h +++ b/src/codegen.h @@ -65,7 +65,7 @@ uint8_t *codeblock_data; extern codeblock_t *codeblock; -extern codeblock_t **codeblock_hash; +extern uint16_t *codeblock_hash; /*Code block uses FPU*/ #define CODEBLOCK_HAS_FPU 1 diff --git a/src/codegen_backend.c b/src/codegen_backend.c index de292e3..500230d 100644 --- a/src/codegen_backend.c +++ b/src/codegen_backend.c @@ -92,7 +92,7 @@ void codegen_reset() int c; memset(codeblock, 0, BLOCK_SIZE * sizeof(codeblock_t)); - memset(codeblock_hash, 0, HASH_SIZE * sizeof(codeblock_t *)); + memset(codeblock_hash, 0, HASH_SIZE * sizeof(uint16_t)); mem_reset_page_blocks(); for (c = 0; c < BLOCK_SIZE; c++) @@ -211,8 +211,8 @@ static void delete_block(codeblock_t *block) { uint32_t old_pc = block->pc; - if (block == codeblock_hash[HASH(block->phys)]) - codeblock_hash[HASH(block->phys)] = NULL; + if (block == &codeblock[codeblock_hash[HASH(block->phys)]]) + codeblock_hash[HASH(block->phys)] = BLOCK_INVALID; if (block->pc == BLOCK_PC_INVALID) fatal("Deleting deleted block\n"); @@ -279,7 +279,7 @@ void codegen_block_init(uint32_t phys_addr) cpu_recomp_reuse++; } block_num = HASH(phys_addr); - codeblock_hash[block_num] = &codeblock[block_current]; + codeblock_hash[block_num] = block_current; block->ins = 0; block->pc = cs + cpu_state.pc;