diff --git a/src/coreclr/src/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs b/src/coreclr/src/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs
index 628b3561c21c7..8fceca0c4cbd1 100644
--- a/src/coreclr/src/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs
+++ b/src/coreclr/src/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
+using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@@ -236,6 +237,11 @@ public sealed class ReadyToRunCodegenCompilation : Compilation
public ReadyToRunSymbolNodeFactory SymbolNodeFactory { get; }
public ReadyToRunCompilationModuleGroupBase CompilationModuleGroup { get; }
private readonly int? _customPESectionAlignment;
+ ///
+ /// Determining whether a type's layout is fixed is a little expensive and the question can be asked many times
+ /// for the same type during compilation so preserve the computed value.
+ ///
+ private ConcurrentDictionary _computedFixedLayoutTypes = new ConcurrentDictionary();
internal ReadyToRunCodegenCompilation(
DependencyAnalyzerBase dependencyGraph,
@@ -375,7 +381,7 @@ public override void WriteDependencyLog(string outputFileName)
}
}
- public bool IsLayoutFixedInCurrentVersionBubble(TypeDesc type)
+ private bool IsLayoutFixedInCurrentVersionBubbleInternal(TypeDesc type)
{
// Primitive types and enums have fixed layout
if (type.IsPrimitive || type.IsEnum)
@@ -423,6 +429,9 @@ public bool IsLayoutFixedInCurrentVersionBubble(TypeDesc type)
return true;
}
+ public bool IsLayoutFixedInCurrentVersionBubble(TypeDesc type) =>
+ _computedFixedLayoutTypes.GetOrAdd(type, (t) => IsLayoutFixedInCurrentVersionBubbleInternal(t));
+
public bool IsInheritanceChainLayoutFixedInCurrentVersionBubble(TypeDesc type)
{
// This method is not expected to be called for value types
diff --git a/src/tests/issues.targets b/src/tests/issues.targets
index befba6a7db558..92403cade25a2 100644
--- a/src/tests/issues.targets
+++ b/src/tests/issues.targets
@@ -914,9 +914,6 @@
https://github.com/dotnet/runtime/issues/32732
-
- https://github.com/dotnet/runtime/issues/38259
-
https://github.com/dotnet/runtime/issues/615