Update logic in arm CodeGen::genCallInstruction to match xarch version (dotnet/corecl...
authorJan Kotas <jkotas@microsoft.com>
Fri, 15 Sep 2017 04:03:52 +0000 (21:03 -0700)
committerGitHub <noreply@github.com>
Fri, 15 Sep 2017 04:03:52 +0000 (21:03 -0700)
This is makes it work for CoreRT, and faster for everybody (avoids JIT/EE call).

Commit migrated from https://github.com/dotnet/coreclr/commit/ee12aaff992267334598c02b92eeaa78c6f9d284

src/coreclr/src/jit/codegenarmarch.cpp
src/coreclr/src/jit/codegenxarch.cpp

index f9081e8..3883121 100644 (file)
@@ -2105,48 +2105,27 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
         assert(callType == CT_HELPER || callType == CT_USER_FUNC);
 
         void* addr = nullptr;
-        if (callType == CT_HELPER)
-        {
-// Direct call to a helper method.
 #ifdef FEATURE_READYTORUN_COMPILER
-            if (call->gtEntryPoint.addr != NULL)
-            {
-                addr = call->gtEntryPoint.addr;
-                assert(call->gtEntryPoint.accessType == IAT_VALUE);
-            }
-            else
+        if (call->gtEntryPoint.addr != NULL)
+        {
+            assert(call->gtEntryPoint.accessType == IAT_VALUE);
+            addr = call->gtEntryPoint.addr;
+        }
+        else
 #endif // FEATURE_READYTORUN_COMPILER
-            {
-                CorInfoHelpFunc helperNum = compiler->eeGetHelperNum(methHnd);
-                noway_assert(helperNum != CORINFO_HELP_UNDEF);
-
-                void* pAddr = nullptr;
-                addr        = compiler->compGetHelperFtn(helperNum, (void**)&pAddr);
+            if (callType == CT_HELPER)
+        {
+            CorInfoHelpFunc helperNum = compiler->eeGetHelperNum(methHnd);
+            noway_assert(helperNum != CORINFO_HELP_UNDEF);
 
-                if (addr == nullptr)
-                {
-                    addr = pAddr;
-                }
-            }
+            void* pAddr = nullptr;
+            addr        = compiler->compGetHelperFtn(helperNum, (void**)&pAddr);
+            assert(pAddr == nullptr);
         }
         else
         {
             // Direct call to a non-virtual user function.
-            CORINFO_ACCESS_FLAGS aflags = CORINFO_ACCESS_ANY;
-            if (call->IsSameThis())
-            {
-                aflags = (CORINFO_ACCESS_FLAGS)(aflags | CORINFO_ACCESS_THIS);
-            }
-
-            if ((call->NeedsNullCheck()) == 0)
-            {
-                aflags = (CORINFO_ACCESS_FLAGS)(aflags | CORINFO_ACCESS_NONNULL);
-            }
-
-            CORINFO_CONST_LOOKUP addrInfo;
-            compiler->info.compCompHnd->getFunctionEntryPoint(methHnd, &addrInfo, aflags);
-
-            addr = addrInfo.addr;
+            addr = call->gtDirectCallAddress;
         }
 
         assert(addr != nullptr);
index 8e772e2..45bcdc2 100644 (file)
@@ -5508,11 +5508,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
 
             void* pAddr = nullptr;
             addr        = compiler->compGetHelperFtn(helperNum, (void**)&pAddr);
-
-            if (addr == nullptr)
-            {
-                addr = pAddr;
-            }
+            assert(pAddr == nullptr);
 
             // tracking of region protected by the monitor in synchronized methods
             if (compiler->info.compFlags & CORINFO_FLG_SYNCH)
@@ -5526,6 +5522,8 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
             addr = call->gtDirectCallAddress;
         }
 
+        assert(addr != nullptr);
+
         // Non-virtual direct calls to known addresses
 
         // clang-format off