Struct TVMFFIObject#

Struct Documentation#

struct TVMFFIObject#

C-based type of all FFI object header that allocates on heap.

Public Members

uint64_t combined_ref_count#

Combined strong and weak reference counter of the object.

Strong ref counter is packed into the lower 32 bits. Weak ref counter is packed into the upper 32 bits.

It is equivalent to { uint32_t strong_ref_count, uint32_t weak_ref_count } in little-endian structure:

  • strong_ref_count: combined_ref_count & 0xFFFFFFFF

  • weak_ref_count: (combined_ref_count >> 32) & 0xFFFFFFFF

Rationale: atomic ops on strong ref counter remains the same as +1/-1, this combined ref counter allows us to use u64 atomic once instead of a separate atomic read of weak counter during deletion.

The ref counter goes first to align ABI with most intrusive ptr designs. It is also likely more efficient as rc operations can be quite common.

int32_t type_index#

type index of the object.

Note

The type index of Object and Any are shared in FFI.

uint32_t __padding#

Extra padding to ensure 8 bytes alignment.

void (*deleter)(void *self, int flags)#

Deleter to be invoked when strong reference counter goes to zero.

See also

TVMFFIObjectDeleterFlagBitMask

Param self:

The self object handle.

Param flags:

The flags to indicate deletion behavior.

int64_t __ensure_align#

auxilary field to TVMFFIObject is always 8 bytes aligned.

Note

This helps us to ensure cross platform compatibility.