Add typed self-counting WASM sections - #131771
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
This PR refactors WASM section emission in the CoreCLR object writer to use typed, self-counting “vector” sections (imports/functions/globals/exports/elements), moving per-row encoding into section-specific WriteEntry implementations and eliminating manual counters / count-prefix patching in the writer.
Changes:
- Introduces
WasmVectorSection/WasmSection<TEntry>abstractions that prepend the vector length automatically and increment entry counts only after successful entry encoding. - Updates
WasmObjectWriterto useAdd*APIs that delegate row encoding/counting to typed section implementations, and finalizes Type/Code counts via an externally-counted section type. - Moves
WasmExportKindto a shared location (WasmNative.cs) for reuse by section code.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/tools/Common/Compiler/ObjectWriter/WasmObjectWriter.cs | Switches writer logic to typed sections (Add* methods) and removes manual count handling; finalizes external counts for Type/Code. |
| src/coreclr/tools/Common/Compiler/ObjectWriter/WasmNative.cs | Adds shared WasmExportKind enum for export section encoding. |
| src/coreclr/tools/Common/Compiler/ObjectWriter/Wasm/WasmSections.cs | Adds typed GetSection<T> helpers to retrieve sections safely by name/index. |
| src/coreclr/tools/Common/Compiler/ObjectWriter/Wasm/WasmSection.cs | Replaces PrependCount with a generalized content-prefix mechanism and adds self-counting vector section implementations for key WASM sections. |
There was a problem hiding this comment.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Note
This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
b313142 to
48871a1
Compare
…t/runtime into wasm-writer-typed-sections
There was a problem hiding this comment.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Note
This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.
Summary
This is the second PR in the WASM object-writer stack and builds on #131770.
SectionWriter's data toSectionDataEmitter.The emitted module structure and existing writer behavior are preserved while making section counts follow directly from successfully written rows.
Stack
Note
This PR description was generated with GitHub Copilot assistance.