dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.36k stars 4.75k forks source link

CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE implementattion #37161

Closed alpencolt closed 4 years ago

alpencolt commented 4 years ago

Recently we've found that crossgen2 generates CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE helper but can not find of it's implementation. Signature is empty: https://github.com/dotnet/runtime/blob/master/src/coreclr/src/inc/jithelpers.h#L270 Is it supported?

jkotas commented 4 years ago

Do you have a code snippet that makes crossgen2 to hit CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE? I believe it should be unreachable in crossgen2.

alpencolt commented 4 years ago

Ups, I mean CORINFO_HELP_READYTORUN_STATIC_BASE. Test Loader/classloader/generics/regressions/237932/repro237932/repro237932.sh failed on ARM with:

FAILED   - [   5s]Loader/classloader/generics/regressions/237932/repro237932/repro237932.sh
               BEGIN EXECUTION
               Running CrossGen2: /opt/usr/coreclr-tc/testhost/corerun /opt/usr/coreclr-tc/testhost/crossgen2/crossgen2.dll --parallelism 4 -o:/opt/usr/coreclr-tc/Loader/classloader/generics/regressions/237932/repro237932/repro237932.dll /opt/usr/coreclr-tc/Loader/classloader/generics/regressions/237932/repro237932/IL/repro237932.dll  -r:/opt/usr/coreclr-tc/testhost/System.Threading.ThreadPool.dll -r:/opt/usr/coreclr-tc/testhost/System.Linq.Expressions.dll -r:/opt/usr/coreclr-tc/testhost/System.Collections.Concurrent.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.dll -r:/opt/usr/coreclr-tc/testhost/System.Data.Odbc.dll -r:/opt/usr/coreclr-tc/testhost/System.Drawing.Primitives.dll -r:/opt/usr/coreclr-tc/testhost/System.Security.Claims.dll -r:/opt/usr/coreclr-tc/testhost/System.Core.dll -r:/opt/usr/coreclr-tc/testhost/System.Diagnostics.EventLog.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Options.ConfigurationExtensions.dll -r:/opt/usr/coreclr-tc/testhost/Dia2Lib.dll -r:/opt/usr/coreclr-tc/testhost/System.Data.dll -r:/opt/usr/coreclr-tc/testhost/System.Reflection.TypeExtensions.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.DependencyInjection.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Logging.Console.dll -r:/opt/usr/coreclr-tc/testhost/System.Xml.XmlDocument.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.WindowsRuntime.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.Serialization.Xml.dll -r:/opt/usr/coreclr-tc/testhost/System.Composition.Runtime.dll -r:/opt/usr/coreclr-tc/testhost/System.Security.Cryptography.ProtectedData.dll -r:/opt/usr/coreclr-tc/testhost/System.Memory.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Configuration.CommandLine.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Configuration.Xml.dll -r:/opt/usr/coreclr-tc/testhost/xunit.abstractions.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Hosting.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.InteropServices.RuntimeInformation.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.Mail.dll -r:/opt/usr/coreclr-tc/testhost/System.CodeDom.dll -r:/opt/usr/coreclr-tc/testhost/System.ComponentModel.Composition.Registration.dll -r:/opt/usr/coreclr-tc/testhost/System.Globalization.Calendars.dll -r:/opt/usr/coreclr-tc/testhost/System.DirectoryServices.dll -r:/opt/usr/coreclr-tc/testhost/System.Reflection.Emit.dll -r:/opt/usr/coreclr-tc/testhost/xunit.core.dll -r:/opt/usr/coreclr-tc/testhost/System.AppContext.dll -r:/opt/usr/coreclr-tc/testhost/System.Xml.Linq.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.Handles.dll -r:/opt/usr/coreclr-tc/testhost/System.ValueTuple.dll -r:/opt/usr/coreclr-tc/testhost/System.Private.CoreLib.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.WebHeaderCollection.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.VisualBasic.Core.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.VisualBasic.dll -r:/opt/usr/coreclr-tc/testhost/System.Utf8String.Experimental.dll -r:/opt/usr/coreclr-tc/testhost/OSExtensions.dll -r:/opt/usr/coreclr-tc/testhost/System.Threading.Channels.dll -r:/opt/usr/coreclr-tc/testhost/System.Threading.Timer.dll -r:/opt/usr/coreclr-tc/testhost/System.Diagnostics.Debug.dll -r:/opt/usr/coreclr-tc/testhost/System.Configuration.ConfigurationManager.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.InteropServices.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.NetworkInformation.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.FileProviders.Composite.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.WebSockets.WebSocketProtocol.dll -r:/opt/usr/coreclr-tc/testhost/System.IO.Compression.FileSystem.dll -r:/opt/usr/coreclr-tc/testhost/System.Composition.AttributedModel.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Win32.SystemEvents.dll -r:/opt/usr/coreclr-tc/testhost/System.Diagnostics.Process.dll -r:/opt/usr/coreclr-tc/testhost/System.IO.dll -r:/opt/usr/coreclr-tc/testhost/Newtonsoft.Json.dll -r:/opt/usr/coreclr-tc/testhost/xunit.performance.execution.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Logging.EventSource.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.DependencyModel.dll -r:/opt/usr/coreclr-tc/testhost/System.Xml.XPath.dll -r:/opt/usr/coreclr-tc/testhost/xunit.performance.api.dll -r:/opt/usr/coreclr-tc/testhost/System.Transactions.dll -r:/opt/usr/coreclr-tc/testhost/System.IO.FileSystem.DriveInfo.dll -r:/opt/usr/coreclr-tc/testhost/System.Console.dll -r:/opt/usr/coreclr-tc/testhost/System.Reflection.MetadataLoadContext.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Diagnostics.Tools.RuntimeClient.dll -r:/opt/usr/coreclr-tc/testhost/System.Reflection.DispatchProxy.dll -r:/opt/usr/coreclr-tc/testhost/System.Diagnostics.StackTrace.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Diagnostics.Tracing.TraceEvent.dll -r:/opt/usr/coreclr-tc/testhost/System.Xml.XmlSerializer.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.NameResolution.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.CSharp.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Configuration.dll -r:/opt/usr/coreclr-tc/testhost/System.Threading.AccessControl.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Configuration.UserSecrets.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.Serialization.Json.dll -r:/opt/usr/coreclr-tc/testhost/System.Text.RegularExpressions.dll -r:/opt/usr/coreclr-tc/testhost/xunit.assert.dll -r:/opt/usr/coreclr-tc/testhost/netstandard.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.DependencyInjection.Abstractions.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.CompilerServices.Unsafe.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.Intrinsics.dll -r:/opt/usr/coreclr-tc/testhost/System.Numerics.Tensors.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.WebClient.dll -r:/opt/usr/coreclr-tc/testhost/System.Security.dll -r:/opt/usr/coreclr-tc/testhost/System.Text.Encodings.Web.dll -r:/opt/usr/coreclr-tc/testhost/System.Xml.XPath.XDocument.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.HttpListener.dll -r:/opt/usr/coreclr-tc/testhost/System.Web.dll -r:/opt/usr/coreclr-tc/testhost/System.IO.Ports.dll -r:/opt/usr/coreclr-tc/testhost/System.Diagnostics.Tools.dll -r:/opt/usr/coreclr-tc/testhost/System.Private.DataContractSerialization.dll -r:/opt/usr/coreclr-tc/testhost/System.Text.Encoding.dll -r:/opt/usr/coreclr-tc/testhost/System.IO.Pipelines.dll -r:/opt/usr/coreclr-tc/testhost/System.Collections.Specialized.dll -r:/opt/usr/coreclr-tc/testhost/System.Security.Cryptography.Pkcs.dll -r:/opt/usr/coreclr-tc/testhost/mscorlib.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.Numerics.dll -r:/opt/usr/coreclr-tc/testhost/System.IO.Compression.ZipFile.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.CodeAnalysis.dll -r:/opt/usr/coreclr-tc/testhost/System.Windows.dll -r:/opt/usr/coreclr-tc/testhost/System.Drawing.dll -r:/opt/usr/coreclr-tc/testhost/System.Web.HttpUtility.dll -r:/opt/usr/coreclr-tc/testhost/System.Security.Principal.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.Serialization.Primitives.dll -r:/opt/usr/coreclr-tc/testhost/dotnet-Microsoft.XmlSerializer.Generator.dll -r:/opt/usr/coreclr-tc/testhost/System.Numerics.dll -r:/opt/usr/coreclr-tc/testhost/System.Diagnostics.Tracing.dll -r:/opt/usr/coreclr-tc/testhost/System.Threading.Overlapped.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.InteropServices.WindowsRuntime.dll -r:/opt/usr/coreclr-tc/testhost/System.Transactions.Local.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Win32.Registry.AccessControl.dll -r:/opt/usr/coreclr-tc/testhost/System.Globalization.dll -r:/opt/usr/coreclr-tc/testhost/System.Data.DataSetExtensions.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Http.dll -r:/opt/usr/coreclr-tc/testhost/System.Security.Cryptography.Encoding.dll -r:/opt/usr/coreclr-tc/testhost/System.Threading.Tasks.Parallel.dll -r:/opt/usr/coreclr-tc/testhost/System.IO.UnmanagedMemoryStream.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.FileProviders.Abstractions.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.Loader.dll -r:/opt/usr/coreclr-tc/testhost/System.Resources.Reader.dll -r:/opt/usr/coreclr-tc/testhost/System.Diagnostics.TraceSource.dll -r:/opt/usr/coreclr-tc/testhost/System.IO.Pipes.AccessControl.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.CodeAnalysis.VisualBasic.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Win32.Primitives.dll -r:/opt/usr/coreclr-tc/testhost/System.Linq.Parallel.dll -r:/opt/usr/coreclr-tc/testhost/System.Private.Uri.dll -r:/opt/usr/coreclr-tc/testhost/System.IO.MemoryMappedFiles.dll -r:/opt/usr/coreclr-tc/testhost/System.Configuration.dll -r:/opt/usr/coreclr-tc/testhost/xunit.performance.core.dll -r:/opt/usr/coreclr-tc/testhost/TraceReloggerLib.dll -r:/opt/usr/coreclr-tc/testhost/System.Security.Cryptography.OpenSsl.dll -r:/opt/usr/coreclr-tc/testhost/System.Reflection.Metadata.dll -r:/opt/usr/coreclr-tc/testhost/System.Threading.Thread.dll -r:/opt/usr/coreclr-tc/testhost/System.Composition.Convention.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Configuration.FileExtensions.dll -r:/opt/usr/coreclr-tc/testhost/System.Text.Json.dll -r:/opt/usr/coreclr-tc/testhost/WindowsBase.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.Http.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.Serialization.dll -r:/opt/usr/coreclr-tc/testhost/System.ServiceModel.Web.dll -r:/opt/usr/coreclr-tc/testhost/System.Diagnostics.PerformanceCounter.dll -r:/opt/usr/coreclr-tc/testhost/System.Composition.TypedParts.dll -r:/opt/usr/coreclr-tc/testhost/System.IO.Compression.Brotli.dll -r:/opt/usr/coreclr-tc/testhost/System.Security.AccessControl.dll -r:/opt/usr/coreclr-tc/testhost/System.DirectoryServices.Protocols.dll -r:/opt/usr/coreclr-tc/testhost/System.Xml.ReaderWriter.dll -r:/opt/usr/coreclr-tc/testhost/System.Drawing.Common.dll -r:/opt/usr/coreclr-tc/testhost/System.Data.Common.dll -r:/opt/usr/coreclr-tc/testhost/xunit.runner.utility.netcoreapp10.dll -r:/opt/usr/coreclr-tc/testhost/System.Security.Cryptography.Cng.dll -r:/opt/usr/coreclr-tc/testhost/System.Security.Cryptography.Algorithms.dll -r:/opt/usr/coreclr-tc/testhost/System.Linq.Queryable.dll -r:/opt/usr/coreclr-tc/testhost/System.Security.Cryptography.Primitives.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.Intrinsics.Experimental.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.Http.Json.dll -r:/opt/usr/coreclr-tc/testhost/System.IO.FileSystem.Primitives.dll -r:/opt/usr/coreclr-tc/testhost/System.Text.Encoding.Extensions.dll -r:/opt/usr/coreclr-tc/testhost/System.IO.Packaging.dll -r:/opt/usr/coreclr-tc/testhost/System.ComponentModel.EventBasedAsync.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.Security.dll -r:/opt/usr/coreclr-tc/testhost/System.ComponentModel.dll -r:/opt/usr/coreclr-tc/testhost/System.Data.OleDb.dll -r:/opt/usr/coreclr-tc/testhost/xunit.performance.metrics.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.WebSockets.Client.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Hosting.Abstractions.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.CompilerServices.VisualC.dll -r:/opt/usr/coreclr-tc/testhost/System.Private.Xml.dll -r:/opt/usr/coreclr-tc/testhost/System.Reflection.dll -r:/opt/usr/coreclr-tc/testhost/System.ComponentModel.DataAnnotations.dll -r:/opt/usr/coreclr-tc/testhost/crossgen2/Microsoft.DiaSymReader.dll -r:/opt/usr/coreclr-tc/testhost/crossgen2/crossgen2.dll -r:/opt/usr/coreclr-tc/testhost/crossgen2/ILCompiler.DependencyAnalysisFramework.dll -r:/opt/usr/coreclr-tc/testhost/crossgen2/System.CommandLine.dll -r:/opt/usr/coreclr-tc/testhost/crossgen2/ILCompiler.ReadyToRun.dll -r:/opt/usr/coreclr-tc/testhost/crossgen2/ILCompiler.TypeSystem.ReadyToRun.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.Primitives.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Caching.Abstractions.dll -r:/opt/usr/coreclr-tc/testhost/System.IO.IsolatedStorage.dll -r:/opt/usr/coreclr-tc/testhost/System.Reflection.Context.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Logging.TraceSource.dll -r:/opt/usr/coreclr-tc/testhost/System.DirectoryServices.AccountManagement.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.Serialization.Formatters.dll -r:/opt/usr/coreclr-tc/testhost/xunit.runner.reporters.netcoreapp10.dll -r:/opt/usr/coreclr-tc/testhost/System.Reflection.Emit.ILGeneration.dll -r:/opt/usr/coreclr-tc/testhost/System.Security.Principal.Windows.dll -r:/opt/usr/coreclr-tc/testhost/System.Resources.Extensions.dll -r:/opt/usr/coreclr-tc/testhost/System.Security.Cryptography.X509Certificates.dll -r:/opt/usr/coreclr-tc/testhost/System.ComponentModel.Primitives.dll -r:/opt/usr/coreclr-tc/testhost/System.Diagnostics.FileVersionInfo.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Logging.Configuration.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.WindowsRuntime.UI.Xaml.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Configuration.Abstractions.dll -r:/opt/usr/coreclr-tc/testhost/System.ComponentModel.Composition.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Configuration.Json.dll -r:/opt/usr/coreclr-tc/testhost/System.Private.Xml.Linq.dll -r:/opt/usr/coreclr-tc/testhost/System.Collections.dll -r:/opt/usr/coreclr-tc/testhost/System.IO.FileSystem.dll -r:/opt/usr/coreclr-tc/testhost/System.IO.Pipes.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.Sockets.dll -r:/opt/usr/coreclr-tc/testhost/System.ServiceModel.Syndication.dll -r:/opt/usr/coreclr-tc/testhost/System.Threading.dll -r:/opt/usr/coreclr-tc/testhost/System.ComponentModel.TypeConverter.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Logging.Debug.dll -r:/opt/usr/coreclr-tc/testhost/System.Xml.Serialization.dll -r:/opt/usr/coreclr-tc/testhost/System.dll -r:/opt/usr/coreclr-tc/testhost/System.Threading.Tasks.Extensions.dll -r:/opt/usr/coreclr-tc/testhost/System.ServiceProcess.ServiceController.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Logging.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Configuration.Binder.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Options.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Caching.Memory.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Logging.Abstractions.dll -r:/opt/usr/coreclr-tc/testhost/System.Globalization.Extensions.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.dll -r:/opt/usr/coreclr-tc/testhost/System.Threading.Tasks.Dataflow.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Configuration.EnvironmentVariables.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.Http.WinHttpHandler.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.FileSystemGlobbing.dll -r:/opt/usr/coreclr-tc/testhost/System.Security.Cryptography.Xml.dll -r:/opt/usr/coreclr-tc/testhost/CommandLine.dll -r:/opt/usr/coreclr-tc/testhost/System.Composition.Hosting.dll -r:/opt/usr/coreclr-tc/testhost/System.Diagnostics.DiagnosticSource.dll -r:/opt/usr/coreclr-tc/testhost/System.Threading.Tasks.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Diagnostics.FastSerialization.dll -r:/opt/usr/coreclr-tc/testhost/System.ComponentModel.Annotations.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Options.DataAnnotations.dll -r:/opt/usr/coreclr-tc/testhost/System.ObjectModel.dll -r:/opt/usr/coreclr-tc/testhost/System.Diagnostics.Contracts.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.WebSockets.dll -r:/opt/usr/coreclr-tc/testhost/System.Resources.ResourceManager.dll -r:/opt/usr/coreclr-tc/testhost/System.Diagnostics.TextWriterTraceListener.dll -r:/opt/usr/coreclr-tc/testhost/System.Xml.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Primitives.dll -r:/opt/usr/coreclr-tc/testhost/System.Xml.XDocument.dll -r:/opt/usr/coreclr-tc/testhost/System.Reflection.Primitives.dll -r:/opt/usr/coreclr-tc/testhost/System.Collections.NonGeneric.dll -r:/opt/usr/coreclr-tc/testhost/System.Collections.Immutable.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.WebProxy.dll -r:/opt/usr/coreclr-tc/testhost/System.IO.FileSystem.AccessControl.dll -r:/opt/usr/coreclr-tc/testhost/System.Reflection.Extensions.dll -r:/opt/usr/coreclr-tc/testhost/xunit.execution.dotnet.dll -r:/opt/usr/coreclr-tc/testhost/System.IO.Compression.dll -r:/opt/usr/coreclr-tc/testhost/Newtonsoft.Json.Bson.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.Extensions.dll -r:/opt/usr/coreclr-tc/testhost/System.Security.Permissions.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Win32.Registry.dll -r:/opt/usr/coreclr-tc/testhost/System.Buffers.dll -r:/opt/usr/coreclr-tc/testhost/System.Numerics.Vectors.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.Ping.dll -r:/opt/usr/coreclr-tc/testhost/System.ServiceProcess.dll -r:/opt/usr/coreclr-tc/testhost/System.Reflection.Emit.Lightweight.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.Requests.dll -r:/opt/usr/coreclr-tc/testhost/xunit.console.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Diagnostics.NETCore.Client.dll -r:/opt/usr/coreclr-tc/testhost/System.Linq.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.Logging.EventLog.dll -r:/opt/usr/coreclr-tc/testhost/System.Windows.Extensions.dll -r:/opt/usr/coreclr-tc/testhost/System.Resources.Writer.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.CodeAnalysis.CSharp.dll -r:/opt/usr/coreclr-tc/testhost/System.IO.FileSystem.Watcher.dll -r:/opt/usr/coreclr-tc/testhost/System.Net.ServicePoint.dll -r:/opt/usr/coreclr-tc/testhost/System.Dynamic.Runtime.dll -r:/opt/usr/coreclr-tc/testhost/System.Runtime.Caching.dll -r:/opt/usr/coreclr-tc/testhost/System.Management.dll -r:/opt/usr/coreclr-tc/testhost/System.Text.Encoding.CodePages.dll -r:/opt/usr/coreclr-tc/testhost/Microsoft.Extensions.FileProviders.Physical.dll -r:/opt/usr/coreclr-tc/testhost/System.Security.SecureString.dll -r:/opt/usr/coreclr-tc/testhost/System.Security.Cryptography.Csp.dll -r:/opt/usr/coreclr-tc/Loader/classloader/generics/regressions/237932/repro237932/IL/repro237932.dll
               Emitting R2R PE file: /opt/usr/coreclr-tc/Loader/classloader/generics/regressions/237932/repro237932/repro237932.dll
               /opt/usr/coreclr-tc/testhost/corerun repro237932.dll ''
               1
               1
               FAIL: Expected ThreadStatic field of both objects to be 1
               Expected: 100
               Actual: 101
               END EXECUTION - FAILED

