Node:VM disassembler, Next:VM profiler, Previous:Peephole optimization, Up:Using the generated code
A VM code disassembler is optional for an interpretive system, but highly recommended during its development and maintenance, because it is very useful for detecting bugs in the front end (and for distinguishing them from VM interpreter bugs).
Vmgen supports VM code disassembling by generating
file-disasm.i. This code has to be wrapped into a
function, as is done in
vmgen-ex/disasm.c. You can use this file
almost verbatim. In addition to
printarg_type(value), which are
explained above, the following macros and variables are used in
file-disasm.i (and you have to define them):
IPTOSis the first argument of the current VM instruction, and
IPpoints to it; this is just as in the engine, but here
ippoints to the opcode of the VM instruction (in contrast to the engine, where
ippoints to the next cell, or even one further).
VM_IS_INST(Inst i, int n)
iis the same as the
nth entry in the VM instruction table.