Rework self modifying code handling.
Code blocks now have a varying level of granularity in the page and dirty masks. Most blocks have 64-byte granularity, but blocks that are repeatedly modified drop to 1-byte granularity. This reduces the maximum size of the affected block significantly, but reduces recompilation due to data located too close to code. If the block is still marked as dirty, then it is recompiled without any immediate instruction parameters being baked into the recompiled code, instead being fetched from the RAM array as needed. This severely reduces recompilation rates on some SMC-heavy games, eg Duke Nukem 3D, System Shock, Screamer etc, giving a major speedup.
This commit is contained in:
parent
063ffb4eab
commit
ab124776a0
36 changed files with 1719 additions and 233 deletions
|
|
@ -1,3 +1,4 @@
|
|||
#include "386_common.h"
|
||||
#include "codegen_backend.h"
|
||||
|
||||
static inline int LOAD_SP_WITH_OFFSET(ir_data_t *ir, int offset)
|
||||
|
|
@ -85,3 +86,26 @@ static inline void CHECK_SEG_LIMITS(codeblock_t *block, ir_data_t *ir, x86seg *s
|
|||
else
|
||||
uop_CMP_JNBE(ir, addr_reg, ireg_seg_limit_high(seg), codegen_gpf_rout);
|
||||
}
|
||||
|
||||
static inline void LOAD_IMMEDIATE_FROM_RAM_8(codeblock_t *block, ir_data_t *ir, int dest_reg, uint32_t addr)
|
||||
{
|
||||
uop_MOVZX_REG_PTR_8(ir, dest_reg, get_ram_ptr(addr));
|
||||
}
|
||||
|
||||
void LOAD_IMMEDIATE_FROM_RAM_16_unaligned(codeblock_t *block, ir_data_t *ir, int dest_reg, uint32_t addr);
|
||||
static inline void LOAD_IMMEDIATE_FROM_RAM_16(codeblock_t *block, ir_data_t *ir, int dest_reg, uint32_t addr)
|
||||
{
|
||||
if ((addr & 0xfff) == 0xfff)
|
||||
LOAD_IMMEDIATE_FROM_RAM_16_unaligned(block, ir, dest_reg, addr);
|
||||
else
|
||||
uop_MOVZX_REG_PTR_16(ir, dest_reg, get_ram_ptr(addr));
|
||||
}
|
||||
|
||||
void LOAD_IMMEDIATE_FROM_RAM_32_unaligned(codeblock_t *block, ir_data_t *ir, int dest_reg, uint32_t addr);
|
||||
static inline void LOAD_IMMEDIATE_FROM_RAM_32(codeblock_t *block, ir_data_t *ir, int dest_reg, uint32_t addr)
|
||||
{
|
||||
if ((addr & 0xfff) >= 0xffd)
|
||||
LOAD_IMMEDIATE_FROM_RAM_32_unaligned(block, ir, dest_reg, addr);
|
||||
else
|
||||
uop_MOV_REG_PTR(ir, dest_reg, get_ram_ptr(addr));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue