How to dump MoarVM bytecode
Asked Answered
S

1

8

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.

Steroid answered 24/7, 2020 at 21:51 Comment(0)
T
2

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.

Thistle answered 27/7, 2020 at 21:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.