NgenDisasm of Main():

; Assembly listing for method Test:Main():int
; Emitting BLENDED_CODE for generic ARM CPU - Unix
; ReadyToRun compilation
; debuggable code
; r11 based frame
; fully interruptible
; Final local variable assignments
;
;  V00 loc0         [V00    ] (  1,  1   )     ref  ->  [sp+0x1C]   must-init class-hnd exact
;  V01 loc1         [V01    ] (  1,  1   )     ref  ->  [sp+0x18]   must-init class-hnd exact
;  V02 loc2         [V02    ] (  1,  1   )    bool  ->  [sp+0x14]   must-init
;  V03 loc3         [V03    ] (  1,  1   )     int  ->  [sp+0x10]   must-init
;# V04 OutArgs      [V04    ] (  1,  1   )  lclBlk ( 0) [sp+0x00]   "OutgoingArgSpace"
;  V05 tmp1         [V05    ] (  1,  1   )     ref  ->  [sp+0x0C]   must-init class-hnd exact "NewObj constructor temp"
;  V06 tmp2         [V06    ] (  1,  1   )     ref  ->  [sp+0x08]   must-init class-hnd exact "NewObj constructor temp"
;  V07 tmp3         [V07    ] (  1,  1   )     int  ->  [sp+0x04]   must-init
;
; Lcl frame size = 32

