[Fun][Weird][VM] Objects as compiled methods

Andreas Raab andreas.raab at gmx.de
Sat May 17 19:33:06 UTC 2003


> *Very* cool.  What are the performance implications?

For the 'regular' sends, zero. There is one (very cheap) test during the
full (non-cached) message lookup which determines if the thing is a compiled
method[*]. If it isn't, a 'special primitive' index is assigned (which later
on does the actual re-invokation).  The test itself takes advantage of
CompiledMethod's special object format so the cost is very close to zero
here - if you take the mcache hit rate into account it's exactly zero (as
in: not measurable).

For the 'object invokation' itself the cost is in the range of a #perform:
(as it does almost the same thing). However, due to my dirty little
'primitive trick' the 'function object' can stay in the mcache which means
that in practice the performance should be pretty close to a 'regular' send.

[*] One might even argue that the test should be there to begin with since
without it the VM will crash if you ever store anything but CMs in the
method dictionaries.

Cheers,
  - Andreas

PS. It just so occured to me that going this way one might have a completely
different interpreter/bytecode set running next to the current one. Even
methods compiled completely to native code. Sort of like a trap. Hm...



More information about the Squeak-dev mailing list