AssemblyScript Runtime Visualizer / TLSF

Notes:

Implementation constants: ? bits alignment, ? bits first level, ? bits second level, ? B overhead

First level bitmap

The first level map is a bitmap determining whether free blocks exist in at least one of its respective second levels. In this implementation, the first bit indicates whether a small block (< 256B) exists. Each bit doubles the size.

Second level maps

Second level maps subdivide each first level into multiple lists of subsizes. Each one works similar to the first level bitmap.

Heads

The heads of the actual free lists, one per second level per first level. Values here are pointers into memory. Last item is the address of the special zero-size "used" tail block, which is usually the end of WASM memory minus block overhead.

Allocator

Chose a size to allocate. Annotated list indexes depend on implementation constants but match those of this implementation.

 

Small blocks: ... (δ ≙ block overhead)

Common blocks: (e.g. allocate 3, free middle, check second level)

Large blocks:

Segments

Allocations performed above are tracked here so you can free them again. Note that TLSF alone does not keep track of used blocks (unless free'd and put in a free list again). It is expected that adjacent free blocks become merged automatically.