Re: virtual machine efficiency

"John R. Strohm" <strohm@airmail.net>
1 Jan 2005 18:02:44 -0500

          From comp.compilers

Related articles
[4 earlier articles]
Re: virtual machine efficiency cr88192@hotmail.com (cr88192) (2004-12-30)
Re: virtual machine efficiency cfc@shell01.TheWorld.com (Chris F Clark) (2004-12-30)
Re: virtual machine efficiency lars@bearnip.com (2004-12-30)
Re: virtual machine efficiency calumg@no.onetel.spam.com (Calum Grant) (2004-12-30)
Re: virtual machine efficiency cr88192@hotmail.com (cr88192) (2004-12-31)
Re: virtual machine efficiency cr88192@hotmail.com (cr88192) (2004-12-31)
Re: virtual machine efficiency strohm@airmail.net (John R. Strohm) (2005-01-01)
Re: virtual machine efficiency kers@hpl.hp.com (Chris Dollin) (2005-01-12)
Re: virtual machine efficiency cr88192@hotmail.com (cr88192) (2005-01-14)
Re: virtual machine efficiency kers@hpl.hp.com (Chris Dollin) (2005-01-15)
Re: virtual machine efficiency hannah@schlund.de (2005-01-30)
| List of all articles for this month |
From: "John R. Strohm" <strohm@airmail.net>
Newsgroups: comp.compilers
Date: 1 Jan 2005 18:02:44 -0500
Organization: Compilers Central
References: 04-12-151
Keywords: VM, performance
Posted-Date: 01 Jan 2005 18:02:44 EST

"ed_davis2" <ed_davis2@yahoo.com> said:
> I have developed a simple stack based virtual machine. I would like
> it to be as efficient as possible, in terms of both speed and object
> code size. Size, as in size of the object code the VM processes
> (byte-code), and not necessarily the size of the VM.


This thread has been running for a while, and a key point seems not to
have arisen.


The efficiency of the interpreter IN PRACTICE will depend HEAVILY on
the actual instruction stream fed to it.


If almost every instruction is a LOAD or STORE that specifies an
absolute address, then efficiency of the byte-code engine will be
dominated by efficiency of the absolute load and store primitives.
However, if the application that is running on the system is, say, a
pixel-cruncher, or a radar signal processor doing massive FFTs, the
absolute load and store primitives are not going to contribute very
much at all to the efficiency of the engine, AND IT IS A WASTE OF
PROGRAMMER BRAIN CYCLES TO OPTIMIZE THE COLD SPOTS.


In general, it is impossible to optimize everything absolutely.


What I would suggest you consider is adding some "index registers" or
"address registers" to your interpreter, and add "load address and
load" and "load address and store" primitives. These instructions
would load the target absolute address into one of the address
registers, and then load or store the top-of-stack through the address
register. Maybe you'd want to provide for an offset, absolute, or
even indexed.


Then whatever generates code to run on the virtual machine can
optimize e.g. constant and temporary placement, to get leverage off
the address registers and the indexed indirect load/store operations.
[Unless you plan to use a JIT compiler to translate your VM code into
machine code, I'd think the higher level the operators, the better,
to minimize the number of ops to decode. -John]



Post a followup to this message

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