Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to dump MoarVM bytecode

Tags:

raku

moarvm

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.

like image 282
Konrad Eisele Avatar asked Jul 24 '20 21:07

Konrad Eisele


1 Answers

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.

like image 172
timotimo Avatar answered Oct 28 '22 18:10

timotimo