[RyuJit Wasm] Fix Signature Generation Bug with Un-called methods#125090
Conversation
…ithGCInfo on Wasm, clean up signature index assignment logic
There was a problem hiding this comment.
Pull request overview
Ensures WebAssembly ReadyToRun compilation always materializes a WasmTypeNode (type signature) for every compiled managed method, fixing missing signature/type-section entries for methods that were compiled but never referenced by relocations.
Changes:
- Add a
NodeFactory.WasmTypeNode(MethodDesc)overload that derives the signature viaWasmLowering.GetSignature. - Add a static dependency from
MethodWithGCInfoto the method’sWasmTypeNodewhen targeting Wasm32. - Simplify signature index assignment in
WasmObjectWriter.RecordMethodSignatureby using_uniqueSignatures.Count.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunCodegenNodeFactory.cs | Adds a factory helper to create/cache WasmTypeNode from a MethodDesc signature. |
| src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/MethodWithGCInfo.cs | Ensures each compiled method depends on (and thus emits/records) its Wasm signature node. |
| src/coreclr/tools/Common/Compiler/ObjectWriter/WasmObjectWriter.cs | Uses dictionary count as the next signature index (removes redundant counter). |
...r/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/MethodWithGCInfo.cs
Outdated
Show resolved
Hide resolved
...r/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/MethodWithGCInfo.cs
Outdated
Show resolved
Hide resolved
…yAnalysis/ReadyToRun/MethodWithGCInfo.cs Co-authored-by: Michal Strehovský <[email protected]>
...r/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/MethodWithGCInfo.cs
Outdated
Show resolved
Hide resolved
I don't think this is an unreasonable approach, but |
This is a good point, and I wasn't considering all the possible NAOT nodes nodes that may need to have this new dependency. The reason I decided on this approach was for clarity -- it seemed clearer to have all type signatures originate in the dependency graph and to simply process them in the object writer, as opposed to having some originate in the graph (for reloc targets) and others in the object writer. |
|
My work is blocked on this, can we land it as-is or is there something wrong with it? |
…yAnalysis/ReadyToRun/MethodWithGCInfo.cs Co-authored-by: SingleAccretion <[email protected]>
I think we can merge as-is so you're unblocked. I do have a follow up I'm working on that I'll want to merge shortly (basically, an interface that code nodes can implement so that we enforce that they do indeed produce a type signature in the graph). |
|
I was able to just apply your changes locally so we can take our time merging this if you want. |
…yAnalysis/ReadyToRun/MethodWithGCInfo.cs Co-authored-by: Copilot <[email protected]>
...r/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/MethodWithGCInfo.cs
Outdated
Show resolved
Hide resolved
Change IWasmCodeNode to look more like IMethodNode for ease of integration. Implement IWasmMethodCodeNode for code carrying nodes, and a dispatch check in ObjectNode.GetStaticDependencies to ensure we add a new edge and node to represent the type signature of a method code node in the dependency graph.
…b.com:adamperlin/runtime into adamperlin/wasm-crossgen-method-typenode-deps
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs
Show resolved
Hide resolved
|
@MichalStrehovsky I've implemented your suggestions for the interface / ObjectNode implementation. Please feel free to take another look when you have a chance. I'm leaving out |
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs
Show resolved
Hide resolved
.../ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/DelayLoadHelperMethodImport.cs
Outdated
Show resolved
Hide resolved
…> IMethodCodeNodeWithTypeSignature; remove some redundant interface impl declarations
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs
Show resolved
Hide resolved
...r/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/MethodWithGCInfo.cs
Outdated
Show resolved
Hide resolved
src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs
Show resolved
Hide resolved
|
EDIT: Ignore this |
…25090) #124685 changed our signature recording logic in favor of using `WasmTypeNode`s in the dependency graph. However, we do not create these nodes currently unless they are the target of a relocation, but every compiled method will need one. This PR adds `WasmTypeNode` as a static dependency of `MethodWithGCInfo` to make sure we always create a type signature node for every method we compile. --------- Co-authored-by: Michal Strehovský <[email protected]> Co-authored-by: SingleAccretion <[email protected]> Co-authored-by: Copilot <[email protected]>
#124685 changed our signature recording logic in favor of using
WasmTypeNodes in the dependency graph. However, we do not create these nodes currently unless they are the target of a relocation, but every compiled method will need one. This PR addsWasmTypeNodeas a static dependency ofMethodWithGCInfoto make sure we always create a type signature node for every method we compile.