cpu,gbdb: implement better breakpoints
Previously, gbdb had to check several signals, including the current PC, to determine when do_run() should stop. This code was hotpath and unecessarily slow. Instead, leverage a n undefined instruction (0xd3) as a breakpoint instruction. When the CPU emulation encounters this instruction, it will call a callback which is implemented by gbdb. This can set a simple flag which is less expensive to query. Finally, both the signal handler and the breakpoint callback set specific "paused" flags and a generic "pause" flag. Now, do_run() can simply check the generic "paused" flag, then use the specific flags to determine the stop reason. This change increased performance by ~10% on Raspberry Pi.
This commit is contained in:
@@ -94,8 +94,11 @@ struct lr35902_state {
|
||||
|
||||
int stall_cycles;
|
||||
int halted;
|
||||
|
||||
lr35902_mem_read_fn mem_read;
|
||||
lr35902_mem_write_fn mem_write;
|
||||
void (*undef_d3)(struct lr35902_state *reg);
|
||||
|
||||
lr35902_interrupt_state int_state;
|
||||
struct lr35902_event events[LR35902_MAX_EVENTS];
|
||||
|
||||
@@ -108,9 +111,15 @@ struct lr35902_state {
|
||||
} metrics;
|
||||
};
|
||||
|
||||
struct lr35902_ops {
|
||||
lr35902_mem_read_fn mem_read;
|
||||
lr35902_mem_write_fn mem_write;
|
||||
|
||||
void (*undef_d3)(struct lr35902_state *reg);
|
||||
};
|
||||
|
||||
void lr35902_init(struct lr35902_state *cpu,
|
||||
lr35902_mem_read_fn mem_read,
|
||||
lr35902_mem_write_fn mem_write);
|
||||
const struct lr35902_ops *ops);
|
||||
|
||||
uint16_t lr35902_get_reg_16(const struct lr35902_state *cpu,
|
||||
lr35902_regs_16 reg);
|
||||
|
||||
Reference in New Issue
Block a user