G_M59477_IG01:
000000  E92D 4C10      push    {r4,r10,r11,lr}
000004  B088           sub     sp, 32
000006  F10D 0B28      add     r11, sp, 40
00000A  F1AB 0224      sub     r2, r11, 36
00000E  2000           movs    r0, 0
000010  2100           movs    r1, 0
000012  C203           stm     r2!, {r0,r1}
000014  C203           stm     r2!, {r0,r1}
000016  C203           stm     r2!, {r0,r1}
000018  6010           str     r0, [r2]
                        ;; bbWeight=1    PerfScore 10.00
G_M59477_IG02:
00001A  BF00           nop     
00001C  F240 0400      movw    r4, LOW RELOC 0x00420070
000020  F2C0 0400      movt    r4, HIGH RELOC 0x00420070
000024  447C           add     r4, pc
000026  6823           ldr     r3, [r4]
000028  4798           blx     r3       // CORINFO_HELP_READYTORUN_NEW
00002A  9003           str     r0, [sp+0x0c]    // [V05 tmp1]
00002C  9803           ldr     r0, [sp+0x0c]    // [V05 tmp1]
00002E  F240 0400      movw    r4, LOW RELOC 0x00420060
000032  F2C0 0400      movt    r4, HIGH RELOC 0x00420060
000036  447C           add     r4, pc
000038  6823           ldr     r3, [r4]
00003A  4798           blx     r3       // C1`1:.ctor():this
00003C  9B03           ldr     r3, [sp+0x0c]    // [V05 tmp1]
00003E  9307           str     r3, [sp+0x1c]    // [V00 loc0]
000040  F240 0400      movw    r4, LOW RELOC 0x00420090
000044  F2C0 0400      movt    r4, HIGH RELOC 0x00420090
000048  447C           add     r4, pc
00004A  6823           ldr     r3, [r4]
00004C  4798           blx     r3       // CORINFO_HELP_READYTORUN_NEW
00004E  9002           str     r0, [sp+0x08]    // [V06 tmp2]
000050  9802           ldr     r0, [sp+0x08]    // [V06 tmp2]
000052  F240 0400      movw    r4, LOW RELOC 0x00420080
000056  F2C0 0400      movt    r4, HIGH RELOC 0x00420080
00005A  447C           add     r4, pc
00005C  6823           ldr     r3, [r4]
00005E  4798           blx     r3       // C1`1:.ctor():this
000060  9B02           ldr     r3, [sp+0x08]    // [V06 tmp2]
000062  9306           str     r3, [sp+0x18]    // [V01 loc1]
000064  F240 0400      movw    r4, LOW RELOC 0x004200A0
000068  F2C0 0400      movt    r4, HIGH RELOC 0x004200A0
00006C  447C           add     r4, pc
00006E  6823           ldr     r3, [r4]
000070  4798           blx     r3       // CORINFO_HELP_READYTORUN_STATIC_BASE
000072  6803           ldr     r3, [r0]
000074  2B01           cmp     r3, 1
000076  D10E           bne     SHORT G_M59477_IG05
000078  F240 0400      movw    r4, LOW RELOC 0x004200D8
00007C  F2C0 0400      movt    r4, HIGH RELOC 0x004200D8
000080  447C           add     r4, pc
000082  6823           ldr     r3, [r4]
000084  4798           blx     r3       // CORINFO_HELP_READYTORUN_STATIC_BASE
000086  6800           ldr     r0, [r0]
000088  2801           cmp     r0, 1
00008A  D001           beq     SHORT G_M59477_IG03
00008C  2000           movs    r0, 0
00008E  E000           b       SHORT G_M59477_IG04
                        ;; bbWeight=1    PerfScore 47.00
