[Fwd: Re: Keeping oops across primitives]

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Fwd: Re: Keeping oops across primitives]

Andreas.Raab
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 <[hidden email]>
To: Bryce Kampjes <[hidden email]>
References: <[hidden email]>
<[hidden email]>

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


Reply | Threaded
Open this post in threaded view
|

Re: [Fwd: Re: Keeping oops across primitives]

Tony Garnock-Jones-2
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, {
    ...
  });
}


Reply | Threaded
Open this post in threaded view
|

Re: [Fwd: Re: Keeping oops across primitives]

Andreas.Raab
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