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
|
|
@ -1534,6 +1534,66 @@ static int codegen_MOV_INT_DOUBLE_64(codeblock_t *block, uop_t *uop)
|
|||
|
||||
return 0;
|
||||
}
|
||||
static int codegen_MOV_REG_PTR(codeblock_t *block, uop_t *uop)
|
||||
{
|
||||
int dest_reg = HOST_REG_GET(uop->dest_reg_a_real);
|
||||
int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real);
|
||||
|
||||
host_arm_MOV_IMM(block, REG_TEMP, (uintptr_t)uop->p);
|
||||
if (REG_IS_L(dest_size))
|
||||
{
|
||||
host_arm_LDR_IMM(block, dest_reg, REG_TEMP, 0);
|
||||
}
|
||||
else
|
||||
fatal("MOV_REG_PTR %02x\n", uop->dest_reg_a_real);
|
||||
|
||||
return 0;
|
||||
}
|
||||
static int codegen_MOVZX_REG_PTR_8(codeblock_t *block, uop_t *uop)
|
||||
{
|
||||
int dest_reg = HOST_REG_GET(uop->dest_reg_a_real);
|
||||
int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real);
|
||||
|
||||
host_arm_MOV_IMM(block, REG_TEMP, (uintptr_t)uop->p);
|
||||
if (REG_IS_L(dest_size))
|
||||
{
|
||||
host_arm_LDRB_IMM(block, dest_reg, REG_TEMP, 0);
|
||||
}
|
||||
else if (REG_IS_W(dest_size))
|
||||
{
|
||||
host_arm_LDRB_IMM(block, REG_TEMP, REG_TEMP, 0);
|
||||
host_arm_BFI(block, dest_reg, REG_TEMP, 0, 16);
|
||||
}
|
||||
else if (REG_IS_B(dest_size))
|
||||
{
|
||||
host_arm_LDRB_IMM(block, REG_TEMP, REG_TEMP, 0);
|
||||
host_arm_BFI(block, dest_reg, REG_TEMP, 0, 8);
|
||||
}
|
||||
else
|
||||
fatal("MOVZX_REG_PTR_8 %02x\n", uop->dest_reg_a_real);
|
||||
|
||||
return 0;
|
||||
}
|
||||
static int codegen_MOVZX_REG_PTR_16(codeblock_t *block, uop_t *uop)
|
||||
{
|
||||
int dest_reg = HOST_REG_GET(uop->dest_reg_a_real);
|
||||
int dest_size = IREG_GET_SIZE(uop->dest_reg_a_real);
|
||||
|
||||
host_arm_MOV_IMM(block, REG_TEMP, (uintptr_t)uop->p);
|
||||
if (REG_IS_L(dest_size))
|
||||
{
|
||||
host_arm_LDRH_IMM(block, dest_reg, REG_TEMP, 0);
|
||||
}
|
||||
else if (REG_IS_W(dest_size))
|
||||
{
|
||||
host_arm_LDRH_IMM(block, REG_TEMP, REG_TEMP, 0);
|
||||
host_arm_BFI(block, dest_reg, REG_TEMP, 0, 16);
|
||||
}
|
||||
else
|
||||
fatal("MOVZX_REG_PTR_16 %02x\n", uop->dest_reg_a_real);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int codegen_OR(codeblock_t *block, uop_t *uop)
|
||||
{
|
||||
|
|
@ -2914,6 +2974,9 @@ const uOpFn uop_handlers[UOP_MAX] =
|
|||
[UOP_MOV_DOUBLE_INT & UOP_MASK] = codegen_MOV_DOUBLE_INT,
|
||||
[UOP_MOV_INT_DOUBLE & UOP_MASK] = codegen_MOV_INT_DOUBLE,
|
||||
[UOP_MOV_INT_DOUBLE_64 & UOP_MASK] = codegen_MOV_INT_DOUBLE_64,
|
||||
[UOP_MOV_REG_PTR & UOP_MASK] = codegen_MOV_REG_PTR,
|
||||
[UOP_MOVZX_REG_PTR_8 & UOP_MASK] = codegen_MOVZX_REG_PTR_8,
|
||||
[UOP_MOVZX_REG_PTR_16 & UOP_MASK] = codegen_MOVZX_REG_PTR_16,
|
||||
|
||||
[UOP_ADD & UOP_MASK] = codegen_ADD,
|
||||
[UOP_ADD_IMM & UOP_MASK] = codegen_ADD_IMM,
|
||||
|
|
|
|||
Loading…
Reference in a new issue