asmjit::ConstPool Class Reference

Constant pool.

Public Members

Public Types

Member Functions

Construction & Destruction

Member Enumeration Documentation

ConstPool::Scope : uint32_tenum

Constant pool scope.


Local constant, always embedded right after the current function.


Global constant, embedded at the end of the currently compiled code.

Member Function Documentation

bool ConstPool::empty() constnoexcept

Tests whether the constant-pool is empty.

size_t ConstPool::size() constnoexcept

Returns the size of the constant-pool in bytes.

size_t ConstPool::alignment() constnoexcept

Returns minimum alignment.

Error ConstPool::add(const void* data, size_t size, size_t& dstOffset)noexcept

Adds a constant to the constant pool.

The constant must have known size, which is 1, 2, 4, 8, 16 or 32 bytes. The constant is added to the pool only if it doesn't not exist, otherwise cached value is returned.

AsmJit is able to subdivide added constants, so for example if you add 8-byte constant 0x1122334455667788 it will create the following slots:

8-byte: 0x1122334455667788 4-byte: 0x11223344, 0x55667788

The reason is that when combining MMX/SSE/AVX code some patterns are used frequently. However, AsmJit is not able to reallocate a constant that has been already added. For example if you try to add 4-byte constant and then 8-byte constant having the same 4-byte pattern as the previous one, two independent slots will be generated by the pool.

void ConstPool::fill(void* dst) constnoexcept

Fills the destination with the content of this constant pool.

Member Data Documentation

Zone* ConstPool::_zone

Zone allocator.

Tree ConstPool::_tree[kIndexCount]

Tree per size.

Gap* ConstPool::_gaps[kIndexCount]

Gaps per size.

Gap* ConstPool::_gapPool

Gaps pool.

size_t ConstPool::_size

Size of the pool (in bytes).

size_t ConstPool::_alignment

Required pool alignment.