return pEntryPoint;
}
-BOOL ReadyToRunInfo::MethodIterator::Next()
-{
- CONTRACTL
- {
- GC_TRIGGERS;
- THROWS;
- MODE_ANY;
- }
- CONTRACTL_END;
-
- while (++m_methodDefIndex < (int)m_pInfo->m_methodDefEntryPoints.GetCount())
- {
- uint offset;
- if (m_pInfo->m_methodDefEntryPoints.TryGetAt(m_methodDefIndex, &offset))
- return TRUE;
- }
- return FALSE;
-}
-
-MethodDesc * ReadyToRunInfo::MethodIterator::GetMethodDesc()
-{
- STANDARD_VM_CONTRACT;
-
- return MemberLoader::GetMethodDescFromMethodDef(m_pInfo->m_pModule, mdtMethodDef | (m_methodDefIndex + 1), FALSE);
-}
-
-MethodDesc * ReadyToRunInfo::MethodIterator::GetMethodDesc_NoRestore()
-{
- CONTRACTL
- {
- GC_TRIGGERS;
- THROWS;
- MODE_ANY;
- }
- CONTRACTL_END;
-
- uint offset;
- if (!m_pInfo->m_methodDefEntryPoints.TryGetAt(m_methodDefIndex, &offset))
- {
- return NULL;
- }
- uint id;
- offset = m_pInfo->m_nativeReader.DecodeUnsigned(offset, &id);
-
- if (id & 1)
- {
- if (id & 2)
- {
- uint val;
- m_pInfo->m_nativeReader.DecodeUnsigned(offset, &val);
- offset -= val;
- }
-
- id >>= 2;
- }
- else
- {
- id >>= 1;
- }
-
- _ASSERTE(id < m_pInfo->m_nRuntimeFunctions);
- PCODE pEntryPoint = dac_cast<TADDR>(m_pInfo->m_pLayout->GetBase()) + m_pInfo->m_pRuntimeFunctions[id].BeginAddress;
-
- return m_pInfo->GetMethodDescForEntryPoint(pEntryPoint);
-}
-
-PCODE ReadyToRunInfo::MethodIterator::GetMethodStartAddress()
+void ReadyToRunInfo::MethodIterator::ParseGenericMethodSignatureAndRid(uint *pOffset, RID *pRid)
{
- STANDARD_VM_CONTRACT;
-
- PCODE ret = m_pInfo->GetEntryPoint(GetMethodDesc(), NULL, FALSE);
- _ASSERTE(ret != NULL);
- return ret;
-}
-
-BOOL ReadyToRunInfo::GenericMethodIterator::Next()
-{
- m_current = m_enum.GetNext();
- return !m_current.IsNull();
-}
-
-MethodDesc *ReadyToRunInfo::GenericMethodIterator::GetMethodDesc_NoRestore()
-{
- _ASSERTE(!m_current.IsNull());
+ _ASSERTE(!m_genericParser.IsNull());
HRESULT hr = S_OK;
+ *pOffset = -1;
+ *pRid = -1;
- PCCOR_SIGNATURE pBlob = (PCCOR_SIGNATURE)m_current.GetBlob();
+ PCCOR_SIGNATURE pBlob = (PCCOR_SIGNATURE)m_genericParser.GetBlob();
SigPointer sig(pBlob);
DWORD methodFlags = 0;
hr = sig.GetData(&methodFlags);
if (FAILED(hr))
{
- return NULL;
+ return;
}
if (methodFlags & ENCODE_METHOD_SIG_OwnerType)
hr = sig.SkipExactlyOne();
if (FAILED(hr))
{
- return NULL;
+ return;
}
}
_ASSERTE((methodFlags & ENCODE_METHOD_SIG_SlotInsteadOfToken) == 0);
_ASSERTE((methodFlags & ENCODE_METHOD_SIG_MemberRefToken) == 0);
- RID rid;
- hr = sig.GetData(&rid);
+ hr = sig.GetData(pRid);
if (FAILED(hr))
{
- return NULL;
+ return;
}
if (methodFlags & ENCODE_METHOD_SIG_MethodInstantiation)
hr = sig.GetData(&numGenericArgs);
if (FAILED(hr))
{
- return NULL;
+ return;
}
for (DWORD i = 0; i < numGenericArgs; i++)
hr = sig.SkipExactlyOne();
if (FAILED(hr))
{
- return NULL;
+ return;
}
}
}
PCCOR_SIGNATURE pSigNew;
DWORD cbSigNew;
sig.GetSignature(&pSigNew, &cbSigNew);
- uint offset = m_current.GetOffset() + (uint)(pSigNew - pBlob);
+
+ m_genericCurrentSig = pBlob;
+ *pOffset = m_genericParser.GetOffset() + (uint)(pSigNew - pBlob);
+}
+
+BOOL ReadyToRunInfo::MethodIterator::Next()
+{
+ CONTRACTL
+ {
+ GC_TRIGGERS;
+ THROWS;
+ MODE_ANY;
+ }
+ CONTRACTL_END;
+
+ // Enumerate non-generic methods
+ while (++m_methodDefIndex < (int)m_pInfo->m_methodDefEntryPoints.GetCount())
+ {
+ uint offset;
+ if (m_pInfo->m_methodDefEntryPoints.TryGetAt(m_methodDefIndex, &offset))
+ {
+ return TRUE;
+ }
+ }
+
+ // Enumerate generic instantiations
+ m_genericParser = m_genericEnum.GetNext();
+ if (!m_genericParser.IsNull())
+ {
+ ParseGenericMethodSignatureAndRid(&m_genericCurrentOffset, &m_genericCurrentRid);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+MethodDesc * ReadyToRunInfo::MethodIterator::GetMethodDesc()
+{
+ STANDARD_VM_CONTRACT;
+
+ mdMethodDef methodToken = mdTokenNil;
+ if (m_methodDefIndex < (int)m_pInfo->m_methodDefEntryPoints.GetCount())
+ {
+ methodToken = mdtMethodDef | (m_methodDefIndex + 1);
+ return MemberLoader::GetMethodDescFromMethodDef(m_pInfo->m_pModule, methodToken, FALSE);
+ }
+ else
+ {
+ _ASSERTE(m_genericCurrentOffset > 0 && m_genericCurrentSig != NULL);
+ return ZapSig::DecodeMethod(m_pInfo->m_pModule, m_pInfo->m_pModule, m_genericCurrentSig);
+ }
+}
+
+MethodDesc * ReadyToRunInfo::MethodIterator::GetMethodDesc_NoRestore()
+{
+ CONTRACTL
+ {
+ GC_TRIGGERS;
+ THROWS;
+ MODE_ANY;
+ }
+ CONTRACTL_END;
+
+ uint offset;
+ if (m_methodDefIndex < (int)m_pInfo->m_methodDefEntryPoints.GetCount())
+ {
+ if (!m_pInfo->m_methodDefEntryPoints.TryGetAt(m_methodDefIndex, &offset))
+ {
+ return NULL;
+ }
+ }
+ else
+ {
+ if (m_genericCurrentOffset <= 0)
+ {
+ // Failed to parse generic info.
+ return NULL;
+ }
+
+ offset = m_genericCurrentOffset;
+ }
+
uint id;
offset = m_pInfo->m_nativeReader.DecodeUnsigned(offset, &id);
return m_pInfo->GetMethodDescForEntryPoint(pEntryPoint);
}
+PCODE ReadyToRunInfo::MethodIterator::GetMethodStartAddress()
+{
+ STANDARD_VM_CONTRACT;
+
+ PCODE ret = m_pInfo->GetEntryPoint(GetMethodDesc(), NULL, FALSE);
+ _ASSERTE(ret != NULL);
+ return ret;
+}
+
DWORD ReadyToRunInfo::GetFieldBaseOffset(MethodTable * pMT)
{
STANDARD_VM_CONTRACT;
ReadyToRunInfo * m_pInfo;
int m_methodDefIndex;
- public:
- MethodIterator(ReadyToRunInfo * pInfo) :
- m_pInfo(pInfo),
- m_methodDefIndex(-1)
- {
- }
+ NativeFormat::NativeHashtable::AllEntriesEnumerator m_genericEnum;
+ NativeFormat::NativeParser m_genericParser;
+ uint m_genericCurrentOffset;
+ RID m_genericCurrentRid;
+ PCCOR_SIGNATURE m_genericCurrentSig;
- BOOL Next();
-
- MethodDesc * GetMethodDesc();
- MethodDesc * GetMethodDesc_NoRestore();
- PCODE GetMethodStartAddress();
- };
-
- class GenericMethodIterator
- {
- ReadyToRunInfo *m_pInfo;
- NativeFormat::NativeHashtable::AllEntriesEnumerator m_enum;
- NativeFormat::NativeParser m_current;
+ void ParseGenericMethodSignatureAndRid(uint *offset, RID *rid);
public:
- GenericMethodIterator(ReadyToRunInfo *pInfo) :
+ MethodIterator(ReadyToRunInfo * pInfo) :
m_pInfo(pInfo),
- m_enum(),
- m_current()
+ m_methodDefIndex(-1),
+ m_genericEnum(),
+ m_genericParser(),
+ m_genericCurrentOffset(-1),
+ m_genericCurrentRid(-1),
+ m_genericCurrentSig(NULL)
{
NativeFormat::PTR_NativeHashtable pHash = NULL;
if (!pInfo->m_instMethodEntryPoints.IsNull())
pHash = NativeFormat::PTR_NativeHashtable(&pInfo->m_instMethodEntryPoints);
}
- m_enum = NativeFormat::NativeHashtable::AllEntriesEnumerator(pHash);
+ m_genericEnum = NativeFormat::NativeHashtable::AllEntriesEnumerator(pHash);
}
BOOL Next();
+
+ MethodDesc * GetMethodDesc();
MethodDesc * GetMethodDesc_NoRestore();
+ PCODE GetMethodStartAddress();
};
static DWORD GetFieldBaseOffset(MethodTable * pMT);