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.
As an example of the changes here are the old and new methods form pushing an inst var in the debugger/execution simulator. The first one sends a message to the receiver, and hence if it is a proxy will invoke the proxy's doesNotUnderstand: handling rather than answering the relevant inst var. The second one directly accesses the relevant inst var, accurately simulating what the VM does for the bytecode. The changes replace direct sends with use of mirror primitives throughout execution simulation in all the places where the VM would do a direct access rather than send a message. ContextPart methods for instruction decoding pushReceiverVariable: offset "Simulate the action of bytecode that pushes the contents of the receiver's
instance variable whose index is the argument, index, on the top of the stack." self push: (self receiver instVarAt: offset + 1)
ContextPart methods for instruction decoding pushReceiverVariable: offset "Simulate the action of bytecode that pushes the contents of the receiver's
instance variable whose index is the argument, index, on the top of the stack." self push: (self object: self receiver instVarAt: offset + 1)
and here's the mirror method. c.f. Object>instVarAt:. They share the same primitive number because internally the VM implements varargs primitives. ContextPart methods for mirror primitives
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> "Access beyond fixed variables."
^self object: anObject basicAt: anIndex - (self objectClass: anObject) instSize On Tue, May 22, 2012 at 8:17 PM, David T. Lewis <[hidden email]> wrote:
best, Eliot |
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]. Cheers, - Andreas |
On Wed, May 23, 2012 at 12:04 PM, Andreas Raab <[hidden email]> wrote: On 5/23/2012 20:51, Eliot Miranda wrote: 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 ;)
best, Eliot |
In reply to this post by Eliot Miranda-2
> The downside of doing this is that the debugger will be broken on
> older VMs. Which ones ? Stef |
On Wed, May 23, 2012 at 09:46:51PM +0200, St?phane Rollandin wrote:
> > The downside of doing this is that the debugger will be broken on > >older VMs. > > Which ones ? > None of the officially released interpreter VMs contain mirror primitive support. Mirror primitive support is present in the source code (VMMaker) for the interpreter VM and has been tested to the extent that it passes the unit tests. Presumably this means that the debugger changes will work with a newly build interpreter VM, although I cannot confirm this. If the image support can be added in the manner suggested by Andreas, that would be great. Otherwise, maybe not so good. Dave |
In reply to this post by Eliot Miranda-2
On Wed, May 23, 2012 at 12:30:48PM -0700, Eliot Miranda wrote:
> On Wed, May 23, 2012 at 12:04 PM, Andreas Raab <[hidden email]> 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 ;) What's the actual failure mode? If you run an image with the updated mirroring debugger on a Squeak-4.4.7.2357 VM from http://squeakvm.org/unix/ what actually happens? Does the debugger work at all? Does the image get messed up from calling primitives with the wrong number of arguments? Does the VM crash after a while? Dave |
In reply to this post by Eliot Miranda-2
On Wed, May 23, 2012 at 12:30:48PM -0700, Eliot Miranda wrote:
> On Wed, May 23, 2012 at 12:04 PM, Andreas Raab <[hidden email]> 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 ;) Would it be possible to perform one test at image startup time to determine if mirror primitive support is present, and handle things accordingly from then on? Dave |
On Wed, May 23, 2012 at 2:13 PM, David T. Lewis <[hidden email]> wrote:
Of course but it'll be clumsy. It'll necessitate a layer of wrapper methods, and for what purpose? Better IMO to upgrade the VMs asap.
best, Eliot |
In reply to this post by Eliot Miranda-2
On 5/23/2012 21:30, Eliot Miranda wrote:
> > > On Wed, May 23, 2012 at 12:04 PM, Andreas Raab <[hidden email] > <mailto:[hidden email]>> 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. Okay, then don't use those prims. Simply rename primitiveInstVarAt to primitiveMirrorInstVarAt, export the latter by name, and use the named version in cases like the above where the direct usage of prim 73 might cause a stack overflow. Tada! You can have your cake and eat it, too :-) Cheers, - Andreas |
Free forum by Nabble | Edit this page |