Skip to content
Beskid Platform specification

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

Memory and references

Platform spec node

Memory and references

Spec standingStandard

Owner
Piotr Mikstacki
Submitter
Piotr Mikstacki

Defines local storage, ref/out parameters, GC-managed heap objects, arrays, and cross-fiber sharing at the language level. Collector algorithms and write barriers must match execution platform-spec; the /execution/ doc tree is informative only.

  • Locals live in function activation records unless captured by closures (see Lambdas and closures).
  • Assignment to immutable bindings must error (E1214).
  • mut on locals and parameters must be present to allow reassignment where required by the reference compiler.
  • Parameters may use ref T or out T modifiers (ParameterModifier).
  • ref passes an alias to existing storage; out requires definite assignment before read on callee entry.
  • ref in type expressions (ref T) denotes reference types in signatures distinct from by-value T.
  • T[] values use the fat-pointer layout (BeskidArray) described in execution ABI material.
  • Element access must respect bounds checks in safe builds (lowering inserts checks unless proven).
  • Reference-bearing values that escape their defining frame must live on the GC heap traced by the runtime collector (concurrent tri-color mark-sweep in the reference implementation).
  • User code must not expose manual free or untracked pointers in v0.1.
  • Pointer stores to heap objects must execute write barriers when required by the active GC phase (see execution memory contracts).
  • null must not appear as a value; optional absence uses Option<T> per Types.
  • Values must not be shared across fibers by alias unless immutability is proven or synchronization uses Channel<T> per Fibers and spawn.
  • Capturing mutable shared state in spawn closures should be rejected when detectable.
  • Stack frames are tied to call/return; return ends the frame and invalidates temporaries.
  • Closure environments must outlive uses tracked by the compiler’s capture analysis.

Immutability E1214; member access E1211–E1213. Registry: Diagnostic code registry.

Memory rules enforced in beskid_analysis must be preserved in codegen for L3 claims.

  • D-LM-MEM-001 — Channel-only fiber sharing: Language law forbids ad hoc shared mutable globals across fibers.
  • D-LM-MEM-002 — Fat-pointer arrays: All T[] share one ABI representation per target unless a profile documents otherwise.
  • D-LM-MEM-003 — GC by default: Heap objects are collector-managed; escape analysis may stack-allocate but must not skip tracing when pointers escape.
  • D-LM-MEM-004 — No null addresses: References are non-null at the type level; Option<T> models absence.

Locals, ref T, GC-traced heap objects, and channel-mediated sharing. Runtime barrier and phase details live under platform-spec execution; /execution/ pages are a legacy bridge only.