Note [Allocating string literals]

GHC/ByteCode/Asm.hs:128 compiler

Our strategy for handling top-level string literal bindings is described in
Note [Generating code for top-level string literal bindings] in GHC.StgToByteCode,
but not all Addr# literals in a program are guaranteed to be lifted to the
top level. Our strategy for handling local Addr# literals is somewhat simpler:
after assembling, we find all the BCONPtrStr arguments in the program, malloc
memory for them, and bake the resulting addresses into the instruction stream
in the form of BCONPtrWord arguments.

We used to allocate remote buffers for BCONPtrStr ByteStrings when
assembling, but this gets in the way of bytecode serialization: we
want the ability to serialize and reload assembled bytecode, so
it's better to preserve BCONPtrStr as-is, and only perform the
actual allocation at link-time.

Note that, as with top-level string literal bindings, this memory is never
freed, so it just leaks if the BCO is unloaded. See Note [Generating code for
top-level string literal bindings] in GHC.StgToByteCode for some discussion
about why.

References 1

Referenced by 1