Skip to content

GC: make runtime StringCells collectible and finalizable #325

Description

@chrisbbreuer

Parent: #134
Required by: #324
Related: #97, #144

Problem

Value stores JavaScript strings as *StringCell, but src/gc.zig currently treats every non-object value as an immediate primitive. Runtime StringCells and their byte storage are therefore arena-permanent and cannot participate in precise liveness or exact external-buffer finalization. That blocks #324 and leaves allocation-heavy string workloads outside the real heap lifecycle.

Scope

  • Add an explicit heap-managed StringCell kind and distinguish static/intern-table/arena cells from collectible runtime cells without pointer guessing.
  • Route fallible runtime string construction through the active context heap when GC is enabled, retaining the existing explicit arena mode where configured.
  • Trace string-valued roots and edges everywhere Value is traced, including interpreter frames, environments, object slots/elements/accessors, promises, modules, workers, C-API handles, debugger state, temporary roots, and concurrent snapshots.
  • Finalize owned string bytes exactly once and provide a general external-owner finalizer record usable by ABI: implement external ZigString ownership and finalization #324; callbacks must run outside collector/internal object locks and remain safe under reentry.
  • Preserve canonical WTF-8 content, equality/hash behavior, atom/intern ownership, static literals, sibling-realm sharing, and no-GIL memory ordering.
  • Integrate the required cell-kind/finalizer support into ~/Code/Libraries/zig-gc as a separately committed dependency change only if the generic collector needs extension.

Acceptance

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions