Oops, I sent this accidentally only to Bryce...
-------- Original Message -------- Subject: Re: Keeping oops across primitives Date: Thu, 08 Jun 2006 10:50:54 -0700 From: Andreas Raab andreas.raab@gmx.de To: Bryce Kampjes bryce@kampjes.demon.co.uk References: 4484D055.8020603@gmx.de 17543.20996.659703.227330@localhost.localdomain
Hi Bryce -
Question: Does anyone see a serious problem with the above proposal? I'm about to implement this right away so if you see an issue with it, please let me know.
Your solution sounds fine. I'd prefer to be able to register variables as roots rather than having to place things in arrays for my use. But then I'm just tracking entry points rather than individual objects (a dictionary that maps classes and selectors to natively compiled methods and an array of objects so natively compiled code can access objects).
Actually, this is an interesting thought. I have the need for managing a dynamic array of roots but this could be handled just as easily by tracking a variable pointing to a Squeak array.
So, does anyone feel strongly about going either way?
Cheers, - Andreas
Andreas Raab wrote:
Actually, this is an interesting thought. I have the need for managing a dynamic array of roots but this could be handled just as easily by tracking a variable pointing to a Squeak array.
A variable in C is more-or-less a one-place array, so perhaps supporting arrays is the simpler option?
{ sqInt myRoot = ...; vm->addToVmRoots(&myRoot, 1, NULL); ... vm->addToVmRoots(NULL, 0, &myRoot); }
#define WITH_ROOT(vm, var, blk) \ { (vm)->addToVmRoots(&(var), 1, NULL); \ blk; \ (vm)->addToVmRoots(NULL, 0, &(var)); }
{ sqInt myRoot2 = ...; WITH_ROOT(vm, myRoot2, { ... }); }
Tony Garnock-Jones wrote:
Andreas Raab wrote:
Actually, this is an interesting thought. I have the need for managing a dynamic array of roots but this could be handled just as easily by tracking a variable pointing to a Squeak array.
A variable in C is more-or-less a one-place array, so perhaps supporting arrays is the simpler option?
Turns out not. The code is much simpler supporting just individual oop locations (variables) so I decided to go with the following interface:
sqInt oopVar; /* declare a global that we wish to track */
{ ... oopVar = vm->nilObject(); /* don't forget to initialize it !!! */ vm->addGCRoot(&oopVar); /* update it */ ... }
and to undo that
{ ... vm->removeGCRoot(&oopVar); ... }
Cheers, - Andreas
vm-dev@lists.squeakfoundation.org