Unimplemented CORINFO_HELP_READYTORUN_* helpers on 32-bit arm arch
Backtrace:
Unhandled Exception: System.NotImplementedException: CORINFO_HELP_READYTORUN_NEWARR_1
at Internal.JitInterface.CorInfoImpl.GetHelperFtnUncached(CorInfoHelpFunc ftnNum)
at Internal.JitInterface.CorInfoImpl.getHelperFtn(CorInfoHelpFunc ftnNum, Void*& ppIndirection)
at Internal.JitInterface.CorInfoImpl._getHelperFtn(IntPtr thisHandle, IntPtr* ppException, CorInfoHelpFunc ftnNum, Void*& ppIndirection)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Internal.JitInterface.CorInfoImpl.CompileMethod(IMethodCodeNode methodCodeNodeNeedingCode, MethodIL methodIL)
at ILCompiler.RyuJitCompilation.ComputeDependencyNodeDependencies(List`1 obj)
at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeDependencies(List`1 deferredStaticDependencies)
at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes()
at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.get_MarkedNodeList()
at ILCompiler.RyuJitCompilation.CompileInternal(String outputFile, ObjectDumper dumper)
at ILCompiler.Compilation.ILCompiler.ICompilation.Compile(String outputFile, ObjectDumper dumper)
at ILCompiler.Program.Run(String[] args)
at ILCompiler.Program.Main(String[] args)
Any ideas how to implement it?
@jkotas please take a look
I would not expect you to hit the exception here. I would expect you to hit the NYI here instead: https://github.com/dotnet/corert/blob/master/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/Target_ARM/ARMReadyToRunHelperNode.cs#L57 . Are you using the true RyuJIT or the legacy JIT? It may have something to do with that. Could you please look into it and share what you find?
Also, we have been using these ReadyToRun helpers as bring up aid. They are unnecessary overhead for full static AOT like CoreRT. We are about to start getting rid of them and get their code inlined by the JIT instead. Depending on what you find, it maybe better for your ARM effort to just go directly for the non-ReadyToRun path.
@Dmitri-Botcharnikov @sergign60
I think it's RyuJIT, in CoreCLR I checked the flag LEGACY_BACKEND, it's false. I run it on arm target by command: corerun ilc.dll some.ilc.rsp corerun from CoreCLR, ilc.dll from CoreRT. It uses libclrjit.so and libclrjitilc.so libraries. Also, I tried to disable the FEATURE_READYTORUN option in all CoreCLR. The error with READYTORUN disappeared but the process began to crash earlier, when it compiles NullTextWriter::WriteLine method. The backtrace is:
#0 0xae5c1b5e in DBG_DebugBreak () from libclrjitilc.so
#1 0xae521fb6 in DebugBreak () at coreclr/src/pal/src/debug/debug.cpp:404
#2 0xae34c686 in assertAbort (why=0xae5f4def "(!value) != (!pValue)", file=0xae5f42d0 "coreclr/src/jit/gentree.cpp", line=6638)
at coreclr/src/jit/error.cpp:289
#3 0xae38c756 in Compiler::gtNewIconEmbHndNode (this=0x12aa18, value=0x0, pValue=0x0, flags=536870912, handle1=0, handle2=0x0, compileTimeHandle=0xcccccccc)
at coreclr/src/jit/gentree.cpp:6638
#4 0xae3b48a6 in Compiler::impLookupToTree (this=0x12aa18, pResolvedToken=0xbeffd9fc, pLookup=0xbeffc1c0, handleFlags=536870912, compileTimeHandle=0xcccccccc)
at coreclr/src/jit/importer.cpp:1781
#5 0xae3b47bc in Compiler::impTokenToHandle (this=0x12aa18, pResolvedToken=0xbeffd9fc, pRuntimeLookup=0x0, mustRestoreHandle=1, importParent=0)
at coreclr/src/jit/importer.cpp:1755
#6 0xae3cdd0e in Compiler::impImportBlockCode (this=<error reading variable: Cannot access memory at address 0xccccdd0c>,
block=<error reading variable: Cannot access memory at address 0xccccdd08>) at coreclr/src/jit/importer.cpp:13718
Backtrace stopped: Cannot access memory at address 0xcccccce0
Now I'm trying to find out what's wrong. Also, the CoreCLR doesn't compile if the FEATURE_READYTORUN option is disabled everywhere. I fixed some errors with it and can create pull request, if it can be useful.
I fixed some errors with it and can create pull request, if it can be useful.
Yes, it would be nice if the changes are simple enough.
With disabled READYTORUN feature in CoreCLR, I fixed some new bugs, and got next crash with "unknown shared statics helper" from fgGetStaticsCCtorHelper function in CoreCLR/src/jit/flowgraph.cpp. This is due to the fact that CoreRT in getFieldInfo function in CoreRT/src/JitInterface/src/CorInfoImpl.cs sets helper as:
// The JIT wants to know how to access a static field on a generic type. We need a runtime lookup.
fieldAccessor = CORINFO_FIELD_ACCESSOR.CORINFO_FIELD_STATIC_READYTORUN_HELPER;
pResult.helper = CorInfoHelpFunc.CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE;
Is there a way around this? There are no compile flags in the CoreRT to disable the READYTORUN feature. Or maybe there is no other way than to enable READYTORUN feature back in CoreCLR on and try to work with it? @jkotas please take a look
When I tried to use the latest corerun toolchain with disabled FEATURE_READYTORUN in CoreRT on x64 I got the following error on the Hello test
./corerun ./ilc.dll @Hello.ilc.rsp
Unhandled Exception: System.NotImplementedException: getClassDomainID
at Internal.JitInterface.CorInfoImpl.getClassDomainID(CORINFO_CLASS_STRUCT_* cls, Void*& ppIndirection)
at Internal.JitInterface.CorInfoImpl._getClassDomainID(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls, Void*& ppIndirection)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Internal.JitInterface.CorInfoImpl.CompileMethod(IMethodCodeNode methodCodeNodeNeedingCode, MethodIL methodIL)
at ILCompiler.RyuJitCompilation.ComputeDependencyNodeDependencies(List`1 obj)
at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeDependencies(List`1 deferredStaticDependencies)
at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes()
at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.get_MarkedNodeList()
at ILCompiler.RyuJitCompilation.CompileInternal(String outputFile, ObjectDumper dumper)
at ILCompiler.Compilation.ILCompiler.ICompilation.Compile(String outputFile, ObjectDumper dumper)
at ILCompiler.Program.Run(String[] args)
at ILCompiler.Program.Main(String[] args)
Process 17201 stopped
* thread #1: tid = 17201, 0x00007ffff6d81428 libc.so.6`__GI_raise(sig=6) + 56 at raise.c:54, name = 'corerun', stop reason = signal SIGABRT
frame #0: 0x00007ffff6d81428 libc.so.6`__GI_raise(sig=6) + 56 at raise.c:54
used diffs in coreclr
diff --git a/clrdefinitions.cmake b/clrdefinitions.cmake
index 7fb653773..58ef098ce 100644
--- a/clrdefinitions.cmake
+++ b/clrdefinitions.cmakeFEATURE_READYTORUNFEATURE_READYTORUNFEATURE_READYTORUN
@@ -160,8 +160,8 @@ endif(CLR_CMAKE_PLATFORM_LINUX)
add_definitions(-DFEATURE_PREJIT)
add_definitions(-DFEATURE_RANDOMIZED_STRING_HASHING)
-add_definitions(-DFEATURE_READYTORUN)
-set(FEATURE_READYTORUN 1)
+#add_definitions(-DFEATURE_READYTORUN)
+#set(FEATURE_READYTORUN 1)
if (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
add_definitions(-DFEATURE_REJIT)
with READYTORUN the test is compiled successfully.
Getting the non-ReadyToRun path inlined by the JIT is not about disabling FEATURE_READYTORUN when compiling the JIT. The JIT can be compiled with FEATURE_READYTORUN just fine for this. Not passing CORJIT_FLAG_READYTORUN flag to the JIT has the same effect as compiling the JIT with FEATURE_READYTORUN disabled. I am sorry for the confusion.
Getting the non-ReadyToRun path inlined by the JIT is about going over all ReadyToRun to helpers and replace them with inline expansion in the JIT.
For example, the virtual calls of regular virtual methods have to return CORINFO_VIRTUALCALL_VTABLE from getCallInfo, and the JIT needs to generate the right code for it that dereferences the right vtable slot.
Let's focus on details how to get the regular virtual method calls inlined by the JIT to make progress on this.
cc @PeterSolMS
I am much obliged to you for your help during the recent feedbacks. I'll try to deal with all this ;-)
@MichalStrehovsky and @PeterSolMS are going to look into this in the upcoming days. It requires some refactoring that would be hard for you to do without context. Could you please wait for their work?
#3773 is the first step.
@jkotas "Are you using the true RyuJIT or the legacy JIT?" @BredPet @Dmitri-Botcharnikov
As I see we are using legacy JIT now for armel tizen, in particular getHelperFtn for CORINFO_HELP_READYTORUN_NEWARR_1 is called from CodeGen::genCodeForCall from codegenlegacy.cpp
https://github.com/dotnet/coreclr/pull/12104
https://github.com/dotnet/coreclr/pull/13777