objectification (was: Jython vs Squeak for teaching multimedia)

Ian Piumarta ian.piumarta at inria.fr
Tue Jul 9 03:31:21 UTC 2002


On Mon, 8 Jul 2002, Jecel Assumpcao Jr wrote:
> On Friday 05 July 2002 13:27, Alan Kay wrote:
> > The important thing that CLOS (e.g.) did was to make the additions to
> > the models compilable so that metachanges could be as efficient as
> > the kernel. We kind of have this with SLANG, but the whole apparatus
> > could be much much cleaner.
> 
> A Jitter in Smalltalk would do the job.

I think two jitters would be simpler (and do a much better job: the right
tool at the right level of abstraction for the particular problem in
hand).

The first is just the regular Deutschian dynamic translation for Smalltalk
(with tagged pointers, message sends, GC, and all the other stuff that
makes the job tricky).  This one isn't very interesting in a MOP context.

The second is intended only for MOP methods.  It makes the same kinds of
assumptions about the bytecode as does the existing Slang translator.  In
fact, it's just a Slang CompiledMethod (rather than MethodNode) -> C
translator that goes one step further and generates binary off the
translated method.  No objects, no message sends, everything is an int and
the generated code is blindingly fast.  A runtime bytecode assembler.  
(Any half-serious application should be equipped with its own built-in
dynamic C compiler.  [And any half-serious OS will have one "on tap" for
all applications, or the kernel, to use.])

In such a restricted context, beating the performance of an optimising C
compiler isn't particularly difficult (aggressively optimising the Slang
bytecode at the rate of several thousand Slang methods per second on
modest hardware).

The mechanism is almost all in place already in Squeak (with the named
primitives).  All that's missing is the primitive lookup to notice that
the method starts with <slang> (instead of <primitive:module:>) and to
fire up the Slang compiler to generate the binary.  Drop the entry point
into the primitive table and off you go.  Beyond that we only need a
translator from Slang bytecode to binary, which is *way* simpler than a
"real" jitter.  A week, maybe two, tops.

(Didn't Johnson's mob at one time or other attempt something similar using
some kind of horrendous RTL for expressing primitive methods?  Claus does
it in Smalltalk/X too, except he sticks real C source in his primitive
methods and then spawns an external C compiler to build a .so. I suspect
that makes self-modifying MOPs rather unrealistic in Smalltalk/X, and
certainly less introspective given that their "source" format isn't
formally structured.)

Objectifying the Interpreter is a great idea (I've thought for a long time
that the Interpreter should really be generated out of the Context
simulation code) but should be coded as carefully as the current
Interpreter to ensure that the two universes (where in the MOP everything
is an int and objects don't exist) remain compatible.  If we had that then
redefining the meaning of message send (or whatever) should not lose a
single percentage point in performance compared to static (optimising)
compilation of translated code (and in fact may well gain performance
compared to overly-conservative C compilers).

Ian

PS: A language called Slang has existed for years, since long before
    Squeak came along.  Stealing the name was maybe not very polite.




More information about the Squeak-dev mailing list