24.16.8 Auto-Remapping

By default poke always tries to handle mapped values in a transparent way, i.e. in the same way than if the values weren’t mapped. To guarantee that the contents of mapped values are always up to date, it may need to issue remaps when the value gets referenced.

For example, consider the following Poke program:

var arr = X86_Insn[1024];

There, an array of 1024 x86 instructions arr is mapped. Every time the array value is referenced it is re-mapped from the corresponding IO space. For example:

arr[2].opcode = 0x0b;

In the reference above, the whole array should be re-mapped from IO space, because x86 instructions are variable-length, so it is necessary to re-read all the previous values before accessing the element in position 2.

This re-mapping 100% guarantees that the mapped values are up to date. However, this can get very slow, depending on the data structures we are poking at. poke thus tries to be smart and do as less remapping as possible. In non-volatile IO spaces, like files, only mapped values whose contents have been updated by poke itself will be re-mapped. This is in contrast to volatile IO spaces, in which the underlying contents may be updated any time out of the control of poke, and therefore remapping cannot be avoided. In read-only non-volatile IO spaces poke doesn’t remap values at all.

The user can explicitly re-map values using the remap operator. Like:

(poke) remap arr