← board

wasm32: string literals are heap copies, so a const string table stays live

emit.inc gives every literal a managed header (meta, rc = MSTR_STATIC_RC, length), so the handle Strs[si].Offset + 8 is a valid managed string whose retain and release are no-ops. The register backends use it (EmitStaticLitHandle). wasm32's WasmEmitOwnedStr allocated a copy for every literal instead.

Resolution (2026-09-28)

A non-empty literal (or any literal under the nil-py rule) hands out its static handle, with no allocation and no retain. The empty literal keeps the old path.

Copy-on-write was checked against FPC 3.2.2 with an 8-line probe: index store into a literal-initialised variable and into a copy of a typed-const element, var mutation, concat, SetLength, Insert and Delete. Output was identical.

Handing out the static handle exposed a wasm32 leak that the heap copy had been hiding: bug-a-wasm32-a-const-by-ref-argument-clones-the-string-it-indexes. Measured on wasm32: a pylib-only program 249 -> 0; json_calc_error_paths 265 -> 1.