tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] TCC code generation for a stack based VM


From: Anton Ertl
Subject: Re: [Tinycc-devel] TCC code generation for a stack based VM
Date: Mon, 8 Nov 2004 20:36:51 +0100 (CET)

On the general topic, I have been looking for some programming
language with many standard benchmarks for which I could use Vmgen
(http://www.complang.tuwien.ac.at/anton/vmgen/).  My main interest is
to evaluate the new optimizations I am working on now and to have an
additional reference project.  Then I saw the bytecode interpreter
mentioned in tcc's TODO file, and then this discussion.

So maybe tcc would be the right platform for my plans, and maybe Vmgen
would be the right tool for further tcc portability.

Is there anybody interested in this?

Fabrice Bellard writes:
>
>I really think that a register based VM target would be simpler to add
>to TCC, and surely faster than a stack based VM.

That depends on a lot of things.  Generally, I think that, with stack
caching and static superinstructions (allready present in the
development version of Vmgen), you will have a hard time outperforming
a stack VM, but that surely would be an interesting point to
investigate (later).  If you feel that it's easier to generate code
for a register machine, it's probably best to do that first.

>- Each instruction is 16 bit wide, some are longer to integrate 16 or
>32 bit constants. 16 bit wide ops can be interesting to avoid one
>table indirection in the interpreter loop.

Unless you are very interested in small VM code (then why not use
8-bit instructions), I would suggest going with threaded code (one
machine word per VM instruction, plus parameters).  This has the
following advantages:

- faster.

- simpler: no dealing with unaligned 32-bit operands necessary (and,
on 64-bit machines, none for 64-bit operands).

- it is simple to extend threaded code to use dynamic
superinstructions (aka "Selective Inlining") for another factor-of-2
speedup.

>- Extend the ELF format for this virtual machine so that you can
>generate object and executables easily.

That's one of the things where I would appreciate help.

- anton




reply via email to

[Prev in Thread] Current Thread [Next in Thread]