benilla-re systems structs docs

luaO_int2fb

function · lua · primitive

Address
0x6f5810 · 22 bytes, up to 0x6f5825
Signature
int32_t __fastcall (uint32_t x)
Meaning
Encodes a size as a byte: a 3-bit mantissa under a 5-bit exponent, rounded up
Confidence
verified, proof two
Finding
lua/object#the-floating-byte-size-code
Test
lua::luao_int2fb_difftest

Finding: The floating-byte size code in lua: objects and tables

luaO_int2fb(x) codes an array size as a 3-bit mantissa under a 5-bit exponent: while x is 8 or more, compared unsigned, it takes x = (x + 1) >> 1 and counts the step e, and the code is e << 3 | x. OP_NEWTABLE decodes its B operand as (B & 7) << (B >> 3), the array size, and passes C to luaH_new as the log2 of the hash size. The code rounds up: 9 array items size an array of 10, and 0xffffffff wraps to 0 in one step and codes as 8.

The derivation is in the doc.

Callers 1

Callees 0

None by a direct call or jump.

Calls and jumps by a bare address, from tables/calls.tsv.