[squeak-dev] Re: push object onto stack
Bert Freudenberg
bert at freudenbergs.de
Tue Apr 20 10:27:56 UTC 2010
On 20.04.2010, at 11:45, Ang BeePeng wrote:
>
>
> Hi,
>
> I found that my object might have been moved by garbage collector. That's
> why pushing oop gives a wrong object. What can I do to stop GC from touching
> my object?
You can't.
That's what pushRemappableOop: is for. Before invoking any function that can cause a GC you need to push the oops you are holding onto. After the function returns, pop them.
Just browse senders of #pushRemappableOop: to see lots of examples. Here is one:
"remap methodContext in case GC happens during allocation"
self pushRemappableOop: methodContext.
newContext := self instantiateContext: (self splObj: ClassBlockContext) sizeInBytes: contextSize.
methodContext := self popRemappableOop.
- Bert -
More information about the Squeak-dev
mailing list
|