Stack, register, message based or hybrid for virtual machine?

"Vis Mike" <visionary25@_nospam_hotmail.com>
11 Feb 2003 01:56:56 -0500

          From comp.compilers

Related articles
Stack, register, message based or hybrid for virtual machine? visionary25@_nospam_hotmail.com (Vis Mike) (2003-02-11)
Re: Stack, register, message based or hybrid for virtual machine? u.hobelmann@web.de (Ulrich Hobelmann) (2003-02-12)
Re: Stack, register, message based or hybrid for virtual machine? anton@mips.complang.tuwien.ac.at (2003-02-21)
| List of all articles for this month |

From: "Vis Mike" <visionary25@_nospam_hotmail.com>
Newsgroups: comp.compilers
Date: 11 Feb 2003 01:56:56 -0500
Organization: Compilers Central
Keywords: architecture
Posted-Date: 11 Feb 2003 01:56:56 EST

Hi all,


Just doing a little VM coding for fun, and trying for the fastest
solution. My stack version seems to be faster, about 25% faster than
my register code. I assume it is because of the register lookup
(pointer to pointer), whereas the stack version knows where to look.


I was thinking of some kind of hybrid. Anybody have any thoughts?
I'll post the complete code if interested, just wanted to brush on the
subject first.


Also, It's odd that the first version of ADD is faster than the second:


sp -= 2;
*sp = sp[0] + sp[1];
++pc; sp++;


sp[-2] = sp[-1] + sp[-2];
++pc; --sp;


I guess that just shows that you can't optimize unless you know what
the machine is actually doing.


Regards,
Mike


long codeStack[] = {
    pushi, 3,
    pushi, 2,
    addi,
    tne, iters, (long)&codeStk[2],
    ret
};


long codeRegister[] = {
    loadi, 2, r0,
    addi, r0, 2, r0,
    tne, t0, iters, (long)&codeReg[3],
    ret
};


Post a followup to this message

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