Both recompilers now check for interrupt after every instruction and exit the block if one has happened.

This commit is contained in:
OBattler
2020-07-13 01:23:40 +02:00
parent 099fd2fc34
commit 0cd0d83cee
6 changed files with 58 additions and 2 deletions

View File

@@ -1095,6 +1095,14 @@ generate_call:
codegen_block_full_ins++;
codegen_endpc = (cs + cpu_state.pc) + 8;
/* Check for interrupts. */
call(block, (uintptr_t)int_check);
addbyte(0x85); /*OR %eax, %eax*/
addbyte(0xc0);
addbyte(0x0F); addbyte(0x85); /*JNZ 0*/
addlong((uint32_t)(uintptr_t)&block->data[BLOCK_EXIT_OFFSET] - (uint32_t)(uintptr_t)(&block->data[block_pos + 4]));
return;
}
}
@@ -1172,6 +1180,14 @@ generate_call:
addbyte(0x0F); addbyte(0x85); /*JNZ 0*/
addlong((uint32_t)(uintptr_t)&block->data[BLOCK_EXIT_OFFSET] - (uint32_t)(uintptr_t)(&block->data[block_pos + 4]));
/* Check for interrupts. */
call(block, (uintptr_t)int_check);
addbyte(0x85); /*OR %eax, %eax*/
addbyte(0xc0);
addbyte(0x0F); addbyte(0x85); /*JNZ 0*/
addlong((uint32_t)(uintptr_t)&block->data[BLOCK_EXIT_OFFSET] - (uint32_t)(uintptr_t)(&block->data[block_pos + 4]));
codegen_endpc = (cs + cpu_state.pc) + 8;
}

View File

@@ -2062,6 +2062,15 @@ generate_call:
codegen_block_full_ins++;
codegen_endpc = (cs + cpu_state.pc) + 8;
/* Check for interrupts. */
addbyte(0xE8); /*CALL*/
addlong(((uint8_t *)int_check - (uint8_t *)(&block->data[block_pos + 4])));
addbyte(0x09); /*OR %eax, %eax*/
addbyte(0xc0);
addbyte(0x0F); addbyte(0x85); /*JNZ 0*/
addlong((uint32_t)&block->data[BLOCK_EXIT_OFFSET] - (uint32_t)(&block->data[block_pos + 4]));
return;
}
}
@@ -2150,6 +2159,15 @@ generate_call:
addbyte(0x0F); addbyte(0x85); /*JNZ 0*/
addlong((uint32_t)&block->data[BLOCK_EXIT_OFFSET] - (uint32_t)(&block->data[block_pos + 4]));
/* Check for interrupts. */
addbyte(0xE8); /*CALL*/
addlong(((uint8_t *)int_check - (uint8_t *)(&block->data[block_pos + 4])));
addbyte(0x09); /*OR %eax, %eax*/
addbyte(0xc0);
addbyte(0x0F); addbyte(0x85); /*JNZ 0*/
addlong((uint32_t)&block->data[BLOCK_EXIT_OFFSET] - (uint32_t)(&block->data[block_pos + 4]));
codegen_endpc = (cs + cpu_state.pc) + 8;
}

View File

@@ -696,6 +696,9 @@ generate_call:
block->ins++;
/* Check for interrupts. */
uop_CALL_INSTRUCTION_FUNC(ir, int_check);
if (block->ins >= MAX_INSTRUCTION_COUNT)
CPU_BLOCK_END();
@@ -756,6 +759,8 @@ generate_call:
uop_MOV_IMM(ir, IREG_ssegs, op_ssegs);
uop_LOAD_FUNC_ARG_IMM(ir, 0, fetchdat);
uop_CALL_INSTRUCTION_FUNC(ir, op);
/* Check for interrupts. */
uop_CALL_INSTRUCTION_FUNC(ir, int_check);
codegen_mark_code_present(block, cs+cpu_state.pc, 8);
last_op_32 = op_32;

View File

@@ -303,6 +303,23 @@ void update_tsc(void)
}
}
int int_check(void)
{
if (cpu_state.abrt)
return 1;
if (trap)
return 1;
else if (smi_line)
return 1;
else if (nmi && nmi_enable && nmi_mask)
return 1;
else if ((cpu_state.flags & I_FLAG) && pic_intpending)
return 1;
return 0;
}
void exec386_dynarec(int cycs)
{
int vector;

View File

@@ -61,8 +61,6 @@
#endif
#include "x87_timings.h"
/*#define ENABLE_CPU_LOG 1*/
static void cpu_write(uint16_t addr, uint8_t val, void *priv);
static uint8_t cpu_read(uint16_t addr, void *priv);

View File

@@ -601,4 +601,6 @@ extern const char *fpu_get_internal_name(int machine, int cpu_manufacturer, int
extern const char *fpu_get_name_from_index(int machine, int cpu_manufacturer, int cpu, int c);
extern int fpu_get_type_from_index(int machine, int cpu_manufacturer, int cpu, int c);
extern int int_check();
#endif /*EMU_CPU_H*/