The Voodoo of Inlined Methods

Lex Spoon lex at cc.gatech.edu
Fri Jun 28 15:07:56 UTC 2002


> > My question:  What's right?
> > 
> > Squeak does not (yet) do type inference, so it *can't* make inlining
> > decisions based on the type of the receiver. 

By the way, this isn't strictly correct.  You can use dynamic type
information and still inline based on type; you simply must insert a
guard in front of the optimized code to check what the type is.  If 
the type is what you hope it is, then you run the inlined code, and otherwise
you run the normal code.  Also, you can do some limitted but effective
type inference after one of these checks succeeds, and assume that the
type stays correct up until the next assignment or so.  (I dunno the details).
This general technique is called customization, whether it relies on
dynamic information or static information.  The Self project used it
heavily, and I've got it in my head that they invented it at least for
OO languages, but I'm not certain.

Incidentally, even if you do static type inference, you are likely to
want to have the type check anyway.  For example, maybe only small integers
deserve having inlined code, and you'll leave large integers and other
types of numbers to use the default implementation.  Or maybe you just want
to weed out oddblal things like nil.


-Lex



More information about the Squeak-dev mailing list