diff options
Diffstat (limited to 'mixlib')
-rw-r--r-- | mixlib/mix_vm.c | 16 | ||||
-rw-r--r-- | mixlib/mix_vm.h | 5 |
2 files changed, 20 insertions, 1 deletions
diff --git a/mixlib/mix_vm.c b/mixlib/mix_vm.c index 38ce5a9..c778615 100644 --- a/mixlib/mix_vm.c +++ b/mixlib/mix_vm.c @@ -74,7 +74,9 @@ mix_vm_new (void) for (i = 0; i < BD_NO_; ++i) vm->devices[i] = NULL; - + + vm->clock = mix_vm_clock_new (); + vm_reset_ (vm); return vm; } @@ -339,6 +341,8 @@ mix_vm_run (mix_vm_t *vm) mix_word_to_ins_uncheck (get_cell_ (vm, get_loc_ (vm)), ins); if ( !(*ins_handlers_[ins.opcode]) (vm,&ins) ) return MIX_VM_ERROR; + else + update_time_ (vm, &ins); if (bp_is_set_ (vm, get_loc_ (vm))) return MIX_VM_BREAK; if (get_loc_ (vm) >= MIX_VM_CELL_NO) halt_ (vm, TRUE); @@ -357,6 +361,8 @@ mix_vm_exec_next (mix_vm_t *vm) mix_word_to_ins_uncheck (get_cell_ (vm, get_loc_ (vm)), ins); if (!(*ins_handlers_[ins.opcode]) (vm, &ins)) return MIX_VM_ERROR; + else + update_time_ (vm, &ins); return bp_is_set_ (vm, get_loc_ (vm)) ? MIX_VM_BREAK : MIX_VM_OK; } @@ -471,3 +477,11 @@ mix_vm_clear_all_breakpoints (mix_vm_t *vm) bp_clear_all_ (vm); } +/* Get the vm uptime, defined as the time spent executing instructions */ +mix_time_t +mix_vm_get_uptime (const mix_vm_t *vm) +{ + g_return_val_if_fail (vm != NULL, 0); + return mix_vm_clock_get_time (get_clock_ (vm)); +} + diff --git a/mixlib/mix_vm.h b/mixlib/mix_vm.h index 62ba34d..91d1d28 100644 --- a/mixlib/mix_vm.h +++ b/mixlib/mix_vm.h @@ -28,6 +28,7 @@ #include "mix_code_file.h" #include "mix_src_file.h" #include "mix_symbol_table.h" +#include "mix_vm_clock.h" /* Comparison flag */ typedef enum { mix_LESS, mix_EQ, mix_GREAT } mix_cmpflag_t; @@ -178,6 +179,10 @@ mix_vm_clear_breakpoint_address (mix_vm_t *vm, guint address) ; extern void mix_vm_clear_all_breakpoints (mix_vm_t *vm); +/* Get the vm uptime, defined as the time spent executing instructions */ +extern mix_time_t +mix_vm_get_uptime (const mix_vm_t *vm); + #endif /* MIX_VM_H */ |