Skip to content

Research: Wa wire IR / ARC lowering for explicit ownership events in OwnIR #441

Open

Description

@PhysShell

Context

Wa is a Go-like language primarily targeting WebAssembly. Its compiler currently exposes two potentially relevant layers:

  • internal/ssa: a Go-derived, source-oriented SSA representation.
  • internal/wire: a newer, higher-level IR with explicit allocations, locations, references, Retained() expression metadata and Release operations.

The new IR has ARC-related lowering in internal/wire/function.go (EndBody, arc_block, arc_expr) and internal/backends/wire2wat/wire2wat.go (calls to runtime.Block.Retain / runtime.Block.Release). See also ins_alloc_imv_extract_discard_release.go and ins_set_assign_store.go.

Maturity caveat: as inspected on 2026-10-24, the normal wa build path in appbuild.go still goes through compiler_wat and SSA; the newer wire2wat backend is not integrated there. The new code also contains TODO/panic branches. Do not treat this as a production-proven ownership verifier or soundness reference.

Research question

Can Own.NET benefit from retaining explicit ownership-relevant semantic events in OwnIR rather than reconstructing them later from generic lower-level operations?

Compare Wa's representation and transformations with our existing Roslyn → OwnIR lowering and ownership/borrow diagnostics, especially:

  1. Alloc / heap-vs-register placement; Get, Load, Set, Assign, Store, Discard, Release.
  2. Retained() semantics and what is explicitly preserved or lost about value ownership vs. reference-counting conventions.
  3. How EndBody / arc_block / arc_expr handle copies, overwrites, branches, loops, calls, return values, and cleanup.
  4. Whether any minimal event vocabulary (e.g. acquire, alias, transfer, invalidate, release, escape) would actually improve a frequent/high-severity Own.NET diagnostic, including explanation and evidence quality.
  5. Cases where mapping Wa's ARC semantics to C# would be incorrect (GC-managed objects, IDisposable, aliasing, ref/out, borrowing, async, exceptional exits). ARC retain/release is not equivalent to Rust-style borrow checking or .NET disposal obligations.

Proposed bounded investigation

  • Pin the exact upstream Wa commit being studied; trace the real path from source AST/type information to wire, and separately confirm which paths are currently exercised by wa build.
  • Produce a compact mapping table: Wa IR operation → OwnIR construct/event → semantics preserved/missing → potential diagnostic affected.
  • Walk through at least 3 concrete snippets (overwrite + alias, branching/early return, exceptional/cleanup case where representable). Record both the Wa lowering behavior and the closest relevant C# case; mark unsupported Wa constructs as unsupported, not as passing.
  • Identify one existing Own.NET diagnostic with a documented precision or soundness gap that explicit ownership events might address. Compare with a simpler improvement to current Roslyn lowering.
  • State a falsifiable recommendation: ADOPT SMALL IDEA, DEFER, or REJECT, backed by concrete code and expected costs.
  • If recommending adoption, propose a separate, tiny prototype issue with testable invariants and regression fixtures. No large IR rewrite in this research issue.

Non-goals / stop rules

  • No language/compiler port, WebAssembly backend, or reuse of Wa's runtime.
  • No assumption that inserting Retain/Release proves memory safety, prevents use-after-free, or establishes soundness.
  • No broad redesign based on architectural resemblance alone.
  • Stop with DEFER/REJECT if there is no plausible gain over current OwnIR for an actual high-value diagnostic.

Upstream references

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions