From: Egor Chesakov Date: Thu, 17 May 2018 02:49:18 +0000 (-0700) Subject: Replace sizeof(TADDR) with TARGET_POINTER_SIZE in Zap (#18028) X-Git-Tag: accepted/tizen/unified/20190422.045933~2127 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c128ae89c062236ec5437bc3ed11aefcc52c360;p=platform%2Fupstream%2Fcoreclr.git Replace sizeof(TADDR) with TARGET_POINTER_SIZE in Zap (#18028) --- diff --git a/src/zap/common.h b/src/zap/common.h index 0abb2ce..3db0b84 100644 --- a/src/zap/common.h +++ b/src/zap/common.h @@ -33,6 +33,7 @@ #include "corcompile.h" #include "iceefilegen.h" #include "corpriv.h" +#include "gcinfotypes.h" #include "holder.h" #include "strongname.h" diff --git a/src/zap/zapcode.cpp b/src/zap/zapcode.cpp index 8d41222..1c3cd83 100644 --- a/src/zap/zapcode.cpp +++ b/src/zap/zapcode.cpp @@ -1676,7 +1676,7 @@ void ZapColdCodeMap::Save(ZapWriter* pZapWriter) DWORD ZapHelperThunk::GetSize() { - return (m_dwHelper & CORCOMPILE_HELPER_PTR) ? sizeof(TADDR) : HELPER_TABLE_ENTRY_LEN; + return (m_dwHelper & CORCOMPILE_HELPER_PTR) ? TARGET_POINTER_SIZE : HELPER_TABLE_ENTRY_LEN; } void ZapHelperThunk::Save(ZapWriter * pZapWriter) diff --git a/src/zap/zapcode.h b/src/zap/zapcode.h index 2fe949e..1e78051 100644 --- a/src/zap/zapcode.h +++ b/src/zap/zapcode.h @@ -792,7 +792,7 @@ public: virtual UINT GetAlignment() { - return sizeof(TADDR); + return TARGET_POINTER_SIZE; } virtual ZapNodeType GetType() @@ -829,7 +829,7 @@ public: } virtual UINT GetAlignment() { - return sizeof(TADDR); + return TARGET_POINTER_SIZE; } virtual DWORD GetSize(); virtual void Save(ZapWriter* pZapWriter); diff --git a/src/zap/zapimage.cpp b/src/zap/zapimage.cpp index 07e512c..cca4d58 100644 --- a/src/zap/zapimage.cpp +++ b/src/zap/zapimage.cpp @@ -158,7 +158,7 @@ void ZapImage::InitializeSections() m_pUnwindDataTable = new (GetHeap()) ZapUnwindDataTable(this); #endif - m_pEEInfoTable = ZapBlob::NewAlignedBlob(this, NULL, sizeof(CORCOMPILE_EE_INFO_TABLE), sizeof(TADDR)); + m_pEEInfoTable = ZapBlob::NewAlignedBlob(this, NULL, sizeof(CORCOMPILE_EE_INFO_TABLE), TARGET_POINTER_SIZE); m_pEETableSection->Place(m_pEEInfoTable); // @@ -331,7 +331,7 @@ void ZapImage::AllocateVirtualSections() m_pPreloadSections[CORCOMPILE_SECTION_RVA_STATICS_HOT] = NewVirtualSection(pDataSection, IBCProfiledSection | HotRange | RVAStaticsSection); - m_pDelayLoadInfoTableSection[ZapImportSectionType_Eager] = NewVirtualSection(pDataSection, IBCUnProfiledSection | HotRange | DelayLoadInfoTableEagerSection, sizeof(TADDR)); + m_pDelayLoadInfoTableSection[ZapImportSectionType_Eager] = NewVirtualSection(pDataSection, IBCUnProfiledSection | HotRange | DelayLoadInfoTableEagerSection, TARGET_POINTER_SIZE); // // Allocate dynamic info tables @@ -340,12 +340,12 @@ void ZapImage::AllocateVirtualSections() // Place the HOT CorCompileTables now, the cold ones would be placed later in this routine (after other HOT sections) for (int i=0; im_pOpt->m_compilerFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_BBINSTR)) { - m_pInstrumentSection = NewVirtualSection(pDataSection, IBCUnProfiledSection | ColdRange | InstrumentSection, sizeof(TADDR)); + m_pInstrumentSection = NewVirtualSection(pDataSection, IBCUnProfiledSection | ColdRange | InstrumentSection, TARGET_POINTER_SIZE); } } @@ -419,14 +419,14 @@ void ZapImage::AllocateVirtualSections() m_pHelperTableSection = NewVirtualSection(pXDataSection, IBCProfiledSection | HotColdSortedRange| HelperTableSection, HELPER_TABLE_ALIGN); // hot for writing, i.e. profiling has indicated a write to this item, so at least one write likely per item at some point - m_pPreloadSections[CORCOMPILE_SECTION_METHOD_PRECODE_WRITE] = NewVirtualSection(pXDataSection, IBCProfiledSection | HotRange | MethodPrecodeWriteSection, sizeof(TADDR)); - m_pPreloadSections[CORCOMPILE_SECTION_METHOD_PRECODE_HOT] = NewVirtualSection(pXDataSection, IBCProfiledSection | HotRange | MethodPrecodeSection, sizeof(TADDR)); + m_pPreloadSections[CORCOMPILE_SECTION_METHOD_PRECODE_WRITE] = NewVirtualSection(pXDataSection, IBCProfiledSection | HotRange | MethodPrecodeWriteSection, TARGET_POINTER_SIZE); + m_pPreloadSections[CORCOMPILE_SECTION_METHOD_PRECODE_HOT] = NewVirtualSection(pXDataSection, IBCProfiledSection | HotRange | MethodPrecodeSection, TARGET_POINTER_SIZE); // // cold sections // - m_pPreloadSections[CORCOMPILE_SECTION_METHOD_PRECODE_COLD] = NewVirtualSection(pXDataSection, IBCProfiledSection | ColdRange | MethodPrecodeSection, sizeof(TADDR)); - m_pPreloadSections[CORCOMPILE_SECTION_METHOD_PRECODE_COLD_WRITEABLE] = NewVirtualSection(pXDataSection, IBCProfiledSection | ColdRange | MethodPrecodeWriteableSection, sizeof(TADDR)); + m_pPreloadSections[CORCOMPILE_SECTION_METHOD_PRECODE_COLD] = NewVirtualSection(pXDataSection, IBCProfiledSection | ColdRange | MethodPrecodeSection, TARGET_POINTER_SIZE); + m_pPreloadSections[CORCOMPILE_SECTION_METHOD_PRECODE_COLD_WRITEABLE] = NewVirtualSection(pXDataSection, IBCProfiledSection | ColdRange | MethodPrecodeWriteableSection, TARGET_POINTER_SIZE); } { @@ -520,8 +520,8 @@ void ZapImage::AllocateVirtualSections() // actually find any duplicates and put those in a small section. For the rest, where there wasn't a duplicate in the entire image, we leave the // singleton in its normal place in the READONLY_HOT section, which was selected carefully by IBC. // - m_pPreloadSections[CORCOMPILE_SECTION_READONLY_SHARED_HOT] = NewVirtualSection(pTextSection, IBCProfiledSection | HotRange | ReadonlySharedSection, sizeof(TADDR)); - m_pPreloadSections[CORCOMPILE_SECTION_READONLY_HOT] = NewVirtualSection(pTextSection, IBCProfiledSection | HotRange | ReadonlySection, sizeof(TADDR)); + m_pPreloadSections[CORCOMPILE_SECTION_READONLY_SHARED_HOT] = NewVirtualSection(pTextSection, IBCProfiledSection | HotRange | ReadonlySharedSection, TARGET_POINTER_SIZE); + m_pPreloadSections[CORCOMPILE_SECTION_READONLY_HOT] = NewVirtualSection(pTextSection, IBCProfiledSection | HotRange | ReadonlySection, TARGET_POINTER_SIZE); // // GC Info for methods which were touched during profiling but didn't explicitly have @@ -571,8 +571,8 @@ void ZapImage::AllocateVirtualSections() m_pUnwindDataSection = NewVirtualSection(pTextSection, IBCProfiledSection | WarmRange | ColdRange | UnwindDataSection, sizeof(DWORD)); #endif // defined(WIN64EXCEPTIONS) - m_pPreloadSections[CORCOMPILE_SECTION_READONLY_WARM] = NewVirtualSection(pTextSection, IBCProfiledSection | WarmRange | ReadonlySection, sizeof(TADDR)); - m_pPreloadSections[CORCOMPILE_SECTION_READONLY_VCHUNKS_AND_DICTIONARY] = NewVirtualSection(pTextSection, IBCProfiledSection | WarmRange | ReadonlySection, sizeof(TADDR)); + m_pPreloadSections[CORCOMPILE_SECTION_READONLY_WARM] = NewVirtualSection(pTextSection, IBCProfiledSection | WarmRange | ReadonlySection, TARGET_POINTER_SIZE); + m_pPreloadSections[CORCOMPILE_SECTION_READONLY_VCHUNKS_AND_DICTIONARY] = NewVirtualSection(pTextSection, IBCProfiledSection | WarmRange | ReadonlySection, TARGET_POINTER_SIZE); // // GC Info for methods which were not touched in profiling @@ -581,7 +581,7 @@ void ZapImage::AllocateVirtualSections() m_pDelayLoadInfoDelayListSectionCold = NewVirtualSection(pTextSection, IBCProfiledSection | ColdRange | DelayLoadInfoDelayListSection, sizeof(DWORD)); - m_pPreloadSections[CORCOMPILE_SECTION_READONLY_COLD] = NewVirtualSection(pTextSection, IBCProfiledSection | ColdRange | ReadonlySection, sizeof(TADDR)); + m_pPreloadSections[CORCOMPILE_SECTION_READONLY_COLD] = NewVirtualSection(pTextSection, IBCProfiledSection | ColdRange | ReadonlySection, TARGET_POINTER_SIZE); // // Allocate the cold code section near the end of the image diff --git a/src/zap/zapimport.cpp b/src/zap/zapimport.cpp index 1b6d6b5..49ec137 100644 --- a/src/zap/zapimport.cpp +++ b/src/zap/zapimport.cpp @@ -128,16 +128,16 @@ static const struct ImportSectionProperties BYTE Type; BYTE EntrySize; WORD Flags; -} +} c_ImportSectionProperties[ZapImportSectionType_Count] = { - { /* ZapImportSectionType_Handle, */ CORCOMPILE_IMPORT_TYPE_UNKNOWN, 0, 0 }, - { /* ZapImportSectionType_TypeHandle, */ CORCOMPILE_IMPORT_TYPE_TYPE_HANDLE, sizeof(TADDR), 0 }, - { /* ZapImportSectionType_MethodHandle, */ CORCOMPILE_IMPORT_TYPE_METHOD_HANDLE, sizeof(TADDR), 0 }, + { /* ZapImportSectionType_Handle, */ CORCOMPILE_IMPORT_TYPE_UNKNOWN, 0, 0 }, + { /* ZapImportSectionType_TypeHandle, */ CORCOMPILE_IMPORT_TYPE_TYPE_HANDLE, TARGET_POINTER_SIZE, 0 }, + { /* ZapImportSectionType_MethodHandle, */ CORCOMPILE_IMPORT_TYPE_METHOD_HANDLE, TARGET_POINTER_SIZE, 0 }, #ifdef _TARGET_ARM_ - { /* ZapImportSectionType_PCode, */ CORCOMPILE_IMPORT_TYPE_UNKNOWN, 0, CORCOMPILE_IMPORT_FLAGS_PCODE }, + { /* ZapImportSectionType_PCode, */ CORCOMPILE_IMPORT_TYPE_UNKNOWN, 0, CORCOMPILE_IMPORT_FLAGS_PCODE }, #endif - { /* ZapImportSectionType_StringHandle, */ CORCOMPILE_IMPORT_TYPE_STRING_HANDLE, sizeof(TADDR), 0 }, + { /* ZapImportSectionType_StringHandle, */ CORCOMPILE_IMPORT_TYPE_STRING_HANDLE, TARGET_POINTER_SIZE, 0 }, }; void ZapImportTable::PlaceImport(ZapImport * pImport) @@ -229,8 +229,8 @@ void ZapImportTable::PlaceFixups(ZapImport ** pImports, NibbleWriter& writer) int tableIndex = pImport->GetSectionIndex(); unsigned offset = pImport->GetOffset(); - _ASSERTE(offset % sizeof(SIZE_T) == 0); - offset /= sizeof(SIZE_T); + _ASSERTE(offset % TARGET_POINTER_SIZE == 0); + offset /= TARGET_POINTER_SIZE; if (tableIndex != curTableIndex) { @@ -607,12 +607,12 @@ public: virtual DWORD GetSize() { - return sizeof(TADDR); + return TARGET_POINTER_SIZE; } virtual UINT GetAlignment() { - return sizeof(TADDR); + return TARGET_POINTER_SIZE; } virtual ZapNodeType GetType() @@ -661,7 +661,7 @@ void ZapImportSectionSignatures::PlaceStubDispatchCell(ZapImport * pImport) if (m_pImportSection->GetNodeCount() == 0) { m_dwIndex = m_pImage->GetImportSectionsTable()->Append(CORCOMPILE_IMPORT_TYPE_STUB_DISPATCH, CORCOMPILE_IMPORT_FLAGS_PCODE, - sizeof(TADDR), m_pImportSection, this, m_pGCRefMapTable); + TARGET_POINTER_SIZE, m_pImportSection, this, m_pGCRefMapTable); } #ifdef FEATURE_READYTORUN_COMPILER @@ -706,12 +706,12 @@ public: virtual DWORD GetSize() { - return sizeof(TADDR); + return TARGET_POINTER_SIZE; } virtual UINT GetAlignment() { - return sizeof(TADDR); + return TARGET_POINTER_SIZE; } virtual ZapNodeType GetType() @@ -763,7 +763,7 @@ void ZapImportSectionSignatures::PlaceExternalMethodCell(ZapImport * pImport) if (m_pImportSection->GetNodeCount() == 0) { m_dwIndex = m_pImage->GetImportSectionsTable()->Append(CORCOMPILE_IMPORT_TYPE_STUB_DISPATCH, CORCOMPILE_IMPORT_FLAGS_PCODE, - sizeof(TADDR), m_pImportSection, this, m_pGCRefMapTable); + TARGET_POINTER_SIZE, m_pImportSection, this, m_pGCRefMapTable); } #ifdef FEATURE_READYTORUN_COMPILER @@ -1320,7 +1320,7 @@ public: virtual DWORD GetSize() { - return 2 * sizeof(TADDR); + return 2 * TARGET_POINTER_SIZE; } virtual void Save(ZapWriter * pZapWriter) @@ -1440,7 +1440,7 @@ public: virtual DWORD GetSize() { // fixup cell, 3 pointers to interception method (Enter/Leave/Tailcall) and opaque handle - return kZapProfilingHandleImportValueIndexCount * sizeof(TADDR); + return kZapProfilingHandleImportValueIndexCount * TARGET_POINTER_SIZE; } virtual void Save(ZapWriter * pZapWriter) @@ -1682,12 +1682,12 @@ public: virtual DWORD GetSize() { - return sizeof(TADDR); + return TARGET_POINTER_SIZE; } virtual UINT GetAlignment() { - return sizeof(TADDR); + return TARGET_POINTER_SIZE; } virtual ZapNodeType GetType() @@ -1773,7 +1773,7 @@ void ZapImportSectionSignatures::PlaceDynamicHelperCell(ZapImport * pImport) if (m_pImportSection->GetNodeCount() == 0) { m_dwIndex = m_pImage->GetImportSectionsTable()->Append(CORCOMPILE_IMPORT_TYPE_UNKNOWN, CORCOMPILE_IMPORT_FLAGS_PCODE, - sizeof(TADDR), m_pImportSection, this, m_pGCRefMapTable); + TARGET_POINTER_SIZE, m_pImportSection, this, m_pGCRefMapTable); } // Create the delay load helper diff --git a/src/zap/zapimport.h b/src/zap/zapimport.h index 3ab9a27..81646f3 100644 --- a/src/zap/zapimport.h +++ b/src/zap/zapimport.h @@ -88,12 +88,12 @@ public: virtual DWORD GetSize() { - return sizeof(TADDR); + return TARGET_POINTER_SIZE; } virtual UINT GetAlignment() { - return sizeof(TADDR); + return TARGET_POINTER_SIZE; } virtual void Save(ZapWriter * pZapWriter); diff --git a/src/zap/zapinfo.cpp b/src/zap/zapinfo.cpp index 16281d7..005c562 100644 --- a/src/zap/zapinfo.cpp +++ b/src/zap/zapinfo.cpp @@ -1070,7 +1070,7 @@ void ZapInfo::allocMem( } else if (optForSize || (roDataSize < 8)) { - align = sizeof(TADDR); + align = TARGET_POINTER_SIZE; } else { @@ -1741,13 +1741,13 @@ void * ZapInfo::getHelperFtn (CorInfoHelpFunc ftnNum, void **ppIndirection) switch (ftnNum) { case CORINFO_HELP_PROF_FCN_ENTER: - *ppIndirection = m_pImage->GetInnerPtr(GetProfilingHandleImport(), kZapProfilingHandleImportValueIndexEnterAddr * sizeof(TADDR)); + *ppIndirection = m_pImage->GetInnerPtr(GetProfilingHandleImport(), kZapProfilingHandleImportValueIndexEnterAddr * TARGET_POINTER_SIZE); return NULL; case CORINFO_HELP_PROF_FCN_LEAVE: - *ppIndirection = m_pImage->GetInnerPtr(GetProfilingHandleImport(), kZapProfilingHandleImportValueIndexLeaveAddr * sizeof(TADDR)); + *ppIndirection = m_pImage->GetInnerPtr(GetProfilingHandleImport(), kZapProfilingHandleImportValueIndexLeaveAddr * TARGET_POINTER_SIZE); return NULL; case CORINFO_HELP_PROF_FCN_TAILCALL: - *ppIndirection = m_pImage->GetInnerPtr(GetProfilingHandleImport(), kZapProfilingHandleImportValueIndexTailcallAddr * sizeof(TADDR)); + *ppIndirection = m_pImage->GetInnerPtr(GetProfilingHandleImport(), kZapProfilingHandleImportValueIndexTailcallAddr * TARGET_POINTER_SIZE); return NULL; #ifdef _TARGET_AMD64_ case CORINFO_HELP_STOP_FOR_GC: @@ -2036,7 +2036,7 @@ void ZapInfo::GetProfilingHandle(BOOL *pbHookFunction, // // Profiling handle is opaque token. It does not have to be aligned thus we can not store it in the same location as token. // - *pProfilerHandle = m_pImage->GetInnerPtr(GetProfilingHandleImport(), kZapProfilingHandleImportValueIndexClientData * sizeof(TADDR)); + *pProfilerHandle = m_pImage->GetInnerPtr(GetProfilingHandleImport(), kZapProfilingHandleImportValueIndexClientData * TARGET_POINTER_SIZE); // All functions get hooked in ngen /Profile *pbHookFunction = TRUE; @@ -2314,7 +2314,7 @@ void * ZapInfo::getFieldAddress(CORINFO_FIELD_HANDLE field, void **ppIndirection AppendConditionalImport(pImport); // Field address is not aligned thus we can not store it in the same location as token. - *ppIndirection = m_pImage->GetInnerPtr(pImport, sizeof(TADDR)); + *ppIndirection = m_pImage->GetInnerPtr(pImport, TARGET_POINTER_SIZE); return NULL; } @@ -2614,7 +2614,7 @@ void ZapInfo::recordRelocation(void *location, void *target, SIZE_T totalCodeSize = m_pCode->GetSize() + ((m_pColdCode != NULL) ? m_pColdCode->GetSize() : 0); // Prealocate relocations (assume that every other pointer may need relocation) - COUNT_T nEstimatedRelocations = (COUNT_T)(totalCodeSize / (2 * sizeof(TADDR))); + COUNT_T nEstimatedRelocations = (COUNT_T)(totalCodeSize / (2 * TARGET_POINTER_SIZE)); if (nEstimatedRelocations > 1) m_CodeRelocations.Preallocate(nEstimatedRelocations); } diff --git a/src/zap/zaprelocs.cpp b/src/zap/zaprelocs.cpp index 059d9a59..3718f2c 100644 --- a/src/zap/zaprelocs.cpp +++ b/src/zap/zaprelocs.cpp @@ -46,7 +46,7 @@ void ZapBaseRelocs::WriteReloc(PVOID pSrc, int offset, ZapNode * pTarget, int ta case IMAGE_REL_BASED_PTR: #ifdef _TARGET_ARM_ // Misaligned relocs disable ASLR on ARM. We should never ever emit them. - _ASSERTE(IS_ALIGNED(rva, sizeof(TADDR))); + _ASSERTE(IS_ALIGNED(rva, TARGET_POINTER_SIZE)); #endif *(UNALIGNED TADDR *)pLocation = pActualTarget; break; @@ -350,7 +350,7 @@ COUNT_T ZapBlobWithRelocs::GetCountOfStraddlerRelocations(DWORD dwPos) { if (pReloc->m_type == IMAGE_REL_BASED_PTR) { - if (AlignmentTrim(dwPos + pReloc->m_offset, RELOCATION_PAGE_SIZE) > RELOCATION_PAGE_SIZE - sizeof(TADDR)) + if (AlignmentTrim(dwPos + pReloc->m_offset, RELOCATION_PAGE_SIZE) > RELOCATION_PAGE_SIZE - TARGET_POINTER_SIZE) nStraddlers++; } }