Related articles |
---|
Virtual Machine Implementation? lars@bearnip.com (Lars Duening) (2000-09-13) |
Re: Virtual Machine Implementation? parz@home.com (Parzival) (2000-09-15) |
Re: Virtual Machine Implementation? timgleason@my-deja.com (2000-09-15) |
From: | "Parzival" <parz@home.com> |
Newsgroups: | comp.compilers |
Date: | 15 Sep 2000 01:38:59 -0400 |
Organization: | Excite@Home - The Leader in Broadband |
References: | 00-09-098 |
Keywords: | interpreter, architecture |
I did something like this for a Basic dialect interpreter. The speed
on our application set doubled, and code size was reduced 40%. Our VM
became a hybrid stack/accumulator machine. The opcodes remained at=20
8 bits, and the remaining 24 bits became an immediate operand or
stack frame address. Separate opcodes allowed memory access to
global or local storage. Operands longer than 24 bits were encoded
in 2 word instructions, using separate opcodes. So, the simple
stack machine code for x =3D 3.0*y + 2.0 was
LIT 3.0 (push literal)
LOAD y (push value at local address of y)
MUL
LIT 2.0
ADD
STORE x (store result at x, and pop)
which became
LIT 3.0 (push literal)
MUL y (multiply stack top by value of local y)
ADD 2.0 (add 2 to stack top)
STORE x (store result at x, and pop)
To take full advantage of this kind of VM, the compiler has to arrange
commutative operations so that memory references and literal operands
appear as operands. In adapting a single pass pure stack machine compiler,
this may be difficult. In our compiler, we re-wrote the generated stack
machine code, i.e. peep-hole optimization.
Parzival
Lars Duening <lars@bearnip.com> wrote in message
> I am now contemplating improving the virtual machine (and giving me
> opportunity to rework the compiler and especially the code optimizer)
Return to the
comp.compilers page.
Search the
comp.compilers archives again.