Plugin & strings

Andrew C. Greenberg werdna at gate.net
Thu Dec 9 05:21:29 UTC 1999


>On Wed, Dec 08, 1999 at 09:54:13PM -0500, Andrew C. Greenberg wrote:
> > The code works because the only value taken from C was converted to
> > an integer value and stored.  There are no pointers to the Smalltalk
> > object space.
>
>Certainly not.
>
> >
> > You should presume that any call to "instantiateClass:indexableSize"
> > will trigger a garbageCollection, invalidating any pointers (oops or
> > pointers inside oops) and requiring you to reload or use the
> > remappable object stack.
> >
>
>Help me out on this; I want to make sure I haven't gotten myself
>confused. My assumptions are:
>
>1) Garbage collections are scheduled within Smalltalk and are not
>initiated during the execution of any individual primitive. Object
>addresses do not move around during the execution of a primitive.

Bad assumption.  The call to #instantiate..., even from a primitive 
will trigger garbage collection.

>2) Outside of a primitive, or between calls to a primitive, objects get
>moved around freely by the garbage collector unless they are registered
>as external objects with SystemDictionary>>registerExternalObject:

Also inside a primitive.  I don't believe that registration precludes 
movement of the object, but can't speak to it one way or the other 
without reading the sources again.

>3) A primitive can't maintain a static reference to a Smalltalk object
>unless the object is registered as external, otherwise horrible things
>happen randomly.

It would be an extraordinarily silly thing to do.


>4) If you try to allocate an object within a primitive and the allocation
>fails, the garbage collector cannot help you out, and your primitive
>needs to fail in some graceful manner.

I am under the impression that garbage collection works just fine 
inside a primitive.  If it didn't, the rePlugin stuff would never 
survive a stress test.

What wouldn't work would be subsequent references to objects after 
the instantiation, to wit:

	x := "oop of stack at 1"
	y := "integer value of stack at 0"
	z := "instantiation of a string of size y"
	"reference to x of any kind."

You can always reload y from the stack, or use popRemappableOop and 
pushRemappableOop, which can be more convenient in some cases.





More information about the Squeak-dev mailing list