Move shared WASM logic to base writer - #131778
Draft
jtschuster wants to merge 9 commits into
Draft
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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. |
This was referenced Aug 3, 2026
This was referenced Aug 4, 2026
Open
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…m/dotnet/runtime into wasm-writer-shared-implementation-local
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the WebAssembly object writer stack by extracting shared section creation/mapping, symbol/index-space management, and emission-order orchestration into a new WasmObjectWriter base class, while keeping WebCIL-specific behavior in WebCilObjectWriter.
Changes:
- Introduces
WasmObjectWriteras the shared base implementation for WASM section construction, symbol management, and emission ordering. - Updates
WebCilObjectWriterto delegate shared behaviors to the base writer and provide a WebCIL-specific data-section factory. - Adjusts WASM section interfaces/implementation details and updates the ReadyToRun project to compile the new base writer.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/coreclr/tools/Common/Compiler/ObjectWriter/WebCilObjectWriter.cs | Moves shared WASM writer logic to the base class and adds an override factory for WebCIL data sections; retains WebCIL-specific import/export/global/layout behavior. |
| src/coreclr/tools/Common/Compiler/ObjectWriter/WasmObjectWriter.cs | Adds new shared base writer encapsulating section typing/mapping, symbol/index-space management, and section emission order. |
| src/coreclr/tools/Common/Compiler/ObjectWriter/Wasm/WasmSection.cs | Makes WASM emission/section interfaces explicitly internal and removes redundant bool initialization. |
| src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj | Adds the new base writer to compilation inputs (but currently duplicates the WebCIL writer include). |
| <Compile Include="..\..\Common\Compiler\ObjectWriter\Wasm\WebcilSection.cs" Link="Compiler\ObjectWriter\Wasm\WebcilSection.cs" /> | ||
| <Compile Include="..\..\Common\Compiler\ObjectWriter\WebCilObjectWriter.cs" Link="Compiler\ObjectWriter\WebCilObjectWriter.cs" /> | ||
| <Compile Include="..\..\Common\Compiler\ObjectWriter\WasmObjectWriter.cs" Link="Compiler\ObjectWriter\WasmObjectWriter.cs" /> | ||
| <Compile Include="..\..\Common\Compiler\ObjectWriter\WebCilObjectWriter.cs" Link="Compiler\ObjectWriter\WebCilObjectWriter.cs" /> |
Comment on lines
+703
to
+706
| internal const int StackPointerGlobalIndex = 0; | ||
| internal const int ImageBaseGlobalIndex = 1; | ||
| internal const int TableBaseGlobalIndex = 2; | ||
| internal const int AsyncContinuationGlobalIndex = 3; |
Comment on lines
+77
to
+83
| if (_sectionEmitOrder is null) | ||
| { | ||
| _sectionEmitOrder = _sectionOrder | ||
| .Where(name => _sections.Contains(name)) | ||
| .Select(name => _sections.GetSectionIndex(name)) | ||
| .ToArray(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is the fourth PR in the WASM object-writer stack and builds on #131772.
WasmObjectWriter.WebCilObjectWritercan continue creating embeddedWebcilSectioninstances.WebCilObjectWriter.This preserves current WebCIL behavior while leaving the generic writer implementation ready to be shared with a second WebAssembly object writer.
Stack
Validation
./build.sh clr+libs+libs.pretest+hostcompleted with 0 warnings and 0 errors.ILCompiler.ReadyToRun.Testsbuilt with 0 warnings and 0 errors.WasmWebcilModuletest ran exactly once and passed.git diff --checkpassed.Note
This PR description was generated with GitHub Copilot.
Stack created with GitHub Stacks CLI • Give Feedback 💬