Re: Optimizing stack access for a stack based VM

Hans-Peter Diettrich <DrDiettrich1@aol.com>
Thu, 13 Sep 2007 08:30:18 +0200

          From comp.compilers

Related articles
Optimizing stack access for a stack based VM jirik.svoboda@seznam.cz (Jiri Svoboda) (2007-09-11)
Re: Optimizing stack access for a stack based VM DrDiettrich1@aol.com (Hans-Peter Diettrich) (2007-09-13)
Re: Optimizing stack access for a stack based VM blog@rivadpm.com (Alex McDonald) (2007-09-13)
Re: Optimizing stack access for a stack based VM lkrupp@pssw.com (Louis Krupp) (2007-09-13)
Re: Optimizing stack access for a stack based VM DrDiettrich1@aol.com (Hans-Peter Diettrich) (2007-09-13)
Re: Optimizing stack access for a stack based VM DrDiettrich1@aol.com (Hans-Peter Diettrich) (2007-09-13)
Re: Optimizing stack access for a stack based VM jvorbrueggen@not-mediasec.de (=?ISO-8859-1?Q?Jan_Vorbr=FCggen?=) (2007-09-14)
Re: Optimizing stack access for a stack based VM blog@rivadpm.com (Alex McDonald) (2007-09-14)
[4 later articles]
| List of all articles for this month |

From: Hans-Peter Diettrich <DrDiettrich1@aol.com>
Newsgroups: comp.compilers
Date: Thu, 13 Sep 2007 08:30:18 +0200
Organization: Compilers Central
References: 07-09-030
Keywords: storage, optimize
Posted-Date: 13 Sep 2007 13:29:13 EDT

Jiri Svoboda wrote:


> Local variables should occur as natural operands of instructions (on
> the stack top) as much as possible, removing the need to fetch them
> from the middle of the stack (and encode displacement values).


IMO it doesn't matter whether you encode local variables as offsets
from the SP, or from another base pointer.




> Obviously anytime we want to execute an arithmetic operation it would be
> beneficial to have its operands on the stack top removing the need for
> stkld/stkst (and coding <offs>).
>
> While we get this for free for temporaries (= temporary results in
> arithmetic expressions) just by producing stack-based code from the
> source code, I'd like to extend it to work for variables, too.


Since access to local variables requires some selector (offset...)
value, you'll have to duplicate all operations, for using a local
variable as the second operand. Perhaps further sets are required, for
locals as first or both operands, and operations with non-local
variables would require further instructions. I'd stay with an RISC
instruction set, and only push/pop variables by dedicated
instructions.


Did you have a look at the i80x87 FPU instruction set? Or at the Java
VM, or at FORTH?


DoDi


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.