ABI safe library theory of operation

From Adobe Open Source Wiki
Revision as of 23:59, 27 August 2009 by SeanParent (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The idea with the ABI safe library (currently the version_1 namespace types) is to provide a set of types that have a defined binary representation regardless of compiler settings, version, or options. And so these types can be passed freely across a DLL boundary.

The template types are intended to be ABI safe so long as they are themselves instantiated with an ABI safe type.

The following are the specific techniques that the library uses:

1) Memory allocation - any heap allocated object will carry with it an xxx_alocator (look up the actual type name). This allocator holds a pointer to a new/delete pair of proc pointers. All allocations go through the allocator and all frees also go through the allocator. This ensures that a consistent new/delete pair is used if a DLL or application of locally replaced these operations.

2) Alignment - the types all try to ensure maximal alignment of types where necessary - this is usually done by aligning to the natural alignment for the type up to 64 bits (there may be issues with types that require 128 bit alignment). There is currently a known issue here with close_hash_map which relies on adobe::pair but makes no attempt to ensure alignment of the second element. So far this hasn't caused any real world problems and it should be fixed at some point by trying to ensure that the current "typical" alignment is kept.

3) No use of C++ compiler constructs, such as RTTI and v-tables which don't have a defined representation. Instead there is an adobe typeinfo system that relies on matching by name (rather than by a symbol that would need to be exported) and constructing v-tables with tables of proc-pointers (compiler generated as static structs - see any_regular_t).