-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Fold generic method bodies by default #117411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fixes dotnet#103951. Same method with different genericness are not distinguishable in the stack traces. They are still distinguishable in the debugger, but it might be acceptable, especially since we have an opt out (undocumented for now).
|
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas |
Do you think it would be possible to rename the symbol for folded copy such that the symbol name does not include the instantiation that happened to win? |
This reverts commit 55811fd.
I think it would make things quite complicated in general. We don't have facilities to change our mind about how symbols are named. We'd also need to invent a scheme for new stable names. |
Size statisticsPull request #117411
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR replaces the boolean “fold identical method bodies” flag with a three-way MethodBodyFoldingMode enum (None, Generic, All), defaults generic folding by build integration, and wires the new mode through the compiler and MSBuild targets.
- Swapped
UseMethodBodyFolding(bool)forUseMethodBodyFolding(MethodBodyFoldingMode)in the CLI, builder, and RyuJit compilation paths. - Introduced
MethodBodyFoldingModeenum and revampedObjectDataInternerto only fold based on generics when requested. - Updated MSBuild targets to compute a default folding mode and emit the new
--methodbodyfolding:<mode>argument.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/tools/aot/ILCompiler/Program.cs | Parse string option into new MethodBodyFoldingMode |
| src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs | Change CLI option type from bool to string and update description |
| src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilationBuilder.cs | Switch interner creation to use new enum |
| src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectDataInterner.cs | Add _genericsOnly flag, CanFold, and comparer support |
| src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs | Use CanFold instead of IsNull |
| src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilationBuilder.Aot.cs | Change builder API and add enum definition |
| src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets | Compute and pass <mode> to --methodbodyfolding |
Comments suppressed due to low confidence (3)
src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs:103
- The description is missing a closing parenthesis; change to e.g. "Fold identical method bodies (one of: none, generic, all)".
new("--methodbodyfolding") { Description = "Fold identical method bodies (one of: none, generic, all" };
src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs:102
- Add an
AddValidatorto restrict the option to the valid values (none, generic, all) and produce a clear error when parsing fails.
public Option<string> MethodBodyFolding { get; } =
src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs:104
- No tests appear to validate the new MethodBodyFolding modes; please add unit tests for parsing and default behavior to ensure coverage.
public Option<string[]> InitAssemblies { get; } =
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectDataInterner.cs
Show resolved
Hide resolved
|
@sbomer is this something you'd be comfortable reviewing? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you consider making the defaults dependent on DebuggerSupport?
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectDataInterner.cs
Show resolved
Hide resolved
I didn't think about it but gave it a thought now - here's my thinking:
So I'd lean towards not tying it to that. |
Fixes #103951.
Same method with different genericness are not distinguishable in the stack traces. They are still distinguishable in the debugger, but it might be acceptable, especially since we have an opt out (undocumented for now).
Cc @dotnet/ilc-contrib