Re: Dynamic Typing Efficiency

"Aaron Gray" <angray@beeb.net>
16 May 2005 11:20:45 -0400

          From comp.compilers

Related articles
[5 earlier articles]
Re: Dynamic Typing Efficiency mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2005-05-09)
Re: Dynamic Typing Efficiency eliotm@pacbell.net (Eliot Miranda) (2005-05-09)
Re: Dynamic Typing Efficiency jeffrey.kenton@comcast.net (Jeff Kenton) (2005-05-09)
Re: Dynamic Typing Efficiency clearm@comcast.net (2005-05-13)
Re: Dynamic Typing Efficiency alexc@TheWorld.com (Alex Colvin) (2005-05-13)
Re: Dynamic Typing Efficiency calumg@onetel.com (Calum Grant) (2005-05-13)
Re: Dynamic Typing Efficiency angray@beeb.net (Aaron Gray) (2005-05-16)
Re: Dynamic Typing Efficiency DrDiettrich@compuserve.de (Hans-Peter Diettrich) (2005-05-18)
Re: Dynamic Typing Efficiency jeffrey.kenton@comcast.net (Jeff Kenton) (2005-05-22)
| List of all articles for this month |

From: "Aaron Gray" <angray@beeb.net>
Newsgroups: comp.compilers
Date: 16 May 2005 11:20:45 -0400
Organization: Compilers Central
References: 05-05-04105-05-054 05-05-056
Keywords: interpreter, types

> Thanks everyone. I am going to try to implement a static analysis
> algorithm along with static versions of all of my opcodes so that they
> can be used when possible.
>
> For now I am using an nxn matrix lookup table. Like so:
>
> enum { INT, BOOL, REAL, STRING }
> enum { II, IB, IR, IS, BI, BB, BR, BS, RI, RB, RR, ... }
>
> char typelook[][] =
>
> INT BOOL REAL STRING
> INT II IB IR IS
> BOOL BI BB BR BS
> REAL RI RB RR RS
> STRING SI SR SR SS
>
> This way the comparison is simpler.
>
> switch (typelook[type1][type2])
> {
> case II:
>
> case IB:
>
> case IR:
>
> .
> .
> .
> }


That's probably the right approach. switch and case probably wins out
over arrays of pointers to functions for modern cpu and
caches. Although if you look at the assembly code you will probably
find a chained list of comparisons and jumps ! So I would put your
most common cases first !


It would be good to see some analysis of switch and case verses array
of pointers to functions on GCC and MS VC++. Maybe I will have a hack
at it at some point in the future.


Most if not all VM's that I have looked at use switch and case.


Aaron


Post a followup to this message

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