G_M59477_IG03:
000090  2001           movs    r0, 1
                        ;; bbWeight=1    PerfScore 1.00
G_M59477_IG04:
000092  9001           str     r0, [sp+0x04]    // [V07 tmp3]
000094  E001           b       SHORT G_M59477_IG06
                        ;; bbWeight=1    PerfScore 2.00
G_M59477_IG05:
000096  2000           movs    r0, 0
000098  9001           str     r0, [sp+0x04]    // [V07 tmp3]
                        ;; bbWeight=1    PerfScore 2.00
G_M59477_IG06:
00009A  9801           ldr     r0, [sp+0x04]    // [V07 tmp3]
00009C  B2C0           uxtb    r0, r0
00009E  9005           str     r0, [sp+0x14]    // [V02 loc2]
0000A0  9805           ldr     r0, [sp+0x14]    // [V02 loc2]
0000A2  2800           cmp     r0, 0
0000A4  D013           beq     SHORT G_M59477_IG07
0000A6  BF00           nop     
0000A8  F240 0000      movw    r0, LOW RELOC 0x004200E0
0000AC  F2C0 0000      movt    r0, HIGH RELOC 0x004200E0
0000B0  4478           add     r0, pc
0000B2  6800           ldr     r0, [r0]
0000B4  6800           ldr     r0, [r0]
0000B6  F240 0400      movw    r4, LOW RELOC 0x004200C0
0000BA  F2C0 0400      movt    r4, HIGH RELOC 0x004200C0
0000BE  447C           add     r4, pc
0000C0  6823           ldr     r3, [r4]
0000C2  4798           blx     r3       // System.Console:WriteLine(string)
0000C4  BF00           nop     
0000C6  2064           movs    r0, 100
0000C8  9004           str     r0, [sp+0x10]    // [V03 loc3]
0000CA  BF00           nop     
0000CC  E013           b       SHORT G_M59477_IG08
                        ;; bbWeight=1    PerfScore 22.00
