[squeak-dev] Re: Newbie Question (about OOPs, maybe) (sorry)

John M McIntosh johnmci at smalltalkconsulting.com
Sun Aug 23 18:28:44 UTC 2009


On 23-Aug-09, at 8:52 AM, David T. Lewis wrote:

> The OOP is a unique identifier for the object at a particular  
> instant in
> time, but the VM is free to change it at any time without telling you.
>
> Dave

David doesn't mention this but when you are building primitives there  
is a call that lets you
push the oops onto a stack. This special stack then is managed by the  
garbage collector so
when it moves the oops the oops on the stack are then noted and then  
the magic value (aka memory addresses) corrected.

Later you pop the values off and they might be different. In general  
it's

oopsMemoryAddress = "find oops"
push oops onto remember stack
newoops = "allocate oops of class type:"  "which might cause a GC move  
event"
oopsMemoryAddress = pop oops off remermber stack
^oopsMemoryAddress

The issue for people starting out writing primitives is forgetting to  
do this pattern.

If you don't do this it might work ok, because there is the  
possibility that allocating the newoops won't move things,
but on some call it will, then you die because oopsMemoryAddress is  
now pointing somewhere random in oops space.

Years back there was talk about preventing a GC during the newoops but  
we've never moved forward on that.

--
= 
= 
= 
========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com>   Twitter:   
squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
= 
= 
= 
========================================================================







More information about the Squeak-dev mailing list