Browse Source

minor perf improvement

Fabian 4 months ago
parent
commit
bfb59f926b
4 changed files with 7 additions and 7 deletions
  1. 1 1
      src/browser/starter.js
  2. 2 2
      src/cpu.js
  3. 3 3
      src/rust/cpu/cpu.rs
  4. 1 1
      src/rust/cpu/instructions.rs

+ 1 - 1
src/browser/starter.js

@@ -109,7 +109,7 @@ function V86(options)
 
     const wasm_shared_funcs = {
         "cpu_exception_hook": n => this.cpu_exception_hook(n),
-        "run_hardware_timers": function(t) { return cpu.run_hardware_timers(t); },
+        "run_hardware_timers": function(a, t) { return cpu.run_hardware_timers(a, t); },
         "cpu_event_halt": () => { this.emulator_bus.send("cpu-event-halt"); },
         "abort": function() { dbg_assert(false); },
         "microtick": v86.microtick,

+ 2 - 2
src/cpu.js

@@ -1449,14 +1449,14 @@ CPU.prototype.dump_function_code = function(block_ptr, count)
     }
 };
 
-CPU.prototype.run_hardware_timers = function(now)
+CPU.prototype.run_hardware_timers = function(acpi_enabled, now)
 {
     const pit_time = this.devices.pit.timer(now, false);
     const rtc_time = this.devices.rtc.timer(now, false);
 
     let acpi_time = 100;
     let apic_time = 100;
-    if(this.acpi_enabled[0])
+    if(acpi_enabled)
     {
         acpi_time = this.devices.acpi.timer(now);
         apic_time = this.devices.apic.timer(now);

+ 3 - 3
src/rust/cpu/cpu.rs

@@ -4,7 +4,7 @@ extern "C" {
     fn cpu_exception_hook(interrupt: i32) -> bool;
     fn call_indirect1(f: i32, x: u16);
     pub fn microtick() -> f64;
-    pub fn run_hardware_timers(t: f64) -> f64;
+    pub fn run_hardware_timers(acpi_enabled: bool, t: f64) -> f64;
     pub fn cpu_event_halt();
     pub fn apic_acknowledge_irq() -> i32;
 
@@ -3030,7 +3030,7 @@ pub unsafe fn main_loop() -> f64 {
 
     if *in_hlt {
         if *flags & FLAG_INTERRUPT != 0 {
-            let t = run_hardware_timers(start);
+            let t = run_hardware_timers(*acpi_enabled, start);
             handle_irqs();
             if *in_hlt {
                 profiler::stat_increment(MAIN_LOOP_IDLE);
@@ -3047,7 +3047,7 @@ pub unsafe fn main_loop() -> f64 {
         do_many_cycles_native();
 
         let now = microtick();
-        let t = run_hardware_timers(now);
+        let t = run_hardware_timers(*acpi_enabled, now);
         handle_irqs();
         if *in_hlt {
             return t;

+ 1 - 1
src/rust/cpu/instructions.rs

@@ -2192,7 +2192,7 @@ pub unsafe fn instr_F4() {
     // due it will immediately call call_interrupt_vector and continue
     // execution without an unnecessary cycle through do_run
     if *flags & FLAG_INTERRUPT != 0 {
-        run_hardware_timers(microtick());
+        run_hardware_timers(*acpi_enabled, microtick());
         handle_irqs();
     }
     else {