Hi Guille,
On Feb 15, 2016, at 6:28 AM, Guille Polito <guillermopolito@gmail.com> wrote:
Well, the main drawback is that you'll not be able to trap any messages implemented by DNUProxy, because as they are implemented, they are understood.
Also, the idea of Ghost was not only to use cannot interpret, but to provide a library that allowed to proxy objects as well as methods and classes.
Finally, I'm curious about the performance difference... because the interpreter code handling DNU and cannot interpret is not much different... Maybe the JIT is not handling it (because nobody proposed it before)?
The JIT optimises MNU dispatch using PICs. The idea is that a PIC can also record that a given selector is not understood and hence avoid both the failing lookup for the send that is not understood (which is very slow because it scans all classes in the receivers hierarchy searching for a selector that isn't there) and the send of doesNotUnderstand:. In spur there's also a possibility of further optimising the creation of the message which could be done in machine code, rather than as now, with a slower call into the interpreter runtime.
Guille
On 02/15/2016 03:11 PM, Denis Kudriashov wrote: I compared doesNotUnderstand: vs cannotInterpret: versions of proxies.
DNUProxy>>doesNotUnderstand: aMessage lastMessage := aMessage. ^'from DNU proxy'
CannotInterpretProxy>>cannotInterpret: aMessage lastMessage := aMessage. ^'from cannot interpret proxy'
And DNU proxy works 2 times faster then #cannotInterpret proxy.
[proxy someMessage] benchFor: 2 seconds.
DNU: "a BenchmarkResult(22,377,669 iterations in 2 seconds. 11,188,835 per second)"
CannotInterpet: "a BenchmarkResult(13,148,735 iterations in 2 seconds 2 milliseconds. 6,567,800 per second)
Also DNU version is much more easy to explain.
So why Ghost uses #cannotInterpret for proxies? (after reading Ghost paper I can't understand this). Naked proxy can be easily done by setting superclass to nil:
ProtoObject subclass: #DNUProxy instanceVariableNames: '' classVariableNames: '' package: 'DNUProxy'. DNUProxy superclass: nil