gbdb: change cycle calculation for better performance
The conditions are hotpath, so pre-calcuate the end cycle count instead of doing it every loop. I didn't verify that the compiler wasn't doing this anyway, but this won't hurt.
This commit is contained in:
@@ -186,7 +186,7 @@ static void echo(char *arg_list)
|
||||
|
||||
static void step(char *arg_list)
|
||||
{
|
||||
uint64_t steps, init_steps;
|
||||
uint64_t steps, end_steps;
|
||||
char *token;
|
||||
token = strtok(arg_list, " ");
|
||||
if (token == NULL) {
|
||||
@@ -198,15 +198,14 @@ static void step(char *arg_list)
|
||||
|
||||
paused = 0;
|
||||
signal(SIGINT, break_execution_handler);
|
||||
init_steps = cpu.metrics.retired_instrs;
|
||||
end_steps = cpu.metrics.retired_instrs + steps;
|
||||
do {
|
||||
cycle();
|
||||
} while (init_steps + steps > cpu.metrics.retired_instrs &&
|
||||
} while (end_steps > cpu.metrics.retired_instrs &&
|
||||
!cpu_at_breakpoint() &&
|
||||
!cpu.halted &&
|
||||
!paused);
|
||||
|
||||
if (init_steps + steps <= cpu.metrics.retired_instrs) {
|
||||
if (end_steps <= cpu.metrics.retired_instrs) {
|
||||
gb_log("CPU stopped after %" PRId64 " instructions\n", steps);
|
||||
} else if (cpu_at_breakpoint()) {
|
||||
breakpoint_addr_hit(cpu.pc);
|
||||
|
||||
Reference in New Issue
Block a user