Skip to content

Commit

Permalink
minor perf improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
copy committed Dec 15, 2023
1 parent 02d45c6 commit bfb59f9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/browser/starter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/cpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/rust/cpu/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/rust/cpu/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit bfb59f9

Please sign in to comment.