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)
|
static void step(char *arg_list)
|
||||||
{
|
{
|
||||||
uint64_t steps, init_steps;
|
uint64_t steps, end_steps;
|
||||||
char *token;
|
char *token;
|
||||||
token = strtok(arg_list, " ");
|
token = strtok(arg_list, " ");
|
||||||
if (token == NULL) {
|
if (token == NULL) {
|
||||||
@@ -198,15 +198,14 @@ static void step(char *arg_list)
|
|||||||
|
|
||||||
paused = 0;
|
paused = 0;
|
||||||
signal(SIGINT, break_execution_handler);
|
signal(SIGINT, break_execution_handler);
|
||||||
init_steps = cpu.metrics.retired_instrs;
|
end_steps = cpu.metrics.retired_instrs + steps;
|
||||||
do {
|
do {
|
||||||
cycle();
|
cycle();
|
||||||
} while (init_steps + steps > cpu.metrics.retired_instrs &&
|
} while (end_steps > cpu.metrics.retired_instrs &&
|
||||||
!cpu_at_breakpoint() &&
|
!cpu_at_breakpoint() &&
|
||||||
!cpu.halted &&
|
|
||||||
!paused);
|
!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);
|
gb_log("CPU stopped after %" PRId64 " instructions\n", steps);
|
||||||
} else if (cpu_at_breakpoint()) {
|
} else if (cpu_at_breakpoint()) {
|
||||||
breakpoint_addr_hit(cpu.pc);
|
breakpoint_addr_hit(cpu.pc);
|
||||||
|
|||||||
Reference in New Issue
Block a user