Re: Dynamic Typing Efficiency

clearm@comcast.net
13 May 2005 16:49:43 -0400

          From comp.compilers

Related articles
[2 earlier articles]
Re: Dynamic Typing Efficiency luke@iogopro.co.uk (Luke McCarthy) (2005-05-08)
Re: Dynamic Typing Efficiency gah@ugcs.caltech.edu (glen herrmannsfeldt) (2005-05-08)
Re: Dynamic Typing Efficiency loic@fejoz.net (Yermat) (2005-05-09)
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: clearm@comcast.net
Newsgroups: comp.compilers
Date: 13 May 2005 16:49:43 -0400
Organization: http://groups.google.com
References: 05-05-04105-05-054
Keywords: types, interpreter, summary
Posted-Date: 13 May 2005 16:49:43 EDT

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:


        .
        .
        .
}




Jeff Kenton wrote:
> One other approach not yet mentioned is to do static analysis where
> possible, so that you can avoid runtime type checking when it's not
> necessary.
>
> clearm@comcast.net wrote:
> > Hello,
> >
> > I am writing a small, python-like scripting language that uses
dynamic
> > typing. I am also writing a stack-based virtual machine to go with
> > it.
> >
> > I have read many papers and posts about improving the efficiency of
> > VMs - for example by using threaded dispatch instead of switch
> > statements.
> >
> > The problem I have is that dynamic typing seems to be extremely
> > inefficient when you have a large number of types. For example, if
I
> > have integers, doubles, strings, booleans, and various compound
types,
> > then an ADD instruction would have to look like this:


Post a followup to this message

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