Uh oh!
There was an error while loading. Please reload this page.
Extract WASM section model - #131770
Conversation
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. |
There was a problem hiding this comment.
Pull request overview
This PR refactors the WASM object writer’s section handling by extracting section-related types into dedicated files and introducing a small WasmSections helper to centralize section storage and name→index lookup.
Changes:
- Replace the writer’s raw
List<WasmSection>+ name dictionary with aWasmSectionswrapper. - Move
WasmSection,WasmDataSection,WasmDataSegment, andWebcilSectionout ofWasmObjectWriter.csinto separate source files. - Update
ILCompiler.ReadyToRun.csprojto compile the newly extracted WASM object-writer sources.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/tools/Common/Compiler/ObjectWriter/WasmObjectWriter.cs | Switch to WasmSections and update section lookups / counts after type extraction. |
| src/coreclr/tools/Common/Compiler/ObjectWriter/Wasm/WebcilSection.cs | New extracted WebcilSection implementation for READYTORUN Webcil-wrapped data sections. |
| src/coreclr/tools/Common/Compiler/ObjectWriter/Wasm/WasmSections.cs | New wrapper for section list + name→index mapping. |
| src/coreclr/tools/Common/Compiler/ObjectWriter/Wasm/WasmSection.cs | New extracted base section type (header encoding / emit + prepend count). |
| src/coreclr/tools/Common/Compiler/ObjectWriter/Wasm/WasmDataSegment.cs | New extracted data-segment type used by the combined data section emission. |
| src/coreclr/tools/Common/Compiler/ObjectWriter/Wasm/WasmDataSection.cs | New extracted data section that emits multiple segments with alignment/padding. |
| src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj | Add compile includes for the newly extracted WASM object-writer files. |
Suppressed comments (1)
src/coreclr/tools/Common/Compiler/ObjectWriter/Wasm/WebcilSection.cs:42
- After removing the redundant
_streamfield, the overrides should also use the inheritedStreamproperty so the implementation stays consistent with the base state.
public override int EncodeSize()
{
return (int)_stream.Length;
}
public override int Emit(Stream outputFileStream)
{
// Emit the raw contents of this Webcil section followed by any required padding.
_stream.Position = 0;
_stream.CopyTo(outputFileStream);
_paddingHelper.PadStream(outputFileStream, (int)Padding);
return (int)_stream.Length + (int)Padding;
}
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
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. |
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
agocke
left a comment
There was a problem hiding this comment.
Looked at the second PR, I think it's fine to move the refactoring changes in there instead.
Summary
This is the first PR in a four-PR stack that extracts a base WasmObjectWriter to be shared between NativeAOT and ReadyToRun. This one mostly just moves code related to WasmSection around and adds a WasmSections abstraction.
WasmSectionsas an abstraction to track and retrieve sections by name or section index.This layer is intended to be mechanical and not introduce changes to behavior.
Stack
Note
This PR description was generated with GitHub Copilot assistance.