[squeak-dev] [Bug & design issue] Messages understood or not understood by ProtoObject

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Fri Feb 14 17:51:33 UTC 2020


Hi Eliot,


> Or provide a vm flag which controls whether special selector #class (the bytecode for sending #class) is inlined or not.  This flag can also control #== & #~~.

Could you give me some (code) pointers about this inlining? :-)

> There is a good solution to this.  Low-level Inspectors *should not* use instVarAt: et al.  Instead they should access object intervals via “the mirror protocol”, see the methods in Context, #object:instVarAt:[put:] #object:at:[put:] #objectClass:

I like and do agree to your vision for tidying up ProtoObject!
Maybe we could also consider some "MetaDecorator" that inherits from ProtoObject and implements #class, #instVarAt: etc. for arbitrary targets? This might simplify the access to the mirror protocol, and it would be a bit more object-oriented:

(MetaDecorator on: aMorph) class "--> Morph"
(MetaDecorator on: aProxy) class "--> Proxy"
(MetaDecorator on: aProxy) instVarsInclude: 'target' "--> true"

> Hopefully I’ve answered your questions and given you pointers.  I’m interested in collaborating to make this a reality in the next major release.

You did. I'm too.

Best,
Christoph

________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Eliot Miranda <eliot.miranda at gmail.com>
Gesendet: Freitag, 14. Februar 2020 18:27:14
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] [Bug & design issue] Messages understood or not understood by ProtoObject

Hi Christoph,

On Feb 14, 2020, at 5:18 AM, Thiede, Christoph <Christoph.Thiede at student.hpi.uni-potsdam.de> wrote:



Hi all! :-)

When we were fiddling around with some proxy implementations today, Marcel and I discovered an interesting set of issues regarding ProtoObjects.

Let's start with a concrete bug:


Code to reproduce <do it>:

ProtoObject new class.


Expected behavior:

DNU exception, because #class is implemented on Object only.


Actual behavior:

Outputs ProtoObject.

Even stranger: If you debug the method instead and simulate the #class send, you get a "simulated message class not understood" error.

If you subclass ProtoObject and override/forward #class, the results will deviate based on whether you are debugging or executing the code.


Some thoughts:

There are two options: Either to implement #class on ProtoObject (by moving the primitive definition up from Object), or to remove it from the specialObjectsArray so that a send to #class is not compiled differently than a send to any other regular message.

Or provide a vm flag which controls whether special selector #class (the bytecode for sending #class) is inlined or not.  This flag can also control #== & #~~.


This leads us to the rather general question: What special messages should an instance of ProtoObject understand?

IMO *only* #doesNotUnderstand:

See below on the mirror protocol


We don't answer this question completely consistent at the moment: For example, #instVarAt: is implemented on Object, but #instVarsInclude: is implemented on ProtoObject. Again, it is a bit weird that the implementation of #instVarsInclude: calls #class which is implemented on Object only. And so it goes on:

  *   #someObject is implemented on Object, but #nextObject is available in ProtoObject.
  *   #withArgs:executeMethod: is implemented on ProtoObject, whereas #perform:withArguments: is on Object.
  *   #ifNotNil: is implemented on ProtoObject; however, #ifNotNilDo: is implemented on Object. (btw: does the latter still have any raison d'être?)
  *   #flag: exists on ProtoObject, and #yourself exists on Object only. Isn't #yourself rather a syntactical element we would like to behave exactly the same way for every possible message receiver? (btw: Is there a good reason not to speed up #yourself via specialObjectsArray)?
  *   (I don't claim for completeness)

And just some other problems regarding to ProtoObject (just collecting them here instead of forgetting them forever):

  *   ObjectTracer is broken due to several reasons. Will fix this soon.
  *   Inspectors cannot inspect ProtoObjects correctly (for example: Inspector openOn: (ObjectTracer on: Display)). This is because #instVarAt: is implemented on Object only so this message is forwarded.
Maybe we should replace these critical calls from Inspector by something like #tryPrimitive:173withArgs:? But should we do so in Inspector or rather in a new subclass named ProtoInspector or similar? Hm, then we would need to implement #inspectorClass on ProtoObject, which is bad either ... We will keep investigating this issue.

There is a good solution to this.  Low-level Inspectors *should not* use instVarAt: et al.  Instead they should access object intervals via “the mirror protocol”, see the methods in Context, #object:instVarAt:[put:] #object:at:[put:] #objectClass:

You see hacks everywhere (the xxxFoo messages in serialization) because we don’t have a well-defined notion of what is in a proxy.  Having one that is as minimal as possible is IMNERHO the clearest definition possible, and the most minimal is just having a #doesNotUnderstand: that prevents recursive does not understand vm exit and displays a stack trace without sending further messages to the proxy (because it uses the mirror primitives).

Note that the mirror primitives are what the execution machinery in Context use to ensure that bytecodes do what they are expected to do.  An I et car access should *not* send instVarAt: to a proxy; it should access the inst var of the proxy, etc.


However, the crucial question is: What special messages should an instance of ProtoObject understand? On the one hand, the idea of ProtoObjects is to work as total proxies with a maximum amount of forwarding potential, which implies a minimum number of methods. On the other hand, certain aspects such as accessing instvars or executing messages are really identity-related. Looking forward to your comments :-)

Hopefully I’ve answered your questions and given you pointers.  I’m interested in collaborating to make this a reality in the next major release.


Best,
Christoph

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200214/d7ac91e1/attachment.html>


More information about the Squeak-dev mailing list