0
$\begingroup$

Specifically, I have tried boiling down the operations of a VM into the smallest possible standardized units and arrived at this:

allocate_stack(size)
fetch(offset_from_stack_pointer)
store(offset_from_stack_pointer)
call(index)

So you might have:

allocate_stack 6
fetch -2
store 0
fetch -1
store 1
call 72

Basically, the allocate_stack would tell you how much space you are allocating for fields in the stack. Then the fetch would queue up something relative to the stack to be stored (or fetch_a would fetch an absolute address). Then store would store the fetched value in the space relative to the stack (or store_a for absolute position). And finally, call <index> would call that specific function.

So basically these are 2-address codes instead of 3-address codes. Does anything like this exist out there where they've expanded upon the idea to find compiler optimizations and such, like 3-address-code and SSA form? If not like this, does anything else exist outside of 3-address-code and SSA form?

$\endgroup$
1
$\begingroup$

This is an extremely common approach to designing abstract machines for non-imperative languages. See, for example, the G machine or the WAM (which uses the same technique for heap allocation).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.