[FFI] Pointer arithmetic impossible on ByteArray?

Andreas Raab andreas.raab at gmx.de
Sat May 20 01:39:14 UTC 2006


nicolas cellier wrote:
> I just want to be able to pass an object (IndirectByteArray?) to a FFI call so 
> that i can play with memory offset inside ByteArray as i can already play in 
> external heap.

Well, good luck then. That's far from trivial.

>>> Is a plugin immune to that kind of moving GC ?
>> No, of course not. You can't keep references to objects across primitive
>> calls for example. Inside primitive calls it depends on what the
>> primitive does - various operations (like allocation) may cause GC and
>> an oop you referred to before the GC will be no longer valid after it
>> unless you explicitly remap it.
> 
> Well, I suppose one must care of order of operations when writing a plugin.
> Must be tricky sometimes...

Yes, it is. And people get it wrong quite a bit, which is why I have 
proposed to turn off GC alltogether in primitive calls to avoid these 
issues. That raises some other problems though, such as what to do when 
a plugin requests a large object and the VM can't accommodate the 
request without GC etc.

Cheers,
   - Andreas




More information about the Squeak-dev mailing list