On Wed, May 23, 2012 at 12:04 PM, Andreas Raab <andreas.raab@gmx.de> wrote:
On 5/23/2012 20:51, Eliot Miranda wrote:
So given that the Interpreter VM now supports the mirror primitives,
does anyone object if I add the debugger changes to trunk that use the
mirror primitives and hence make accurate debugging of proxies possible?
The downside of doing this is that the debugger will be broken on
older VMs.

It should be possible to write the mirror prims relatively safely, e.g.:

object: anObject instVarAt: anIndex
       "Primitive. Answer a fixed variable in an object. The numbering of the
       variables corresponds to the named instance variables. Fail if the index
       is not an Integer or is not the index of a fixed variable. Essential for the
       debugger. See  Object documentation whatIsAPrimitive."

       <primitive: 73>
       anIndex <= (self objectClass: anObject) instSize
               ifTrue:["Assume mirror primitives are missing"
                       ^anObject instVarAt: index]
               ifFalse:["Access beyond fixed variables."
                       ^self object: anObject basicAt: anIndex - (self objectClass: anObject) instSize].

That's a good idea.  Alas it doesn't work because the primitives won't fail on the older VMs.  Note that the same primitive is used for instVarAt: and object:instVarAt: (and likewise for object:instVarAt:put: & objectClass: etc).  The difference is that in the older VM the prims assume a fixed argument count and only pop that many objects from the stack.  Hence there is the potential of stack overflow in the older VMs.  In any case things are likely to limp along rather than fail catastrophically.  I'm not sure that that's a good thing or not ;)

 - Andreas