Make dart:ffi Pointer an extension type over int #60722
Labels
area-vm
Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
library-ffi
Currently
Pointer
fromdart:ffi
is a heap object. It takes 3 words of memory (object header, address value and type arguments). Accessing pointer involves an extra indirection - we need to read an address value from thePointer
object before address value can be used to access pointed memory or do address arithmetic.If large number of
Pointer
objects are used to point to small structs, the overhead ofPointer
can be comparable to the amount of useful memory being addressed, which makesPointer
pretty much useless for building off-heap data structures.With extension types, it is possible to make
Pointer
a zero-cost abstraction over address value (represented asint
) and avoid these overheads: we would not need a heap object at all (unlessint
is boxed),Pointer
would take only 1 word on 64-bit systems and it would not need an extra indirection when accessing address./cc @dcharkes @mraleph
The text was updated successfully, but these errors were encountered: