vm: fep out if monotonic counter decreases

db4
Slava Pestov 2009-12-14 01:09:04 -06:00
parent 62e7aed2d3
commit 0a3c5f5ac6
3 changed files with 10 additions and 2 deletions

View File

@ -15,7 +15,10 @@ void factor_vm::primitive_system_micros()
void factor_vm::primitive_nano_count()
{
box_unsigned_8(nano_count());
u64 nanos = nano_count();
if(nanos < last_nano_count) critical_error("Monotonic counter decreased",0);
last_nano_count = nanos;
box_unsigned_8(nanos);
}
void factor_vm::primitive_sleep()

View File

@ -10,7 +10,8 @@ factor_vm::factor_vm() :
current_gc(NULL),
gc_events(NULL),
fep_disabled(false),
full_output(false)
full_output(false),
last_nano_count(0)
{
primitive_reset_dispatch_stats();
}

View File

@ -87,6 +87,10 @@ struct factor_vm
/* Incrementing object counter for identity hashing */
cell object_counter;
/* Sanity check to ensure that monotonic counter doesn't
decrease */
u64 last_nano_count;
// contexts
void reset_datastack();
void reset_retainstack();