[armel tizen] Fixed dynamic code allocation and code pitching for ARM (#16352)
authorsergey ignatov <sergign60@mail.ru>
Wed, 14 Feb 2018 22:35:21 +0000 (01:35 +0300)
committerBruce Forstall <brucefo@microsoft.com>
Wed, 14 Feb 2018 22:35:21 +0000 (14:35 -0800)
* [armel tizen] Fixed dynamic code allocation for ARM

* Added comment

* Used ThumbCodeToDataPointer

* Changed to PCODEToPINSTR

src/vm/codepitchingmanager.cpp
src/vm/dynamicmethod.cpp
src/vm/prestub.cpp

index 521c101..6a937fb 100644 (file)
@@ -241,7 +241,7 @@ static void LookupOrCreateInPitchingCandidate(MethodDesc* pMD, ULONG sizeOfCode)
             const char* szClassName = className.GetUTF8(scratch);
             const char* szMethodSig = methodSig.GetUTF8(scratch);
 
-            printf("Candidate %lld %s :: %s %s\n",
+            printf("Candidate %lu %s :: %s %s\n",
                    sizeOfCode, szClassName, pMD->GetName(), szMethodSig);
         }
 #endif
@@ -346,7 +346,7 @@ StackWalkAction StackWalkCallback(CrawlFrame* pCf, VOID* data)
     return CrawlFrameVisitor(pCf, (Thread *)data);
 }
 
-static ULONGLONG s_PitchedMethodCounter = 0;
+static ULONG s_PitchedMethodCounter = 0;
 void MethodDesc::PitchNativeCode()
 {
     WRAPPER_NO_CONTRACT;
@@ -383,7 +383,7 @@ void MethodDesc::PitchNativeCode()
     MethodTable * pMT = GetMethodTable();
     _ASSERTE(pMT != nullptr);
 
-    CodeHeader* pCH = ((CodeHeader*)(pCode & ~1)) - 1;
+    CodeHeader* pCH = dac_cast<PTR_CodeHeader>(PCODEToPINSTR(pCode)) - 1;
     _ASSERTE(pCH->GetMethodDesc() == this);
 
     HostCodeHeap* pHeap = HostCodeHeap::GetCodeHeap((TADDR)pCode);
@@ -436,11 +436,8 @@ void MethodDesc::PitchNativeCode()
         const char* szClassName = className.GetUTF8(scratch);
         const char* szMethodSig = methodSig.GetUTF8(scratch);
 
-        if (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_JitPitchPrintStat) != 0)
-        {
-            printf("Pitched %lld %lld %s :: %s %s\n",
-                   s_PitchedMethodCounter, pitchedBytes, szClassName, GetName(), szMethodSig);
-        }
+        printf("Pitched %lu %lu %s :: %s %s\n",
+               s_PitchedMethodCounter, pitchedBytes, szClassName, GetName(), szMethodSig);
     }
 
     DACNotify::DoJITPitchingNotification(this);
@@ -514,7 +511,7 @@ EXTERN_C void SavePitchingCandidate(MethodDesc* pMD, ULONG sizeOfCode)
         SimpleWriteLockHolder swlh(s_totalNCSizeLock);
         s_totalNCSize += sizeOfCode;
         if (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_JitPitchPrintStat) != 0)
-            printf("jitted %lld (bytes) pitched %lld (bytes)\n", s_totalNCSize, s_jitPitchedBytes);
+            printf("jitted %lu (bytes) pitched %lu (bytes)\n", s_totalNCSize, s_jitPitchedBytes);
     }
 }
 #endif
index c997565..806ab57 100644 (file)
@@ -795,7 +795,7 @@ struct HostCodeHeap::TrackAllocation * HostCodeHeap::GetTrackAllocation(TADDR co
 {
     LIMITED_METHOD_CONTRACT;
 
-    CodeHeader * pHdr = dac_cast<PTR_CodeHeader>(codeStart) - 1;
+    CodeHeader * pHdr = dac_cast<PTR_CodeHeader>(PCODEToPINSTR(codeStart)) - 1;
 
     // Pointer to the TrackAllocation record is stored just before the code header
     return *((TrackAllocation **)(pHdr) - 1);
index 7705dc0..5e9fc11 100644 (file)
@@ -887,7 +887,7 @@ PCODE MethodDesc::JitCompileCodeLocked(PrepareCodeConfig* pConfig, JitListLockEn
 #if defined(FEATURE_JIT_PITCHING)
         else
         {
-            SavePitchingCandidate(this, sizeOfCode);
+            SavePitchingCandidate(this, *pSizeOfCode);
         }
 #endif
     }