summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEgor Chesakov <Egor.Chesakov@microsoft.com>2018-09-26 19:47:18 -0700
committerGitHub <noreply@github.com>2018-09-26 19:47:18 -0700
commitbe18f2b4a7e0a4f7257df048e92d64a73035ed92 (patch)
tree00ebd49ac898ab0a9057f4271f89eacf0bc97590
parent24bbc37eb70895b6d7cc9cc95b8453742cdc0cae (diff)
downloadcoreclr-be18f2b4a7e0a4f7257df048e92d64a73035ed92.tar.gz
coreclr-be18f2b4a7e0a4f7257df048e92d64a73035ed92.tar.bz2
coreclr-be18f2b4a7e0a4f7257df048e92d64a73035ed92.zip
Cross-bitness in VTable Calls (#20137)
* Use TARGET_POINTER_SIZE in CEEInfo::getMethodVTableOffset in src/vm/jitinterface.cpp * Use SIZEOF__MethodTable_ in src/vm/methodtable.h
-rw-r--r--src/vm/jitinterface.cpp4
-rw-r--r--src/vm/methodtable.h8
2 files changed, 9 insertions, 3 deletions
diff --git a/src/vm/jitinterface.cpp b/src/vm/jitinterface.cpp
index 4bb52a78f0..64126089c3 100644
--- a/src/vm/jitinterface.cpp
+++ b/src/vm/jitinterface.cpp
@@ -8768,8 +8768,8 @@ void CEEInfo::getMethodVTableOffset (CORINFO_METHOD_HANDLE methodHnd,
// better be in the vtable
_ASSERTE(method->GetSlot() < method->GetMethodTable()->GetNumVirtuals());
- *pOffsetOfIndirection = MethodTable::GetVtableOffset() + MethodTable::GetIndexOfVtableIndirection(method->GetSlot()) * sizeof(MethodTable::VTableIndir_t);
- *pOffsetAfterIndirection = MethodTable::GetIndexAfterVtableIndirection(method->GetSlot()) * sizeof(MethodTable::VTableIndir2_t);
+ *pOffsetOfIndirection = MethodTable::GetVtableOffset() + MethodTable::GetIndexOfVtableIndirection(method->GetSlot()) * TARGET_POINTER_SIZE /* sizeof(MethodTable::VTableIndir_t) */;
+ *pOffsetAfterIndirection = MethodTable::GetIndexAfterVtableIndirection(method->GetSlot()) * TARGET_POINTER_SIZE /* sizeof(MethodTable::VTableIndir2_t) */;
*isRelative = MethodTable::VTableIndir_t::isRelative ? 1 : 0;
_ASSERTE(MethodTable::VTableIndir_t::isRelative == MethodTable::VTableIndir2_t::isRelative);
diff --git a/src/vm/methodtable.h b/src/vm/methodtable.h
index 38ce20ee0a..2e9241242e 100644
--- a/src/vm/methodtable.h
+++ b/src/vm/methodtable.h
@@ -33,6 +33,7 @@
#include "contractimpl.h"
#include "generics.h"
#include "fixuppointer.h"
+#include "gcinfotypes.h"
/*
* Forward Declarations
@@ -1802,11 +1803,13 @@ public:
return pMTParent == NULL ? 0 : pMTParent->GetNumVirtuals();
}
+ #define SIZEOF__MethodTable_ (0x10 + (6 INDEBUG(+1)) * TARGET_POINTER_SIZE)
+
static inline DWORD GetVtableOffset()
{
LIMITED_METHOD_DAC_CONTRACT;
- return (sizeof(MethodTable));
+ return SIZEOF__MethodTable_;
}
// Return total methods: virtual, static, and instance method slots.
@@ -4430,6 +4433,9 @@ public:
}; // class MethodTable
+#ifndef CROSSBITNESS_COMPILE
+static_assert_no_msg(sizeof(MethodTable) == SIZEOF__MethodTable_);
+#endif
#if defined(FEATURE_COMINTEROP) && !defined(DACCESS_COMPILE)
WORD GetEquivalentMethodSlot(MethodTable * pOldMT, MethodTable * pNewMT, WORD wMTslot, BOOL *pfFound);
#endif // defined(FEATURE_COMINTEROP) && !defined(DACCESS_COMPILE)