FixAcceleratedCompiledMethodEnum (#34841)
authorDavid Wrighton <davidwr@microsoft.com>
Sat, 11 Apr 2020 05:03:41 +0000 (22:03 -0700)
committerGitHub <noreply@github.com>
Sat, 11 Apr 2020 05:03:41 +0000 (05:03 +0000)
- Implementation checked in earlier today resulted in a non-sorted RUNTIMEFUNCTION list which caused unpredictable runtime failures
- Assertions around MethodCodeNode handling in EnumerateCompiledMethods were wrong

src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunCodegenNodeFactory.cs
src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/Compiler/ReadyToRunTableManager.cs

index e01e93c..9ddbe79 100644 (file)
@@ -425,16 +425,20 @@ namespace ILCompiler.DependencyAnalysis
             foreach (IMethodNode methodNode in MetadataManager.GetCompiledMethods(moduleToEnumerate, methodCategory))
             {
                 MethodDesc method = methodNode.Method;
-                Debug.Assert(methodNode == MethodEntrypoint(method));
                 MethodWithGCInfo methodCodeNode = methodNode as MethodWithGCInfo;
-                if (methodCodeNode == null && methodNode is LocalMethodImport localMethodImport)
+#if DEBUG
+                IMethodNode methodNodeDebug = MethodEntrypoint(method);
+                MethodWithGCInfo methodCodeNodeDebug = methodNodeDebug as MethodWithGCInfo;
+                if (methodCodeNodeDebug == null && methodNodeDebug is LocalMethodImport localMethodImport)
                 {
-                    methodCodeNode = localMethodImport.MethodCodeNode;
+                    methodCodeNodeDebug = localMethodImport.MethodCodeNode;
                 }
-                if (methodCodeNode == null && methodNode is PrecodeMethodImport precodeMethodImport)
+                if (methodCodeNodeDebug == null && methodNodeDebug is PrecodeMethodImport precodeMethodImport)
                 {
-                    methodCodeNode = precodeMethodImport.MethodCodeNode;
+                    methodCodeNodeDebug = precodeMethodImport.MethodCodeNode;
                 }
+                Debug.Assert(methodCodeNodeDebug == methodCodeNode);
+#endif
 
                 if (methodCodeNode != null && !methodCodeNode.IsEmpty)
                 {
index 410dd35..d2ad6b3 100644 (file)
@@ -116,6 +116,8 @@ namespace ILCompiler
                         _completeSortedMethods.AddRange(perModuleData.GenericMethodsGenerated);
                         _completeSortedGenericMethods.AddRange(perModuleData.GenericMethodsGenerated);
                     }
+                    _completeSortedMethods.Sort(sortHelper);
+                    _completeSortedGenericMethods.Sort(sortHelper);
                     _sortedMethods = true;
                 }
             }