Module cranelift_interpreter::address

source ·
Expand description

Virtual Addressing Scheme for the Interpreter

The interpreter uses virtual memory addresses for its memory operations. These addresses are obtained by the various _addr instructions (e.g. stack_addr) and can be either 32 or 64 bits.

Addresses are composed of 3 fields: “region”, “entry” and offset.

“region” refers to the type of memory that this address points to. “entry” refers to which instance of this memory the address points to (e.g table1 would be “entry” 1 of a Table region address). The last field is the “offset”, which refers to the offset within the entry.

The address has the “region” field as the 2 most significant bits. The following bits are the “entry” field, the amount of “entry” bits depends on the size of the address and the “region” of the address. The remaining bits belong to the “offset” field

An example address could be a 32 bit address, in the function region, which has 1 “entry” bit this address would have 32 - 1 - 2 = 29 offset bits.

The only exception to this is the “stack” region, where, because we only have a single “stack” we have 0 “entry” bits, and thus is all offset.

address sizeaddress kindregion value (2 bits)entry bits (#)offset bits (#)
32Stack0b00030
32Function0b01129
32Table0b10525
32GlobalValue0b11624
64Stack0b00062
64Function0b01161
64Table0b101052
64GlobalValue0b111250

Structs§

Enums§