Thanks. I tried some of these (they seemed to work or failed when they should), but
(Point compiledMethodAt: #x) valueWithReceiver: 3@4 arguments: #()
crashes on my machine (Squeak 2.6, Win98), followed by fatal error when opening the debugger.
It's a Compiler bug. The method Point>>x has a primitive response that never fails ("quick push of instance field") and since the Compiler expects the runtime to respond to this without ever trying to execute bytecodes, it doesn't bother generating any bytecodes in the method at all. To fix this, in Compiler>>generate: modify the final return in the block argument to the first send to simply record the primitive index for the quick response:
self generateIfQuick: [:method | primitive _ method primitive].
then re-accept Point>>x and try the example again.
[Dan: here's an example of cheating and then getting caught. ;-)]
Ian
It's a Compiler bug. The method Point>>x has a primitive response that never fails ("quick push of instance field") and since the Compiler expects the runtime to respond to this without ever trying to execute bytecodes, it doesn't bother generating any bytecodes in the method at all. To fix this, in MethodNode>>generate: modify the final return in the block argument to the first send to simply record the primitive index for the quick response:
self generateIfQuick: [:method | primitive _ method primitive].
then re-accept Point>>x and try the example again.
[Dan: here's an example of cheating and then getting caught. ;-)]
Yikes. I should say so.
My guess is that this dates back to the old AppleST image. In any case, I'll fix it.
Thanks for the alert.
- Dan
This seems to do the job, Ian.
BTW. With this example (when executed in a #timesRepeat: loop), the #valueWithReceiver:... call is 15 times slower than the regular method call ((3@4) x) when executed without the tests, 60 times when including the tests.
michel
squeak-dev@lists.squeakfoundation.org