Skip to content

Correct and compact DWARF line-program encoding - #9196

Open
cpunion wants to merge 4 commits into
WebAssembly:mainfrom
cpunion:codex/dwarf-line-encoding-20261002
Open

cpunion wants to merge 4 commits into
WebAssembly:mainfrom
cpunion:codex/dwarf-line-encoding-20261002

Conversation

@cpunion

@cpunion cpunion commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #9192. Standalone diff; implementation and tests. Regenerated snapshots are in a separate commit.

Problem and fix

Discriminators use ULEB128, not the CU's address width. For a 32-bit CU and discriminator 300:

DW_LNE_set_discriminator
Before: 00 05 04 2c 01 00 00   (incorrect fixed-width operand)
After:  00 03 04 ac 02         (ULEB128 operand)

Also reset per-row markers correctly and explicitly repeat nonzero discriminators, which reset after each emitted row. Within a sequence, use relative address advances where valid instead of repeatedly emitting full addresses. This compacts encoding without changing source attribution.

Before / after

Same TinyGo goroutine/JSON input; total module bytes including DWARF:

Transformation Before (#9192) After
Roundtrip 2,098,029 1,893,879
O1 2,067,179 1,872,431
O1 + Asyncify 2,340,443 2,146,432

Stripped outputs are byte-identical. These are debug-file size savings, not runtime speedups.

Validation and scope

  • Regression fails before the fix and passes after it. Covers multi-byte/repeated discriminators, row-marker resets, address remapping, compact opcodes, and a second roundtrip.
  • 93 Python tests (including 10 DWARF tests), the wasm-opt suite, LLVM DWARF verification, and the TinyGo runtime check pass. C++: 437 passed, one existing macOS skip. V8 execution checks are left to CI.

No instruction-origin or Asyncify-specific changes; those are in #9194. GitHub's main-based diff includes the unmerged prerequisite.

Original contribution, developed with AI assistance.

@cpunion
cpunion requested a review from a team as a code owner October 2, 2026 07:27
@cpunion
cpunion requested review from stevenfontanella and removed request for a team October 2, 2026 07:27

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant