petdance/scratch — Issue #243: variadic opcodes make assembly/disassembly difficult
Author: petdance
Created: 2011-11-14 06:07:23+00:00
State: open
Labels: core, Pri-normal, rfc, Sev-medium

opcodes that take a variadic number of arguments are difficult to work with. Some examples of these (maybe the only examples of them) are set_args, get_params, set_returns, and get_results. These ops take lists of values to pass/receive in a call. The first arg to the op is a string or an FIA that contains information about the number of ops that follow.
At the very least, these ops should be flagged to identify them as being special. This way a PIR-based disassembler can identify them and produce a better listing.

Far better idea, in my mind, would be refactoring these ops entirely so that they no longer take variadic lists of arguments. Instead, I suggest we could have IMCC build CallContext PMCs (or a new kind of proto-CallSignature PMC instead, depending on preprocessing requirements) at compile time and store them in the constants table. So set_args_p would change from taking an FIA with a series of flags and then a variadic argument list to taking a single "CallArguments" PMC which would contain all the same information, but in a form that was much easier to work with. Since information about the arguments to a function call are already stored as constants in the bytecode stream directly, we can easily convert this to a PMC constant with no loss of dynamicism. If anything we gain more dynamicism because we gain the ability to construct argument lists at runtime without having to explicitly use :flat.

These kinds of refactors would dovetail nicely with other PCC refactors currently planned.

Ideas?

Originally http://trac.parrot.org/parrot/ticket/1468