-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Move managed type system APIs to UTF-8 #122658
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
base: main
Are you sure you want to change the base?
Conversation
This reverts commit ed668c3.
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 moves managed type system APIs from string-based operations to UTF-8 byte spans to reduce string allocations during compilation. The changes update core interfaces (IPrefixMangledType, IPrefixMangledMethod, IPrefixMangledSignature, MetadataType.GetNestedType) and their implementations to use ReadOnlySpan<byte> instead of string.
Key Changes
- Interface signatures changed from
stringtoReadOnlySpan<byte>for name/prefix properties - GetNestedType methods now accept
ReadOnlySpan<byte>parameters - String literals converted to UTF-8 literals (e.g.,
"Boxed"→ `"Boxed"u8) - Switch statements replaced with if-else chains for span comparisons
Reviewed changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| IPrefixMangledType.cs | Changed Prefix property from string to ReadOnlySpan |
| IPrefixMangledMethod.cs | Changed Prefix property from string to ReadOnlySpan |
| IPrefixMangledSignature.cs | Changed Prefix property from string to ReadOnlySpan |
| MetadataType.cs | Changed GetNestedType parameter from string to ReadOnlySpan |
| CompilerTypeSystemContext.Mangling.cs | Updated Prefix implementations to return UTF-8 literals |
| CompilerTypeSystemContext.InterfaceThunks.cs | Added caching of UTF-8 prefix as byte array field |
| CompilerTypeSystemContext.BoxedTypes.cs | Updated GetNestedType signature |
| CompilerTypeSystemContext.GeneratedAssembly.cs | Updated GetNestedType signature |
| ReadyToRunCompilerContext.cs | Changed GetNestedType call to use UTF-8 literal |
| Compilation.cs | Changed GetKnownNestedType call to use UTF-8 literal |
| TypeRefTypeSystemType.cs | Updated GetNestedType with UTF-8 parameter, converts to string for dictionary lookup |
| EcmaType.cs | Updated GetNestedType to accept UTF-8, uses Append and GetString |
| EcmaModule.cs | Updated type reference resolution to use UTF-8 with Append |
| TypeSystemHelpers.cs | Changed GetFullName to return UTF-8, uses Append extension |
| SimpleArrayOfTRuntimeInterfacesAlgorithm.cs | Changed static array to ReadOnlyMemory[] for UTF-8 storage |
| UnmanagedCallingConventions.cs | Converted switch expression to if-else chain for UTF-8 comparisons |
| ComparerIntrinsics.cs | Changed methods to accept UTF-8 parameters, uses Append for type name construction |
| NativeAotILProvider.cs | Converted switch to if-else chain for UTF-8 name comparisons |
| Multiple *Mangling.cs files | Updated Prefix implementations to return UTF-8 literals |
| Multiple type stub files | Updated GetNestedType method signatures |
| CalliMarshallingMethodThunk.Mangling.cs | Added UTF-8 prefix logic with Append call |
| HelperExtensions.cs | Updated GetKnownNestedType signature |
| CustomAttributeTypeNameParser.cs | Updated nested type lookup to convert to UTF-8 |
| ProcessLinkerXmlBase.cs | Updated nested type lookup to convert to UTF-8 |
| Multiple partial type files | Updated GetNestedType signatures to accept UTF-8 |
| UnsafeIntrinsics.cs | Added TODO comment about avoiding string allocations |
Moved some APIs to UTF-8 when there was the chance to avoid some string allocations for at least some code paths.
Contributes to #122363.