diff options
author | Konstantin Baladurin <k.baladurin@partner.samsung.com> | 2018-04-26 17:34:58 +0300 |
---|---|---|
committer | Vladislav Andresov <v.andresov@partner.samsung.com> | 2018-04-26 20:04:15 +0300 |
commit | 371df401e4d8c9639035d164710d1246e0cb8548 (patch) | |
tree | b550f3433a68c80a1ff952413b7b7a0e3ab97995 /packaging/0023-Remove-relocations-for-MethodTable-m_pWriteableData-.patch | |
parent | 5e7a310b1a251937154d05cd52637ac62b6d5edc (diff) | |
download | coreclr-accepted/tizen_4.0_unified.tar.gz coreclr-accepted/tizen_4.0_unified.tar.bz2 coreclr-accepted/tizen_4.0_unified.zip |
Add memory optimization patches from upstreamsubmit/tizen_4.0/20180427.011218accepted/tizen/4.0/unified/20180427.062437accepted/tizen_4.0_unified
Change-Id: Ie8ea75fa60184b77135289c8fdc0f49d40b49d87
Diffstat (limited to 'packaging/0023-Remove-relocations-for-MethodTable-m_pWriteableData-.patch')
-rw-r--r-- | packaging/0023-Remove-relocations-for-MethodTable-m_pWriteableData-.patch | 207 |
1 files changed, 207 insertions, 0 deletions
diff --git a/packaging/0023-Remove-relocations-for-MethodTable-m_pWriteableData-.patch b/packaging/0023-Remove-relocations-for-MethodTable-m_pWriteableData-.patch new file mode 100644 index 0000000000..f8b8321f3f --- /dev/null +++ b/packaging/0023-Remove-relocations-for-MethodTable-m_pWriteableData-.patch @@ -0,0 +1,207 @@ +From 74f3dd15eada76e26fd74c2ec8db5076a7d4b86f Mon Sep 17 00:00:00 2001 +From: Gleb Balykov <g.balykov@samsung.com> +Date: Thu, 22 Jun 2017 20:39:03 +0300 +Subject: [PATCH 23/32] Remove relocations for MethodTable::m_pWriteableData + for Linux ARM + +--- + src/debug/daccess/nidump.cpp | 2 +- + src/vm/methodtable.cpp | 26 ++++++++++++++------------ + src/vm/methodtable.h | 23 +++++++++++++++-------- + src/vm/methodtable.inl | 2 +- + src/vm/methodtablebuilder.cpp | 2 +- + 5 files changed, 32 insertions(+), 23 deletions(-) + +diff --git a/src/debug/daccess/nidump.cpp b/src/debug/daccess/nidump.cpp +index 673aa39..04d610e 100644 +--- a/src/debug/daccess/nidump.cpp ++++ b/src/debug/daccess/nidump.cpp +@@ -7045,7 +7045,7 @@ NativeImageDumper::DumpMethodTable( PTR_MethodTable mt, const char * name, + DPtrToPreferredAddr(mt->GetLoaderModule()), + MethodTable, METHODTABLES ); + +- PTR_MethodTableWriteableData wd = mt->m_pWriteableData; ++ PTR_MethodTableWriteableData wd = ReadPointer((MethodTable *)mt, &MethodTable::m_pWriteableData); + _ASSERTE(wd != NULL); + DisplayStartStructureWithOffset( m_pWriteableData, DPtrToPreferredAddr(wd), + sizeof(*wd), MethodTable, METHODTABLES ); +diff --git a/src/vm/methodtable.cpp b/src/vm/methodtable.cpp +index b849746..e93f63d 100644 +--- a/src/vm/methodtable.cpp ++++ b/src/vm/methodtable.cpp +@@ -4832,8 +4832,8 @@ void MethodTable::Fixup(DataImage *image) + } + + _ASSERTE(GetWriteableData()); +- image->FixupPointerField(this, offsetof(MethodTable, m_pWriteableData)); +- m_pWriteableData->Fixup(image, this, needsRestore); ++ image->FixupPlainOrRelativePointerField(this, &MethodTable::m_pWriteableData); ++ m_pWriteableData.GetValue()->Fixup(image, this, needsRestore); + + #ifdef FEATURE_COMINTEROP + if (HasGuidInfo()) +@@ -5074,12 +5074,12 @@ void MethodTable::Fixup(DataImage *image) + + if (NeedsCrossModuleGenericsStaticsInfo()) + { +- MethodTableWriteableData * pNewWriteableData = (MethodTableWriteableData *)image->GetImagePointer(m_pWriteableData); ++ MethodTableWriteableData * pNewWriteableData = (MethodTableWriteableData *)image->GetImagePointer(m_pWriteableData.GetValue()); + CrossModuleGenericsStaticsInfo * pNewCrossModuleGenericsStaticsInfo = pNewWriteableData->GetCrossModuleGenericsStaticsInfo(); + + pNewCrossModuleGenericsStaticsInfo->m_DynamicTypeID = pInfo->m_DynamicTypeID; + +- image->ZeroPointerField(m_pWriteableData, sizeof(MethodTableWriteableData) + offsetof(CrossModuleGenericsStaticsInfo, m_pModuleForStatics)); ++ image->ZeroPointerField(m_pWriteableData.GetValue(), sizeof(MethodTableWriteableData) + offsetof(CrossModuleGenericsStaticsInfo, m_pModuleForStatics)); + + pNewMT->SetFlag(enum_flag_StaticsMask_IfGenericsThenCrossModule); + } +@@ -9194,9 +9194,10 @@ MethodTable::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) + DacEnumMemoryRegion(dac_cast<TADDR>(it.GetIndirectionSlot()), it.GetSize()); + } + +- if (m_pWriteableData.IsValid()) ++ PTR_MethodTableWriteableData pWriteableData = ReadPointer(this, &MethodTable::m_pWriteableData); ++ if (pWriteableData.IsValid()) + { +- m_pWriteableData.EnumMem(); ++ pWriteableData.EnumMem(); + } + + if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE) +@@ -9659,8 +9660,6 @@ bool MethodTable::ClassRequiresUnmanagedCodeCheck() + return false; + } + +-#endif // !DACCESS_COMPILE +- + + + BOOL MethodTable::Validate() +@@ -9670,13 +9669,14 @@ BOOL MethodTable::Validate() + ASSERT_AND_CHECK(SanityCheck()); + + #ifdef _DEBUG +- if (m_pWriteableData == NULL) ++ if (m_pWriteableData.IsNull()) + { + _ASSERTE(IsAsyncPinType()); + return TRUE; + } + +- DWORD dwLastVerifiedGCCnt = m_pWriteableData->m_dwLastVerifedGCCnt; ++ MethodTableWriteableData *pWriteableData = m_pWriteableData.GetValue(); ++ DWORD dwLastVerifiedGCCnt = pWriteableData->m_dwLastVerifedGCCnt; + // Here we used to assert that (dwLastVerifiedGCCnt <= GCHeapUtilities::GetGCHeap()->GetGcCount()) but + // this is no longer true because with background gc. Since the purpose of having + // m_dwLastVerifedGCCnt is just to only verify the same method table once for each GC +@@ -9707,13 +9707,15 @@ BOOL MethodTable::Validate() + #ifdef _DEBUG + // It is not a fatal error to fail the update the counter. We will run slower and retry next time, + // but the system will function properly. +- if (EnsureWritablePagesNoThrow(m_pWriteableData, sizeof(MethodTableWriteableData))) +- m_pWriteableData->m_dwLastVerifedGCCnt = GCHeapUtilities::GetGCHeap()->GetGcCount(); ++ if (EnsureWritablePagesNoThrow(pWriteableData, sizeof(MethodTableWriteableData))) ++ pWriteableData->m_dwLastVerifedGCCnt = GCHeapUtilities::GetGCHeap()->GetGcCount(); + #endif //_DEBUG + + return TRUE; + } + ++#endif // !DACCESS_COMPILE ++ + NOINLINE BYTE *MethodTable::GetLoaderAllocatorObjectForGC() + { + WRAPPER_NO_CONTRACT; +diff --git a/src/vm/methodtable.h b/src/vm/methodtable.h +index ef0cb44..63d35e6 100644 +--- a/src/vm/methodtable.h ++++ b/src/vm/methodtable.h +@@ -3148,36 +3148,39 @@ public: + // Private part of MethodTable + // ------------------------------------------------------------------ + ++#ifndef DACCESS_COMPILE + inline void SetWriteableData(PTR_MethodTableWriteableData pMTWriteableData) + { + LIMITED_METHOD_CONTRACT; + _ASSERTE(pMTWriteableData); +- m_pWriteableData = pMTWriteableData; ++ m_pWriteableData.SetValue(pMTWriteableData); + } +- ++#endif ++ + inline PTR_Const_MethodTableWriteableData GetWriteableData() const + { + LIMITED_METHOD_DAC_CONTRACT; + g_IBCLogger.LogMethodTableWriteableDataAccess(this); +- return m_pWriteableData; ++ return GetWriteableData_NoLogging(); + } + + inline PTR_Const_MethodTableWriteableData GetWriteableData_NoLogging() const + { + LIMITED_METHOD_DAC_CONTRACT; +- return m_pWriteableData; ++ return ReadPointer(this, &MethodTable::m_pWriteableData); + } + + inline PTR_MethodTableWriteableData GetWriteableDataForWrite() + { +- LIMITED_METHOD_CONTRACT; ++ LIMITED_METHOD_DAC_CONTRACT; + g_IBCLogger.LogMethodTableWriteableDataWriteAccess(this); +- return m_pWriteableData; ++ return GetWriteableDataForWrite_NoLogging(); + } + + inline PTR_MethodTableWriteableData GetWriteableDataForWrite_NoLogging() + { +- return m_pWriteableData; ++ LIMITED_METHOD_DAC_CONTRACT; ++ return ReadPointer(this, &MethodTable::m_pWriteableData); + } + + //------------------------------------------------------------------- +@@ -4076,7 +4079,11 @@ private: + + RelativePointer<PTR_Module> m_pLoaderModule; // LoaderModule. It is equal to the ZapModule in ngened images + +- PTR_MethodTableWriteableData m_pWriteableData; ++#if defined(PLATFORM_UNIX) && defined(_TARGET_ARM_) ++ RelativePointer<PTR_MethodTableWriteableData> m_pWriteableData; ++#else ++ PlainPointer<PTR_MethodTableWriteableData> m_pWriteableData; ++#endif + + // The value of lowest two bits describe what the union contains + enum LowBits { +diff --git a/src/vm/methodtable.inl b/src/vm/methodtable.inl +index eb1abb0..4c808ee 100644 +--- a/src/vm/methodtable.inl ++++ b/src/vm/methodtable.inl +@@ -1737,7 +1737,7 @@ FORCEINLINE PTR_Module MethodTable::GetGenericsStaticsModuleAndID(DWORD * pID) + _ASSERTE(!IsStringOrArray()); + if (m_dwFlags & enum_flag_StaticsMask_IfGenericsThenCrossModule) + { +- CrossModuleGenericsStaticsInfo *pInfo = m_pWriteableData->GetCrossModuleGenericsStaticsInfo(); ++ CrossModuleGenericsStaticsInfo *pInfo = ReadPointer(this, &MethodTable::m_pWriteableData)->GetCrossModuleGenericsStaticsInfo(); + _ASSERTE(FitsIn<DWORD>(pInfo->m_DynamicTypeID) || pInfo->m_DynamicTypeID == (SIZE_T)-1); + *pID = static_cast<DWORD>(pInfo->m_DynamicTypeID); + return pInfo->m_pModuleForStatics; +diff --git a/src/vm/methodtablebuilder.cpp b/src/vm/methodtablebuilder.cpp +index e8f3b9c..5d77463 100644 +--- a/src/vm/methodtablebuilder.cpp ++++ b/src/vm/methodtablebuilder.cpp +@@ -10215,7 +10215,7 @@ MethodTable * MethodTableBuilder::AllocateNewMT(Module *pLoaderModule, + } + + #ifdef _DEBUG +- pMT->m_pWriteableData->m_dwLastVerifedGCCnt = (DWORD)-1; ++ pMT->m_pWriteableData.GetValue()->m_dwLastVerifedGCCnt = (DWORD)-1; + #endif // _DEBUG + + RETURN(pMT); +-- +2.7.4 + |