G_M59477_IG07:
0000CE  BF00           nop     
0000D0  F240 0000      movw    r0, LOW RELOC 0x004200E8
0000D4  F2C0 0000      movt    r0, HIGH RELOC 0x004200E8
0000D8  4478           add     r0, pc
0000DA  6800           ldr     r0, [r0]
0000DC  6800           ldr     r0, [r0]
0000DE  F240 0400      movw    r4, LOW RELOC 0x004200C0
0000E2  F2C0 0400      movt    r4, HIGH RELOC 0x004200C0
0000E6  447C           add     r4, pc
0000E8  6823           ldr     r3, [r4]
0000EA  4798           blx     r3       // System.Console:WriteLine(string)
0000EC  BF00           nop     
0000EE  2065           movs    r0, 101
0000F0  9004           str     r0, [sp+0x10]    // [V03 loc3]
0000F2  BF00           nop     
0000F4  E7FF           b       SHORT G_M59477_IG08
                        ;; bbWeight=1    PerfScore 16.00
G_M59477_IG08:
0000F6  9804           ldr     r0, [sp+0x10]    // [V03 loc3]
                        ;; bbWeight=1    PerfScore 1.00
G_M59477_IG09:
0000F8  B008           add     sp, 32
0000FA  E8BD 8C10      pop     {r4,r10,r11,pc}
                        ;; bbWeight=1    PerfScore 2.00

