VM timers in a bit of a mess
tim at rowledge.org
Tue Jun 14 18:41:24 UTC 2005
For some reason I just had to take a look a some of the timer code and spotted
In sq.h the three timer functions (ioMSecs, ioLowResMSecs and iMicroMSecs) are
declared and then macros made to allow for a plain clock.h based version.
However, sometime back ioMicroMSecs() got added to the VM proxy structure in
sqVirtualMachine. I think this means you can't actually compile unless there is
a 'real' implementation of ioMicroMSecs() somewhere - could be wrong but that
appears to be the case.
At the very least the comment in sq.h is wrong about ioMicroMSecs only being
used in gc code and needs correcting. I imagine getting rid of the related
macro would be sensible too.
So far as I can see we all have concrete implementations of ioMicroMSecs()
sitting around, though they vary a bit
RISC OS returns the sqInt of the millisecond count
Mac returns int of some mangling of microsec values
unix returns sqInt of mangled gettimeofday() result
win32 returns int of a tick count & 0x3FFFFFFF (similar with ioMSecs)
In the (I think recently added) GC statistics, when we return the various
times an assumption is made about the time values being SmallInt values, which
isn't neccessarily true for all but win32. Note that ioMSecs() is always seen
in interp.c along with '&MillisecondClockMask' to make sure it is SmallInt safe.
We could either require ioMicroMSecs to be moduloed down or add the guard in
the Interpreter code. Likewise we could have ioMSecs do a modulo and remove the
code in Interpreter.
Thoughts on cleaning this up?
Tim Rowledge, tim at rowledge.org, http://www.rowledge.org/tim
Computing Dictionary: Recursive: (see Recursive)
More information about the Vm-dev