On 12 April 2010 21:08, Andreas Raab <andreas.raab@gmx.de> wrote:
On 4/12/2010 10:57 AM, Igor Stasenko wrote:
On 12 April 2010 20:49, Andreas Raab<andreas.raab@gmx.de> Â wrote:
Today, you can give your plugin an array of your own special objects that is used by your plugin, registered with the VM as a GC root and there's no need to modify splObjs.
Looks like i missed something. HOW? Suppose a primitive needs to answer an instance of a special class, known by it. How it can instantiate it, if it having no any clues, where its invoked from, and it can't rely on a receiver, nor any of method's arguments?
You make it work just like splObjs, i.e.,
FooPlugin>>primitiveSetSplObjs     "Sets the special objects for my plugin"     splObjs := interpreterProxy stackObjectValue: 0.     "... should have sanity checks ..."     interpreterProxy addGCRoot: (self cCode: '&splObjs').
FooPlugin>>instantiateNewBar     "Instantiates a new Bar (at index 2 in the splObjs)"
    "... should have sanity checks ..."     foo := interpreterProxy instantiateClass: (interpreterProxy fetchPointer: 2 ofObject: splObjs) indexableSize: 0.     interpreterProxy pop: 1 thenPush: foo.
then you use it like here:
Foo class>>startUp: resuming     "Install my special objects on system startup"     resuming ifTrue:[         self primitiveSetSplObjs: {Foo. Bar. DukeNukem. 42}.     ].
Foo class>>newBar     ^self primitiveNewBar
The "trick" is that your plugin can register whatever it wants for GC tracing (in fact you should probably set the variable to nilObj and call addGCRoot from initialiseModule exactly once and release it via shutdownModule). This removes the need for abusing splObjs to stick in stuff that you'd like to preserve between prim calls.
Ah, that's cool.. Except that most recent SVN repository sqVirtualMachine.h (revision 1955) having no addGCroot: defined in InterpreterProxy struct. I am using wrong SVN repository? http://squeakvm.org/svn/squeak/trunk/ After some research i found another file in plugins/IA32ABI/, which includes new proxy functions, but its not used by builder.
Cheers, Â - Andreas
-- Best regards, Igor Stasenko AKA sig.