On 000072 return value loaded from [r0] but as we've found it's located in [r0-4]. So we looked to implementation of CORINFO_HELP_READYTORUN_STATIC_BASE to understand but cannot find it.

jkotas commented 4 years ago

CORINFO_HELP_READYTORUN_... helpers should be converted to fixup returned by getReadyToRunHelper method on JIT/EE interface.

t-mustafin commented 4 years ago

Where are CORINFO_HELP_READYTORUN_... helpers sources?

jkotas commented 4 years ago

They are not static helpers. They are created dynamically by DynamicHelperFixup method

t-mustafin commented 4 years ago

Thunk of CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE. crossgen1:

=> 0xb5903726:  push    {r4}
   0xb5903728:  movs    r4, #3
   0xb590372a:  push    {r4}
   0xb590372c:  movw    r4, #8192       ; 0x2000
   0xb5903730:  movt    r4, #46480      ; 0xb590
   0xb5903734:  ldr     r4, [r4, #0]
   0xb5903736:  push    {r4}
   0xb5903738:  movw    r4, #8204       ; 0x200c
   0xb590373c:  movt    r4, #46480      ; 0xb590
   0xb5903740:  ldr     r4, [r4, #0]
   0xb5903742:  bx      r4              ; call DelayLoad_Helper_FakeProlog

crossgen2:

=> 0xb456bbe0:  str.w   r4, [sp, #-4]!
   0xb456bbe4:  movs    r4, #2
   0xb456bbe6:  str.w   r4, [sp, #-4]!
   0xb456bbea:  movw    r4, #53496      ; 0xd0f8
   0xb456bbee:  movt    r4, #46167      ; 0xb457
   0xb456bbf2:  ldr     r4, [r4, #0]
   0xb456bbf4:  str.w   r4, [sp, #-4]!
   0xb456bbf8:  movw    r4, #53504      ; 0xd100
   0xb456bbfc:  movt    r4, #46167      ; 0xb457
   0xb456bc00:  ldr     r4, [r4, #0]
   0xb456bc02:  bx      r4              ; call DelayLoad_Helper_FakeProlog

crossgen2 for x64:

=> 0x00007fff7c950d00:  lea    0x10c39(%rip),%rax        # 0x7fff7c961940
   0x00007fff7c950d07:  pushq  $0x2
   0x00007fff7c950d09:  pushq  0x10bf1(%rip)        # 0x7fff7c961900
   0x00007fff7c950d0f:  jmpq   *0x10bfb(%rip)        # 0x7fff7c961910

It seems that in crossgen2 second argument sectionIndex should be 0x2.

t-mustafin commented 4 years ago

Stack in DelayLoad_Helper_FakeProlog on crossgen1:

#0  DynamicHelperFixup (pTransitionBlock=0xbeffec7c, pCell=0xb590201c, sectionIndex=3, 
    pModule=0xb45c8bac, pKind=0xbeffec2c, pTH=0xbeffec38, ppMD=0xbeffec34, ppFD=0xbeffec30)
    at /home/mustafin_t/dotnet/runtime2/src/coreclr/src/vm/prestub.cpp:3155
#1  0xb62faac0 in DynamicHelperWorker (pTransitionBlock=0xbeffec7c, pCell=0xb590201c, 
    sectionIndex=3, pModule=0xb45c8bac, frameFlags=0)
    at /home/mustafin_t/dotnet/runtime2/src/coreclr/src/vm/prestub.cpp:3484
#2  0xb648f78e in DelayLoad_Helper_FakeProlog ()
    at /home/mustafin_t/dotnet/runtime2/src/coreclr/src/vm/arm/asmhelpers.S:1123
#3  0xb5903862 in ?? ()

We got kind = ENCODE_THREAD_STATIC_BASE_NONGC_HELPER at src/coreclr/src/vm/prestub.cpp:3155:

(gdb) p/x kind
$2 = 0x24
(gdb) p/x ENCODE_THREAD_STATIC_BASE_NONGC_HELPER 
$5 = 0x24

Stack in DelayLoad_Helper_FakeProlog on crossgen2:

#0  DynamicHelperFixup (pTransitionBlock=0xbeffec7c, pCell=0xb457d118, sectionIndex=2, 
    pModule=0xb45c8bac, pKind=0xbeffec2c, pTH=0xbeffec38, ppMD=0xbeffec34, ppFD=0xbeffec30)
    at /home/mustafin_t/dotnet/runtime2/src/coreclr/src/vm/prestub.cpp:3155
#1  0xb62faac0 in DynamicHelperWorker (pTransitionBlock=0xbeffec7c, pCell=0xb457d118, 
    sectionIndex=2, pModule=0xb45c8bac, frameFlags=0)
    at /home/mustafin_t/dotnet/runtime2/src/coreclr/src/vm/prestub.cpp:3484
#2  0xb648f78e in DelayLoad_Helper_FakeProlog ()
    at /home/mustafin_t/dotnet/runtime2/src/coreclr/src/vm/arm/asmhelpers.S:1123
#3  0xb456b3b6 in ?? ()

We got kind = ENCODE_FIELD_ADDRESS at src/coreclr/src/vm/prestub.cpp:3155:

(gdb) p/x kind
$1 = 0x20
(gdb) p/x ENCODE_FIELD_ADDRESS 
$2 = 0x20

On crossgen2 x64 DynamicHelperFixup catches the same kind = 0x20 = ENCODE_FIELD_ADDRESS:

Thread 1 "corerun" hit Breakpoint 4, DynamicHelperFixup (pTransitionBlock=0x7fffffffd268, pCell=0x7fff7c961940, sectionIndex=<optimized out>, pModule=0x7fff7c9365e0, pKind=0x7fffffffd104, pTH=0x7fffffffd110, ppMD=0x7fffffffd0f0, ppFD=0x7fffffffd0f8) at /home/mustafin_t/dotnet/runtime2/src/coreclr/src/vm/prestub.cpp:3138
3138        switch (kind)
(gdb) p kind
$1 = 32 ' '
(gdb) s
3164            pFD = ZapSig::DecodeField(pModule, pInfoModule, pBlob, &th);
(gdb) bt
#0  DynamicHelperFixup (pTransitionBlock=0x7fffffffd268, pCell=0x7fff7c961940, sectionIndex=<optimized out>, pModule=<optimized out>, pKind=0x7fffffffd104, pTH=0x7fffffffd110, ppMD=0x7fffffffd0f0, ppFD=0x7fffffffd0f8) at /home/mustafin_t/dotnet/runtime2/src/coreclr/src/vm/prestub.cpp:3164
#1  0x00007ffff6425a78 in DynamicHelperWorker (pTransitionBlock=0x7fffffffd268, pCell=0x7fff7c961940, sectionIndex=2, pModule=0x7fff7c9365e0, frameFlags=<optimized out>) at /home/mustafin_t/dotnet/runtime2/src/coreclr/src/vm/prestub.cpp:3467
#2  0x00007ffff6545bf7 in DelayLoad_Helper () at /home/mustafin_t/dotnet/runtime2/src/coreclr/src/pal/inc/unixasmmacrosamd64.inc:837
#3  0x00007fff7c9505a7 in ?? ()
#4  0x00000000f642de98 in ?? ()
#5  0x00007fff5001e5d0 in ?? ()
#6  0x00007fff5001d8f0 in ?? ()
#7  0x0000000000000000 in ?? ()
t-mustafin commented 4 years ago

crossgen2 generates kind=ENCODE_FIELD_ADDRESS for CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE case, meanwile crossgen1 generates kind=ENCODE_THREAD_STATIC_BASE_NONGC_HELPER. Is it ok?

jkotas commented 4 years ago

cossgen2 generates kind=ENCODE_FIELD_ADDRESS for CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE case, meanwile crossgen1 generates kind=ENCODE_THREAD_STATIC_BASE_NONGC_HELPER. Is it ok?

It should still works correctly, but it suggests that we may have a performance bug with crossgen2. ENCODE_THREAD_STATIC_BASE_NONGC_HELPER is more efficient than ENCODE_FIELD_ADDRESS and so it should be preferred where possible.

cc @dotnet/crossgen-contrib @trylek

trylek commented 4 years ago

Hmm, I was under the impression that statics on generics are handled differently than non-generic statics using the four bases (GC, NON-GC, TLS GC, TLS NON-GC). Perhaps I'm just missing something, it's been a while since I last looked at that code.