Skip to content

Observability: publish generated-code symbols and exact native stacks #501

Description

@chrisbbreuer

Parent: #459
Depends on: #461, #483
Related: #466, #467, #487, #495

Goal

Make generated JavaScript and WebAssembly code fully visible to host profilers, crash reporters, debuggers, and the zig-js inspector with exact native↔source↔bytecode attribution.

Current boundary

The saved macOS baseline profile sees hot anonymous MAP_JIT addresses as <unknown binary> because generated mappings have no native symbol table. #461 requires symbolized attribution and #483 includes debug/unwind metadata, but neither owns end-to-end profiler registration, native stack reconstruction, or lifecycle validation.

Scope

  • Define artifact-owned symbols for functions, tiers, OSR regions, runtime stubs, Wasm functions, side exits, and retired generations.
  • Publish native PC ranges to macOS sampling/crash tooling and Linux perf/jitdump/perf-map interfaces through owned writers and explicit platform APIs.
  • Emit/register exact unwind metadata for every native frame, call stub, deopt/side exit, trap, and host transition on each ABI.
  • Map native PC → artifact generation → optimizer/baseline/Wasm origin → bytecode/Wasm offset → source URL/line/column, including inlined frames.
  • Reconstruct logical stacks across JS↔host↔Wasm, async continuations, generators, exceptions, proper-tail calls, deopt, and optimized-away frames where required.
  • Deregister/retire symbols and unwind records only after the final executing reader leaves the artifact epoch.
  • Measure registration, sampling, symbolization, memory, and disabled-path overhead.

No-workaround rules

  • No permanent executable mapping retention for symbolization, stale/reused PC attribution, guessed stack scanning, profiler-only different codegen, unsafe unwind through Zig frames, or dependency on a third-party profiler library.

Acceptance

  • Owned fixtures validate PC ranges, names, source offsets, inline/deopt frames, unwind, crash traces, and async/host/Wasm boundaries on each backend.
  • System profiler samples attribute generated leaves to stable symbols instead of anonymous mappings.
  • Inspector CPU profiles and host-native samples agree on artifact/source identity for the same execution.
  • Invalidation/retirement/teardown races never expose stale metadata and pass TSan/artifact lifetime tests.
  • Disabled observability has measured zero or bounded negligible overhead; enabled overhead and memory are published.

Foundation

Baseline dispatch profile; inspector/CPU-profile foundations under #139/#404.

Metadata

Metadata

Assignees

No one assigned

    Labels

    embeddingZig, C, private ABI, and Objective-C embeddingenhancementNew feature or requestjitBytecode, baseline JIT, optimizer, and code generationperformanceMeasured runtime, memory, scaling, or build performance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions