[Vm-beginners] Please confirm/deny that MethodContext sender is nilled by the Interpreter.

gettimothy gettimothy at zoho.com
Fri Jan 10 13:31:13 UTC 2014


I while ago, while studying Eliot's factorial copy example I made the mistake of assuming that since the sender of the MethodContext was the UndefinedObject (which is the Nil object) that that was why the sender was nil.

Eliot corrected me, writing:



Assuming you're not joking, that's not what it means at all.  
The sender points to the sender context *until* it is returned from.  
We're inspecting a block, which got created in the Doit context for the expression [:n| ....].  
And that DoIt context is the home context of the [:n|...] block.  
The DoIt context returned its result (the [:n|...] block) to whatever the sender context was.  
But when the DoIt context returned that result the DoIt context's sender was nilled, to indicate that it had been returned from.  
So by the time the [:n|...] block was inspected its home context's sender was nil.

 




 I spent some time trying to figure out exactly where that happens and I believe I have followed it to "system space" where I would like to leave things for now. If I am in fact correct.

Following the code of Eliot's factorial copy example, The DoIt travels through user space, to the Compiler's 

Compiler >> evaluate: textOrStream in: aContext to: receiver notifying: aRequestor ifFail: failBlock logged: logFlag


and ends up at <primitive:188> in Object >>withArgs: argArray executeMethod: compiledMethod

{A whole bunch of stuff happens in System Space that I am do not know how to trace yet--but eventually, the return must happen....so..}


In the BlueBook on page 608, There is a section on Return Bytecodes where bytecode 123 does set the sender nil.




returnBytecode
   currentBytecode = 120
      ifTrue: [tself returnValue: receiver
                     to: self sender].
   currentBytecode = 121
      ifTrue: [tself returnValue: TruePointer
                     to: self sender].
   currentBytecode = 122
      ifTrue: [tself returnVatue: FalsePointer
                     to: self sender].
  currentBytecode = 123
      ifTrue: [tself returnValue: NilPointer
                     to: self sender].

 Which exists on Squeak's Interpreter and is mapped to instance method 

Interpreter >> returnNil.



and finally, Interpreter >> commonReturn 


that seems the most possible path to me.

Conversely, any possibility of the sender being nilled in User Space would have to call 
ContextPart>>privSender: aContext 


Browsing the senders of that method paired with no apparent semaphores in the Compiler method, leads me to conclude it happens in system space.

Does that sound like its in the ballpark? Details are not neccessary as my goal was to just account for every variable we see in a Context.

thx

tty

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-beginners/attachments/20140110/b67987ba/attachment.htm


More information about the VM-beginners mailing list