From: Jan Kotas Date: Sat, 13 Jan 2018 08:40:45 +0000 (-0800) Subject: Revert "Remove relocations for MethodTable::m_pParentMethodTable for Linux ARM" X-Git-Tag: accepted/tizen/base/20180629.140029~143^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2b197262e52b06719db5179cc42b55851874c88c;p=platform%2Fupstream%2Fcoreclr.git Revert "Remove relocations for MethodTable::m_pParentMethodTable for Linux ARM" This reverts commit cf1fb9e17fc8b6ee849edab5a696d0ec5c6eadd2. --- diff --git a/src/debug/daccess/nidump.cpp b/src/debug/daccess/nidump.cpp index b780405..274b1e7 100644 --- a/src/debug/daccess/nidump.cpp +++ b/src/debug/daccess/nidump.cpp @@ -5987,7 +5987,7 @@ PTR_MethodTable NativeImageDumper::GetParent( PTR_MethodTable mt ) /* REVISIT_TODO Thu 12/01/2005 * Handle fixups */ - PTR_MethodTable parent( ReadPointerMaybeNull((MethodTable *) mt, &MethodTable::m_pParentMethodTable) ); + PTR_MethodTable parent( mt->m_pParentMethodTable ); _ASSERTE(!CORCOMPILE_IS_POINTER_TAGGED(PTR_TO_TADDR(parent))); return parent; } @@ -6961,7 +6961,7 @@ NativeImageDumper::DumpMethodTable( PTR_MethodTable mt, const char * name, - PTR_MethodTable parent = ReadPointerMaybeNull((MethodTable *) mt, &MethodTable::m_pParentMethodTable); + PTR_MethodTable parent = mt->m_pParentMethodTable; if( parent == NULL ) { DisplayWriteFieldPointer( m_pParentMethodTable, NULL, MethodTable, diff --git a/src/vm/ceeload.cpp b/src/vm/ceeload.cpp index 504bf79..a80e7f6 100644 --- a/src/vm/ceeload.cpp +++ b/src/vm/ceeload.cpp @@ -10114,32 +10114,6 @@ void Module::RestoreMethodTablePointer(RelativeFixupPointer * p } } -/*static*/ -void Module::RestoreMethodTablePointer(PlainPointer * ppMT, - Module *pContainingModule, - ClassLoadLevel level) -{ - CONTRACTL - { - THROWS; - GC_TRIGGERS; - MODE_ANY; - } - CONTRACTL_END; - - if (ppMT->IsNull()) - return; - - if (ppMT->IsTagged()) - { - RestoreMethodTablePointerRaw(ppMT->GetValuePtr(), pContainingModule, level); - } - else - { - ClassLoader::EnsureLoaded(ppMT->GetValue(), level); - } -} - #endif // !DACCESS_COMPILE BOOL Module::IsZappedCode(PCODE code) diff --git a/src/vm/ceeload.h b/src/vm/ceeload.h index 62facce..03b31f5 100644 --- a/src/vm/ceeload.h +++ b/src/vm/ceeload.h @@ -2816,10 +2816,6 @@ public: ClassLoadLevel level = CLASS_LOADED); static void RestoreFieldDescPointer(RelativeFixupPointer * ppFD); - static void RestoreMethodTablePointer(PlainPointer * ppMT, - Module *pContainingModule = NULL, - ClassLoadLevel level = CLASS_LOADED); - static void RestoreModulePointer(RelativeFixupPointer * ppModule, Module *pContainingModule); static PTR_Module RestoreModulePointerIfLoaded(DPTR(RelativeFixupPointer) ppModule, Module *pContainingModule); diff --git a/src/vm/class.cpp b/src/vm/class.cpp index 9d82f77..99156ff 100644 --- a/src/vm/class.cpp +++ b/src/vm/class.cpp @@ -883,15 +883,7 @@ ClassLoader::LoadExactParentAndInterfacesTransitively(MethodTable *pMT) LOG((LF_CLASSLOADER, LL_INFO1000, "GENERICS: Replaced approximate parent %s with exact parent %s from token %x\n", pParentMT->GetDebugClassName(), pNewParentMT->GetDebugClassName(), crExtends)); // SetParentMethodTable is not used here since we want to update the indirection cell in the NGen case - if (pMT->GetParentMethodTablePlainOrRelativePointerPtr()->IsIndirectPtrMaybeNull()) - { - *EnsureWritablePages(pMT->GetParentMethodTablePlainOrRelativePointerPtr()->GetValuePtr()) = pNewParentMT; - } - else - { - EnsureWritablePages(pMT->GetParentMethodTablePlainOrRelativePointerPtr()); - pMT->GetParentMethodTablePlainOrRelativePointerPtr()->SetValueMaybeNull(pNewParentMT); - } + *EnsureWritablePages(pMT->GetParentMethodTablePtr()) = pNewParentMT; pParentMT = pNewParentMT; } diff --git a/src/vm/generics.cpp b/src/vm/generics.cpp index ed53132..83bcd86 100644 --- a/src/vm/generics.cpp +++ b/src/vm/generics.cpp @@ -364,7 +364,7 @@ ClassLoader::CreateTypeHandleForNonCanonicalGenericInstantiation( pMT->ClearFlag(MethodTable::enum_flag_IsZapped); pMT->ClearFlag(MethodTable::enum_flag_IsPreRestored); - pMT->m_pParentMethodTable.SetValueMaybeNull(NULL); + pMT->ClearFlag(MethodTable::enum_flag_HasIndirectParent); // Non non-virtual slots pMT->ClearFlag(MethodTable::enum_flag_HasSingleNonVirtualSlot); diff --git a/src/vm/jithelpers.cpp b/src/vm/jithelpers.cpp index 12f110c..9f887e6 100644 --- a/src/vm/jithelpers.cpp +++ b/src/vm/jithelpers.cpp @@ -2396,7 +2396,7 @@ HCIMPL2(Object*, JIT_ChkCastClass_Portable, MethodTable* pTargetMT, Object* pObj if (pMT == pTargetMT) return pObject; - pMT = MethodTable::GetParentMethodTable(pMT); + pMT = MethodTable::GetParentMethodTableOrIndirection(pMT); } while (pMT); ENDFORBIDGC(); @@ -2416,14 +2416,14 @@ HCIMPL2(Object*, JIT_ChkCastClassSpecial_Portable, MethodTable* pTargetMT, Objec PRECONDITION(pObject->GetMethodTable() != pTargetMT); } CONTRACTL_END; - PTR_VOID pMT = MethodTable::GetParentMethodTable(pObject->GetMethodTable()); + PTR_VOID pMT = MethodTable::GetParentMethodTableOrIndirection(pObject->GetMethodTable()); while (pMT) { if (pMT == pTargetMT) return pObject; - pMT = MethodTable::GetParentMethodTable(pMT); + pMT = MethodTable::GetParentMethodTableOrIndirection(pMT); } ENDFORBIDGC(); @@ -2450,7 +2450,7 @@ HCIMPL2(Object*, JIT_IsInstanceOfClass_Portable, MethodTable* pTargetMT, Object* if (pMT == pTargetMT) return pObject; - pMT = MethodTable::GetParentMethodTable(pMT); + pMT = MethodTable::GetParentMethodTableOrIndirection(pMT); } while (pMT); if (!pObject->GetMethodTable()->HasTypeEquivalence()) diff --git a/src/vm/methodtable.cpp b/src/vm/methodtable.cpp index 0b63e8a..24c69cf 100644 --- a/src/vm/methodtable.cpp +++ b/src/vm/methodtable.cpp @@ -1788,7 +1788,7 @@ TypeHandle::CastResult MethodTable::CanCastToClassNoGC(MethodTable *pTargetMT) if (pMT == pTargetMT) return TypeHandle::CanCast; - pMT = MethodTable::GetParentMethodTable(pMT); + pMT = MethodTable::GetParentMethodTableOrIndirection(pMT); } while (pMT); } @@ -4779,17 +4779,7 @@ void MethodTable::Fixup(DataImage *image) #endif // _DEBUG MethodTable * pParentMT = GetParentMethodTable(); - _ASSERTE(!pNewMT->m_pParentMethodTable.IsIndirectPtrMaybeNull()); - - ZapRelocationType relocType; - if (decltype(MethodTable::m_pParentMethodTable)::isRelative) - { - relocType = IMAGE_REL_BASED_RELPTR; - } - else - { - relocType = IMAGE_REL_BASED_PTR; - } + _ASSERTE(!pNewMT->GetFlag(enum_flag_HasIndirectParent)); if (pParentMT != NULL) { @@ -4801,8 +4791,7 @@ void MethodTable::Fixup(DataImage *image) { if (image->CanHardBindToZapModule(pParentMT->GetLoaderModule())) { - _ASSERTE(!m_pParentMethodTable.IsIndirectPtr()); - image->FixupField(this, offsetof(MethodTable, m_pParentMethodTable), pParentMT, 0, relocType); + image->FixupPointerField(this, offsetof(MethodTable, m_pParentMethodTable)); } else { @@ -4838,7 +4827,8 @@ void MethodTable::Fixup(DataImage *image) if (pImport != NULL) { - image->FixupFieldToNode(this, offsetof(MethodTable, m_pParentMethodTable), pImport, FIXUP_POINTER_INDIRECTION, relocType); + image->FixupFieldToNode(this, offsetof(MethodTable, m_pParentMethodTable), pImport, -(SSIZE_T)offsetof(MethodTable, m_pParentMethodTable)); + pNewMT->SetFlag(enum_flag_HasIndirectParent); } } @@ -6101,7 +6091,7 @@ void MethodTable::Restore() // // Restore parent method table // - Module::RestoreMethodTablePointer(&m_pParentMethodTable, GetLoaderModule(), CLASS_LOAD_APPROXPARENTS); + Module::RestoreMethodTablePointerRaw(GetParentMethodTablePtr(), GetLoaderModule(), CLASS_LOAD_APPROXPARENTS); // // Restore interface classes @@ -8156,8 +8146,13 @@ BOOL MethodTable::IsParentMethodTablePointerValid() if (!GetWriteableData_NoLogging()->IsParentMethodTablePointerValid()) return FALSE; - TADDR base = dac_cast(this) + offsetof(MethodTable, m_pParentMethodTable); - return !m_pParentMethodTable.IsTagged(base); + if (!GetFlag(enum_flag_HasIndirectParent)) + { + return TRUE; + } + TADDR pMT; + pMT = *PTR_TADDR(m_pParentMethodTable + offsetof(MethodTable, m_pParentMethodTable)); + return !CORCOMPILE_IS_POINTER_TAGGED(pMT); } #endif diff --git a/src/vm/methodtable.h b/src/vm/methodtable.h index e237ebe..0073a18 100644 --- a/src/vm/methodtable.h +++ b/src/vm/methodtable.h @@ -2177,12 +2177,6 @@ public: // THE METHOD TABLE PARENT (SUPERCLASS/BASE CLASS) // -#if defined(PLATFORM_UNIX) && defined(_TARGET_ARM_) - typedef RelativeFixupPointer ParentMT_t; -#else - typedef PlainPointer ParentMT_t; -#endif - BOOL HasApproxParent() { LIMITED_METHOD_DAC_CONTRACT; @@ -2201,24 +2195,32 @@ public: LIMITED_METHOD_DAC_CONTRACT; PRECONDITION(IsParentMethodTablePointerValid()); - return ReadPointerMaybeNull(this, &MethodTable::m_pParentMethodTable); + + TADDR pMT = m_pParentMethodTable; +#ifdef FEATURE_PREJIT + if (GetFlag(enum_flag_HasIndirectParent)) + pMT = *PTR_TADDR(m_pParentMethodTable + offsetof(MethodTable, m_pParentMethodTable)); +#endif + return PTR_MethodTable(pMT); } - inline static PTR_VOID GetParentMethodTable(PTR_VOID pMT) + inline static PTR_VOID GetParentMethodTableOrIndirection(PTR_VOID pMT) { - LIMITED_METHOD_DAC_CONTRACT; - - PTR_MethodTable pMethodTable = dac_cast(pMT); - return pMethodTable->GetParentMethodTable(); + WRAPPER_NO_CONTRACT; + return PTR_VOID(*PTR_TADDR(dac_cast(pMT) + offsetof(MethodTable, m_pParentMethodTable))); } -#ifndef DACCESS_COMPILE - inline ParentMT_t * GetParentMethodTablePlainOrRelativePointerPtr() + inline MethodTable ** GetParentMethodTablePtr() { - LIMITED_METHOD_CONTRACT; - return &m_pParentMethodTable; + WRAPPER_NO_CONTRACT; + +#ifdef FEATURE_PREJIT + return GetFlag(enum_flag_HasIndirectParent) ? + (MethodTable **)(m_pParentMethodTable + offsetof(MethodTable, m_pParentMethodTable)) :(MethodTable **)&m_pParentMethodTable; +#else + return (MethodTable **)&m_pParentMethodTable; +#endif } -#endif // !DACCESS_COMPILE // Is the parent method table pointer equal to the given argument? BOOL ParentEquals(PTR_MethodTable pMT) @@ -2237,8 +2239,8 @@ public: void SetParentMethodTable (MethodTable *pParentMethodTable) { LIMITED_METHOD_CONTRACT; - PRECONDITION(!m_pParentMethodTable.IsIndirectPtrMaybeNull()); - m_pParentMethodTable.SetValueMaybeNull(pParentMethodTable); + PRECONDITION(!GetFlag(enum_flag_HasIndirectParent)); + m_pParentMethodTable = (TADDR)pParentMethodTable; #ifdef _DEBUG GetWriteableDataForWrite_NoLogging()->SetParentMethodTablePointerValid(); #endif @@ -4141,7 +4143,7 @@ private: // if enum_flag_enum_flag_HasIndirectParent is set. The indirection is offset by offsetof(MethodTable, m_pParentMethodTable). // It allows casting helpers to go through parent chain natually. Casting helper do not need need the explicit check // for enum_flag_HasIndirectParentMethodTable. - ParentMT_t m_pParentMethodTable; + TADDR m_pParentMethodTable; RelativePointer m_pLoaderModule; // LoaderModule. It is equal to the ZapModule in ngened images diff --git a/src/vm/proftoeeinterfaceimpl.cpp b/src/vm/proftoeeinterfaceimpl.cpp index b9e5481..5daf127 100644 --- a/src/vm/proftoeeinterfaceimpl.cpp +++ b/src/vm/proftoeeinterfaceimpl.cpp @@ -7091,7 +7091,7 @@ HRESULT ProfToEEInterfaceImpl::GetClassLayout(ClassID classID, // running into - attempting to get the class layout for all types at module load time. // If we don't detect this the runtime will AV during the field iteration below. Feel // free to eliminate this check when a more complete solution is available. - if (typeHandle.AsMethodTable()->GetParentMethodTablePlainOrRelativePointerPtr()->IsTagged()) + if (CORCOMPILE_IS_POINTER_TAGGED(*(typeHandle.AsMethodTable()->GetParentMethodTablePtr()))) { return CORPROF_E_DATAINCOMPLETE; }