Slashdot Mirror


Optimizing Stack Based Architectures?

An anonymous reader queries: "I'm currently writing a stack oriented interpreter (*ahem* Managed Code Environment) with complimentary compiler (that will be under MIT license), and was wondering if there have been any advances in stack architecture optimization? Some intense Googling turned up this paper, but it seems a bit dated, and focuses mainly on managing local variables, which is inapplicable to me because my interpreter directly supports local vars. Any thoughts or useful links on the topic would be appreciated."

2 of 31 comments (clear)

  1. searching papers: portal.acm.org by hubertf · · Score: 2, Insightful

    Try giving your query at http://portal.acm.org/, they return quite a bunch of articles, dunno how many of them are relevant. Download of article text may cost, though...

    - Hubert

  2. Re:It's not just about the VM by ltratt · · Score: 2, Insightful

    MOV's are typically very cheap, stack operations typically aren't. At the risk of generalizing, I'll assert that generally stack based VMs are built with a particular target language in mind, and that register machines aren't. With a register machine you're more likely to be playing by someone elses rules.

    IME if you develop and analyse your instruction set carefully, you can often reduce the amount of 'redundant' instructions necessary in a stack based solution. Let me give you a trivial example. In something I'm working on, I removed a couple of pages of instructions (huge amounts of DUP'ing and SWAP'ing amongst them) that were generated to analyse and assign a functions arguments in a dynamic language, and replaced them with a single instruction. Yes, I've bloated the instruction set by doing so. Yes, I increased performance an awful lot, and also made the compiler a *lot* easier to understand at the expense of a very small addition to the VM. Because of the frequency that particular op is called, and the saving involved, that sort of design choice is often where you can make the useful big savings.