[DGD] some questions about interpret.cpp

Felix A. Croes felix at dworkin.nl
Mon Dec 28 20:08:00 CET 2015


Carter Cheng <cartercheng at gmail.com> wrote:

> Also concerning kfuns why would they want to modify the program counter?
> Shouldn't the kfun return to the subsequent instruction after the kfun call
> in most cases?

A kfun can modify the program counter when it executes the store value
instructions that follow the kfun call.  This is how things work for
the VM version 2.1; there is no more lvalue type, which means that
there is no more where-to-store-what information on the value stack.
Instead, a call to sscanf() is followed by store instructions, which
are then executed through i_lvalues() in a special modus, allowing
the kfun to save to variables from an array of values that is put
on the stack.

Storing values without going through an lvalue type is a big speed boost
for LPC.  VM code is about 30% faster (measured for Hydra, DGD may be a
little less optimized).  For JIT code, the impact will be even larger;
it does however mean that for sscanf calls from JIT-compiled code, you
have to pass a function pointer to i_lvalue(), which will then be called
to perform the stores.

Regards,
Felix Croes



More information about the DGD mailing list