waffle

Module pool

Source
Expand description

Pooled list data structure.

The IR for a function contains many small lists: the lists of arguments and result values for each operator, and the list of result types for each operator as well. It would be fairly inefficient to manage these lists as many separate memory allocations, each with the overhead of a Vec (24 bytes on a 64-bit system) in addition to the storage block. So, instead, we aggregate these lists by keeping them all in one large Vec (per kind) and holding index ranges as virtual handles to lists in the rest of the IR.

We define a general abstraction here ListPool<T> for a list of T, with a ListRef<T> that together with the pool can yield an actual slice. This container is instantiated several times in the FunctionBody, namely for the arg_pool and type_pool.

Structs§

  • A “storage pool” backing many ListRefs of the given type.
  • A handle to a list stored in a ListPool.