How to dump MoarVM bytecode

205 views Asked by At

I wonder how I can debug the Moarvm bytecode. Is there a document that describes for instance howto convert raku to moarvm and howto dump the generated bytecode. If i try to i.e. run:

rakudo-m --target=mbc c.p6 
===SORRY!===
Cannot dump this object; no dump method

Somewhere I read about a "--dump" switch but that doesnt seem avaiable. I custom compile rakudo/nqp/moarvm from github.

1

There are 1 answers

0
timotimo On BEST ANSWER

The target argument to the rakudo compiler requires an --output=filename for some of the values. parse, ast, and optimize will all happily output to a console, though.

The moar binary is what has the --dump flag, but I would perhaps suggest using the debug output from the spesh subsystem of moarvm, which is the dynamic bytecode specializer and jit.

You can get at it by setting the environment variable MVM_SPESH_LOG to a filename. If the code in question doesn't run often enough to appear in the spesh log, you can set MVM_SPESH_NODELAY so moar will consider routines "hot" much earlier. There will be less information for the optimizer to work with, but if you're after seeing the compilation result only, it should be just fine.