Skip to content
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

Minor changes to IIDOptimizer and AOTOptimizer #1626

Merged
merged 3 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Authoring/WinRT.SourceGenerator/AotOptimizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,9 @@ void AddVtableAttributesForType(Microsoft.CodeAnalysis.TypeInfo instantiatedType
// type need to be put on the CCW.
if (instantiatedType.Type is IArrayTypeSymbol arrayType)
{
if (convertedToTypeSymbol is not IArrayTypeSymbol)
if (convertedToTypeSymbol is not IArrayTypeSymbol &&
// Make sure we aren't just assigning it to a value type such as ReadOnlySpan
!convertedToTypeSymbol.IsValueType)
{
if (visitedTypes.Contains(arrayType))
{
Expand Down
23 changes: 16 additions & 7 deletions src/Perf/IIDOptimizer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,28 @@ private static int GuidPatch(string targetAssembly, string outputDirectory, IEnu
var winRTRuntimeAssembly = ResolveWinRTRuntime(targetAssemblyDefinition, resolver);
if (winRTRuntimeAssembly is null)
{
Console.WriteLine("Failed to resolve WinRT.Runtime.dll.");
return -1;
}

var guidPatcher = new GuidPatcher(winRTRuntimeAssembly, targetAssemblyDefinition);

int numPatches = guidPatcher.ProcessAssembly();
int numPatches = guidPatcher.ProcessAssembly();
Console.WriteLine($"{numPatches} IID calculations/fetches patched");

guidPatcher.SaveAssembly(outputDirectory);

Console.WriteLine($"Saved patched .dll to {outputDirectory}");
Console.WriteLine($"{numPatches} IID calculations/fetches patched");
return 0;
// Only write assembly if we actually patched anything.
// Otherwise we would just write a type we use as part of our implementation
// when it is actually not needed.
if (numPatches > 0)
{
guidPatcher.SaveAssembly(outputDirectory);
Console.WriteLine($"Saved patched .dll to {outputDirectory}");
return 0;
}
else
{
// Exit code is checked by caller to copy patched file over.
return -1;
}
}
catch (AssemblyResolutionException e)
{
Expand Down