Properly fixed update_tsc().

This commit is contained in:
OBattler
2020-07-12 23:51:56 +02:00
parent 38828bdc3b
commit 099fd2fc34
4 changed files with 12 additions and 15 deletions

View File

@@ -21,7 +21,7 @@ void codegen_accumulate(int acc_reg, int delta)
{ {
acc_regs[acc_reg].count += delta; acc_regs[acc_reg].count += delta;
if (delta != 0) { if ((acc_reg == ACCREG_cycles) && (delta != 0)) {
addbyte(0x81); /*ADD $acc_regs[c].count,acc_regs[c].dest*/ addbyte(0x81); /*ADD $acc_regs[c].count,acc_regs[c].dest*/
addbyte(0x04); addbyte(0x04);
addbyte(0x25); addbyte(0x25);

View File

@@ -21,7 +21,7 @@ void codegen_accumulate(int acc_reg, int delta)
{ {
acc_regs[acc_reg].count += delta; acc_regs[acc_reg].count += delta;
if (delta != 0) { if ((acc_reg == ACCREG_cycles) && (delta != 0)) {
addbyte(0x81); /*ADD $acc_regs[c].count,acc_regs[c].dest*/ addbyte(0x81); /*ADD $acc_regs[c].count,acc_regs[c].dest*/
addbyte(0x05); addbyte(0x05);
addlong((uint32_t) (uintptr_t) &(acycs)); addlong((uint32_t) (uintptr_t) &(acycs));
@@ -45,8 +45,6 @@ void codegen_accumulate_flush(void)
acc_regs[c].count = 0; acc_regs[c].count = 0;
} }
acycs = 0;
} }
void codegen_accumulate_reset() void codegen_accumulate_reset()

View File

@@ -21,7 +21,7 @@ void codegen_accumulate(ir_data_t *ir, int acc_reg, int delta)
{ {
acc_regs[acc_reg].count += delta; acc_regs[acc_reg].count += delta;
if (delta != 0) { if ((acc_reg == ACCREG_cycles) && (delta != 0)) {
uop_ADD_IMM(ir, IREG_acycs, IREG_acycs, -delta); uop_ADD_IMM(ir, IREG_acycs, IREG_acycs, -delta);
} }
} }

View File

@@ -283,23 +283,20 @@ void update_tsc(void)
int cycdiff; int cycdiff;
uint64_t delta; uint64_t delta;
if (CACHE_ON()) cycdiff = cycles_old - cycles;
cycdiff = acycs; if (inrecomp)
else cycdiff += acycs;
cycdiff = cycles_old - cycles;
delta = tsc - tsc_old; delta = tsc - tsc_old;
if (delta > 0) { if (delta > 0) {
/* TSC has changed, this means interim timer processing has happened, /* TSC has changed, this means interim timer processing has happened,
see how much we still need to add. */ see how much we still need to add. */
cycdiff -= delta; cycdiff -= delta;
if (cycdiff > 0)
tsc += cycdiff;
} else {
/* TSC has not changed. */
if (cycdiff > 0)
tsc += cycdiff;
} }
if (cycdiff > 0)
tsc += cycdiff;
if (cycdiff > 0) { if (cycdiff > 0) {
if (TIMER_VAL_LESS_THAN_VAL(timer_target, (uint32_t)tsc)) if (TIMER_VAL_LESS_THAN_VAL(timer_target, (uint32_t)tsc))
timer_process(); timer_process();
@@ -319,6 +316,7 @@ void exec386_dynarec(int cycs)
int cyc_period = cycs / 2000; /*5us*/ int cyc_period = cycs / 2000; /*5us*/
acycs = 0;
cycles_main += cycs; cycles_main += cycs;
while (cycles_main > 0) while (cycles_main > 0)
{ {
@@ -540,6 +538,7 @@ void exec386_dynarec(int cycs)
inrecomp=1; inrecomp=1;
code(); code();
acycs = 0;
inrecomp=0; inrecomp=0;
#ifndef USE_NEW_DYNAREC #ifndef USE_NEW_DYNAREC