On Wed, Aug 17, 2005 at 00:59:52 +0100, Adrian Howard wrote:
> Sorry - I don't understand. If I do:
> 
>      call_to_external_c_library_foo( $foo );
>      call_to_external_c_library_bar( $bar );
> 
> Then how does the compiler know that $foo is only used temporarily  and can 
> be moved around, while $bar is cached in the 
> external library  and shouldn't be moved by any heap de-fragmentation that 
> the garbage  collector might do?


$foo points to the object structure, which also has a "static"
handle, that is allocated in a static arena (something that isn't
defragmented or copied by the GC).

this handle is simply a pointer that points back to the object
structure (and is updated as this object moves). The object has it's
address, and it has the object's address.

When an object is given to a foreign function, that function gets
the handle to the object (the address of the staticly located
pointer to the dynamically located object).

When the compiler is sure that an object is never ever given to an
external function, it can omit the code that keeps handles to the
objects.

This is just a small solution for a GC scheme that copies or
defragments - I personally doubt that this will be the case any time
in the forseeable future, but it's runtime and GC dependant, and
there are other solutions, this is just one.

-- 
 ()  Yuval Kogman <[EMAIL PROTECTED]> 0xEBD27418  perl hacker &
 /\  kung foo master: /me wields bonsai kittens: neeyah!!!!!!!!!!!!!!!!

Attachment: pgpx98dfxTWat.pgp
Description: PGP signature

Reply via email to