Animorphic ST (Strongtalk) released!

Tim Rowledge tim at sumeru.stanford.edu
Thu Jul 18 19:39:52 UTC 2002


Stephen Pair <spair at advantive.com> is claimed by the authorities to have written:

> Being curios about how this stuff works, and not knowing anything about
> how JIT VMs work, I have a couple of questions.
> 
> First, are you you talking about adding JIT to Squeak?  Or something
> more?  What does Jitter do?  How does it relate to this discussion?
A JIT in the usual sense is a Just In Time translator ie when yo u'call'
a piece of code you see if it is in 'pesudocode' form or 'realcode'
form. If the former, you branch off for a moment to translate the
pseudocode and install it so that next time the same method is called
you go straight to the'realcode'.

What I was suggesting is more of a Some Time Soon If You're Lucky
translator.
> 
> When you say compile a method, I take that to mean take a normal
> Smalltalk bytecoded method and compile it into native machine code.
Yup.
> What does the compiled method look like?  Is it just a sequencing of the
> machine code that the interpreter would normally run as it processes
> each bytecode?  It must be more than that right?
Yup, you can take the opportunity to do all sorts of optimisations
depending on how clever you feel like being. Certainly one would want to
convert from stack oriented to register oriented working (not horribly
difficult if you have a decently full semantic model in your pseudocode)
to match the idiom of your cpu. Many peephole optimisations can be
considered. Calling of prims can be streamlined (indeed visual works
actually pre-translates some 'sorta-prims' from hand writen pseduocode,
so they can be nearly inlined), checks not entirely unlike the
checkForInterupts can be inserted where appropriate.. .all sorts of
stuff.

> Also, once a method is compiled to machine code, why would there be any
> need to keep the bytecodes around (as Tim descibes)?  Can't you just
> throw away the old bytecodes at that point?  Ah...but perhaps it's so
> that the image can remain portable to different architectures...is that
> it?
Partly, but assuming you have a realistic sized cache to keep your
translated code in, you probably want to be able to flush it and have
the pseudocode around to retranslate at some point. You could reasonably
imagine having an out-of-image store of this stuff though. Even
recompiling from sources wouldn't be utterly stupid. Hell, given the
quality of code one sometimes finds, a random number generator and
genetic algorithm might not go amiss :-)

tim
-- 
Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
Pseudocode: like a real cold bud nod quide as badd.




More information about the Squeak-dev mailing list