summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Wrighton <davidwr@microsoft.com>2019-06-07 11:38:49 -0700
committerGitHub <noreply@github.com>2019-06-07 11:38:49 -0700
commitb614f4f5529296cac834e54f2fa4bc540a61a04d (patch)
tree9ed3c8a7e298516bcb436bf68252b959f524a762
parentb51993933c5f2f29b20d229cdb32bbcb41e76dd6 (diff)
downloadcoreclr-b614f4f5529296cac834e54f2fa4bc540a61a04d.tar.gz
coreclr-b614f4f5529296cac834e54f2fa4bc540a61a04d.tar.bz2
coreclr-b614f4f5529296cac834e54f2fa4bc540a61a04d.zip
Reduce indirect function calls (#24980)
* Reduce indirect dispatch in hot paths in metadata * Remove allocation indirections in utilcode for coreclr - we no longer have a multi-dll distribution of code that needs to share heaps * Remove unused code in GetCLRFunction * Remove virtual dispatch around impl/decl methodtable access in MethodData
-rw-r--r--src/ToolBox/superpmi/superpmi-shared/coreclrcommoncallbacks.h5
-rw-r--r--src/ToolBox/superpmi/superpmi-shim-collector/coreclrcallbacks.cpp36
-rw-r--r--src/ToolBox/superpmi/superpmi-shim-counter/coreclrcallbacks.cpp28
-rw-r--r--src/ToolBox/superpmi/superpmi-shim-simple/coreclrcallbacks.cpp32
-rw-r--r--src/ToolBox/superpmi/superpmi/coreclrcallbacks.cpp25
-rw-r--r--src/inc/clrhost.h13
-rw-r--r--src/inc/stgpool.h36
-rw-r--r--src/md/heaps/stringheap.h2
-rw-r--r--src/md/inc/metamodel.h91
-rw-r--r--src/md/inc/metamodelro.h2
-rw-r--r--src/md/runtime/mdinternalro.cpp2
-rw-r--r--src/md/runtime/metamodel.cpp80
-rw-r--r--src/utilcode/clrhost_nodependencies.cpp49
-rw-r--r--src/vm/ceemain.cpp25
-rw-r--r--src/vm/ceemain.h3
-rw-r--r--src/vm/hosting.cpp10
-rw-r--r--src/vm/methodtable.cpp28
-rw-r--r--src/vm/methodtable.h46
-rw-r--r--src/vm/util.cpp16
19 files changed, 156 insertions, 373 deletions
diff --git a/src/ToolBox/superpmi/superpmi-shared/coreclrcommoncallbacks.h b/src/ToolBox/superpmi/superpmi-shared/coreclrcommoncallbacks.h
index 98c44c5dec..674268d52a 100644
--- a/src/ToolBox/superpmi/superpmi-shared/coreclrcommoncallbacks.h
+++ b/src/ToolBox/superpmi/superpmi-shared/coreclrcommoncallbacks.h
@@ -10,11 +10,6 @@
IExecutionEngine* STDMETHODCALLTYPE IEE_t();
HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength);
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes);
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem);
void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName);
-typedef LPVOID(STDMETHODCALLTYPE* pfnEEHeapAllocInProcessHeap)(DWORD dwFlags, SIZE_T dwBytes);
-typedef BOOL(STDMETHODCALLTYPE* pfnEEHeapFreeInProcessHeap)(DWORD dwFlags, LPVOID lpMem);
-
#endif
diff --git a/src/ToolBox/superpmi/superpmi-shim-collector/coreclrcallbacks.cpp b/src/ToolBox/superpmi/superpmi-shim-collector/coreclrcallbacks.cpp
index f0bc271311..759e6717d4 100644
--- a/src/ToolBox/superpmi/superpmi-shim-collector/coreclrcallbacks.cpp
+++ b/src/ToolBox/superpmi/superpmi-shim-collector/coreclrcallbacks.cpp
@@ -8,8 +8,6 @@
#include "iexecutionengine.h"
CoreClrCallbacks* original_CoreClrCallbacks = nullptr;
-pfnEEHeapAllocInProcessHeap original_EEHeapAllocInProcessHeap = nullptr;
-pfnEEHeapFreeInProcessHeap original_EEHeapFreeInProcessHeap = nullptr;
IExecutionEngine* STDMETHODCALLTYPE IEE_t()
{
@@ -18,41 +16,7 @@ IExecutionEngine* STDMETHODCALLTYPE IEE_t()
return iee;
}
-/*#pragma warning( suppress :4996 ) //deprecated
-HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength)
-{
- DebugBreakorAV(131);
- return 0;
-}
-*/
-
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
-{
- if (original_EEHeapAllocInProcessHeap == nullptr)
- __debugbreak();
- return original_EEHeapAllocInProcessHeap(dwFlags, dwBytes);
-}
-
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
-{
- if (original_EEHeapFreeInProcessHeap == nullptr)
- __debugbreak();
- return original_EEHeapFreeInProcessHeap(dwFlags, lpMem);
-}
-
void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
{
- if (strcmp(functionName, "EEHeapAllocInProcessHeap") == 0)
- {
- original_EEHeapAllocInProcessHeap =
- (pfnEEHeapAllocInProcessHeap)original_CoreClrCallbacks->m_pfnGetCLRFunction("EEHeapAllocInProcessHeap");
- return (void*)EEHeapAllocInProcessHeap;
- }
- if (strcmp(functionName, "EEHeapFreeInProcessHeap") == 0)
- {
- original_EEHeapFreeInProcessHeap =
- (pfnEEHeapFreeInProcessHeap)original_CoreClrCallbacks->m_pfnGetCLRFunction("EEHeapFreeInProcessHeap");
- return (void*)EEHeapFreeInProcessHeap;
- }
return original_CoreClrCallbacks->m_pfnGetCLRFunction(functionName);
}
diff --git a/src/ToolBox/superpmi/superpmi-shim-counter/coreclrcallbacks.cpp b/src/ToolBox/superpmi/superpmi-shim-counter/coreclrcallbacks.cpp
index f0bc271311..c5ef40227c 100644
--- a/src/ToolBox/superpmi/superpmi-shim-counter/coreclrcallbacks.cpp
+++ b/src/ToolBox/superpmi/superpmi-shim-counter/coreclrcallbacks.cpp
@@ -8,8 +8,6 @@
#include "iexecutionengine.h"
CoreClrCallbacks* original_CoreClrCallbacks = nullptr;
-pfnEEHeapAllocInProcessHeap original_EEHeapAllocInProcessHeap = nullptr;
-pfnEEHeapFreeInProcessHeap original_EEHeapFreeInProcessHeap = nullptr;
IExecutionEngine* STDMETHODCALLTYPE IEE_t()
{
@@ -26,33 +24,7 @@ HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer,
}
*/
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
-{
- if (original_EEHeapAllocInProcessHeap == nullptr)
- __debugbreak();
- return original_EEHeapAllocInProcessHeap(dwFlags, dwBytes);
-}
-
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
-{
- if (original_EEHeapFreeInProcessHeap == nullptr)
- __debugbreak();
- return original_EEHeapFreeInProcessHeap(dwFlags, lpMem);
-}
-
void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
{
- if (strcmp(functionName, "EEHeapAllocInProcessHeap") == 0)
- {
- original_EEHeapAllocInProcessHeap =
- (pfnEEHeapAllocInProcessHeap)original_CoreClrCallbacks->m_pfnGetCLRFunction("EEHeapAllocInProcessHeap");
- return (void*)EEHeapAllocInProcessHeap;
- }
- if (strcmp(functionName, "EEHeapFreeInProcessHeap") == 0)
- {
- original_EEHeapFreeInProcessHeap =
- (pfnEEHeapFreeInProcessHeap)original_CoreClrCallbacks->m_pfnGetCLRFunction("EEHeapFreeInProcessHeap");
- return (void*)EEHeapFreeInProcessHeap;
- }
return original_CoreClrCallbacks->m_pfnGetCLRFunction(functionName);
}
diff --git a/src/ToolBox/superpmi/superpmi-shim-simple/coreclrcallbacks.cpp b/src/ToolBox/superpmi/superpmi-shim-simple/coreclrcallbacks.cpp
index 149fe069af..759e6717d4 100644
--- a/src/ToolBox/superpmi/superpmi-shim-simple/coreclrcallbacks.cpp
+++ b/src/ToolBox/superpmi/superpmi-shim-simple/coreclrcallbacks.cpp
@@ -8,8 +8,6 @@
#include "iexecutionengine.h"
CoreClrCallbacks* original_CoreClrCallbacks = nullptr;
-pfnEEHeapAllocInProcessHeap original_EEHeapAllocInProcessHeap = nullptr;
-pfnEEHeapFreeInProcessHeap original_EEHeapFreeInProcessHeap = nullptr;
IExecutionEngine* STDMETHODCALLTYPE IEE_t()
{
@@ -18,37 +16,7 @@ IExecutionEngine* STDMETHODCALLTYPE IEE_t()
return iee;
}
-/*#pragma warning( suppress :4996 ) //deprecated
-HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength)
-{
- DebugBreakorAV(131);
- return 0;
-}
-*/
-
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
-{
- return original_EEHeapAllocInProcessHeap(dwFlags, dwBytes);
-}
-
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
-{
- return original_EEHeapFreeInProcessHeap(dwFlags, lpMem);
-}
-
void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
{
- if (strcmp(functionName, "EEHeapAllocInProcessHeap") == 0)
- {
- original_EEHeapAllocInProcessHeap =
- (pfnEEHeapAllocInProcessHeap)original_CoreClrCallbacks->m_pfnGetCLRFunction("EEHeapAllocInProcessHeap");
- return (void*)EEHeapAllocInProcessHeap;
- }
- if (strcmp(functionName, "EEHeapFreeInProcessHeap") == 0)
- {
- original_EEHeapFreeInProcessHeap =
- (pfnEEHeapFreeInProcessHeap)original_CoreClrCallbacks->m_pfnGetCLRFunction("EEHeapFreeInProcessHeap");
- return (void*)EEHeapFreeInProcessHeap;
- }
return original_CoreClrCallbacks->m_pfnGetCLRFunction(functionName);
}
diff --git a/src/ToolBox/superpmi/superpmi/coreclrcallbacks.cpp b/src/ToolBox/superpmi/superpmi/coreclrcallbacks.cpp
index d96e2be7df..15af7c8555 100644
--- a/src/ToolBox/superpmi/superpmi/coreclrcallbacks.cpp
+++ b/src/ToolBox/superpmi/superpmi/coreclrcallbacks.cpp
@@ -24,33 +24,8 @@ HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer,
HANDLE ourHeap = nullptr;
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
-{
- if (ourHeap == nullptr)
- ourHeap = HeapCreate(0, 4096, 0);
- if (ourHeap == nullptr)
- {
- LogError("HeapCreate Failed");
- __debugbreak();
- return nullptr;
- }
- LPVOID result = HeapAlloc(ourHeap, dwFlags, dwBytes);
- // LogDebug("EEHeapAllocInProcessHeap %p %u %u", result, dwFlags, dwBytes);
- return result;
-}
-
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
-{
- // return true;
- return HeapFree(ourHeap, dwFlags, lpMem);
-}
-
void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
{
- if (strcmp(functionName, "EEHeapAllocInProcessHeap") == 0)
- return (void*)EEHeapAllocInProcessHeap;
- if (strcmp(functionName, "EEHeapFreeInProcessHeap") == 0)
- return (void*)EEHeapFreeInProcessHeap;
DebugBreakorAV(132);
return nullptr;
}
diff --git a/src/inc/clrhost.h b/src/inc/clrhost.h
index c210652a8d..88a917d59f 100644
--- a/src/inc/clrhost.h
+++ b/src/inc/clrhost.h
@@ -182,8 +182,11 @@ inline void ClrFlsSetValue(DWORD slot, void *pData)
}
}
-typedef LPVOID (*FastAllocInProcessHeapFunc)(DWORD dwFlags, SIZE_T dwBytes);
-extern FastAllocInProcessHeapFunc __ClrAllocInProcessHeap;
+#ifndef SELF_NO_HOST
+LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes);
+BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem);
+#endif
+
inline LPVOID ClrAllocInProcessHeap(DWORD dwFlags, S_SIZE_T dwBytes)
{
STATIC_CONTRACT_SUPPORTS_DAC_HOST_ONLY;
@@ -193,7 +196,7 @@ inline LPVOID ClrAllocInProcessHeap(DWORD dwFlags, S_SIZE_T dwBytes)
}
#ifndef SELF_NO_HOST
- return __ClrAllocInProcessHeap(dwFlags, dwBytes.Value());
+ return EEHeapAllocInProcessHeap(dwFlags, dwBytes.Value());
#else
#undef HeapAlloc
#undef GetProcessHeap
@@ -206,13 +209,11 @@ inline LPVOID ClrAllocInProcessHeap(DWORD dwFlags, S_SIZE_T dwBytes)
#endif
}
-typedef BOOL (*FastFreeInProcessHeapFunc)(DWORD dwFlags, LPVOID lpMem);
-extern FastFreeInProcessHeapFunc __ClrFreeInProcessHeap;
inline BOOL ClrFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
{
STATIC_CONTRACT_SUPPORTS_DAC_HOST_ONLY;
#ifndef SELF_NO_HOST
- return __ClrFreeInProcessHeap(dwFlags, lpMem);
+ return EEHeapFreeInProcessHeap(dwFlags, lpMem);
#else
#undef HeapFree
#undef GetProcessHeap
diff --git a/src/inc/stgpool.h b/src/inc/stgpool.h
index 4486695507..67d78b24db 100644
--- a/src/inc/stgpool.h
+++ b/src/inc/stgpool.h
@@ -234,6 +234,42 @@ public:
return hr;
}
+
+//*****************************************************************************
+// Return a pointer to a null terminated string given an offset previously
+// handed out by AddString or FindString. Only valid for use if the Storage pool is actuall ReadOnly, and not derived
+//*****************************************************************************
+ __checkReturn
+ inline HRESULT GetStringReadOnly(
+ UINT32 nIndex,
+ __deref_out LPCSTR *pszString)
+ {
+ HRESULT hr;
+
+ // Size of the data in the heap will be ignored, because we have verified during creation of the string
+ // heap (code:Initialize) and when adding new strings (e.g. code:AddString,
+ // code:AddTemporaryStringBuffer), that the heap is null-terminated, therefore we don't have to check it
+ // for each string in the heap
+ MetaData::DataBlob stringData;
+
+ // Get data from the heap (clears stringData on error)
+ IfFailGo(GetDataReadOnly(
+ nIndex,
+ &stringData));
+ _ASSERTE(hr == S_OK);
+ // Raw data are always at least 1 byte long, otherwise it would be invalid offset and hr != S_OK
+ PREFAST_ASSUME(stringData.GetDataPointer() != NULL);
+ // Fills output string
+ *pszString = reinterpret_cast<LPSTR>(stringData.GetDataPointer());
+ //_ASSERTE(stringData.GetSize() > strlen(*pszString));
+
+ return hr;
+ ErrExit:
+ // Clears output string on error
+ *pszString = NULL;
+
+ return hr;
+ }
#ifdef _PREFAST_
#pragma warning(pop)
#endif
diff --git a/src/md/heaps/stringheap.h b/src/md/heaps/stringheap.h
index b5353a12fd..2f99c6da2b 100644
--- a/src/md/heaps/stringheap.h
+++ b/src/md/heaps/stringheap.h
@@ -77,7 +77,7 @@ public:
UINT32 nIndex,
__deref_out_z LPCSTR *pszString) const
{
- return const_cast<StgPoolReadOnly &>(m_StringPool).GetString(
+ return const_cast<StgPoolReadOnly &>(m_StringPool).GetStringReadOnly(
nIndex,
pszString);
}
diff --git a/src/md/inc/metamodel.h b/src/md/inc/metamodel.h
index 317501bfa5..99f4ce8949 100644
--- a/src/md/inc/metamodel.h
+++ b/src/md/inc/metamodel.h
@@ -150,7 +150,7 @@ public:
virtual int CommonIsRo() = 0;
__checkReturn
- virtual HRESULT CommonGetCustomAttributeByName( // S_OK or error.
+ HRESULT CommonGetCustomAttributeByName( // S_OK or error.
mdToken tkObj, // [IN] Object with Custom Attribute.
LPCUTF8 szName, // [IN] Name of desired Custom Attribute.
const void **ppData, // [OUT] Put pointer to data here.
@@ -440,16 +440,6 @@ public:
ULONG ulTarget, // target for search
RID *pRid) = 0;
- // Search a table for multiple (adjacent) rows containing the given
- // key value. EG, InterfaceImpls all point back to the implementing class.
- __checkReturn
- HRESULT SearchTableForMultipleRows( // First RID found, or 0.
- ULONG ixTbl, // Table to search.
- CMiniColDef sColumn, // Sorted key column, containing search value.
- ULONG ulTarget, // Target for search.
- RID *pEnd, // [OPTIONAL, OUT]
- RID *pFoundRid);
-
// Search for a custom value with a given type.
__checkReturn
HRESULT FindCustomAttributeFor(// RID of custom value, or 0.
@@ -733,6 +723,85 @@ public:
}
//*****************************************************************************
+ // Search a table for multiple (adjacent) rows containing the given
+ // key value. EG, InterfaceImpls all point back to the implementing class.
+ //*****************************************************************************
+ __checkReturn
+ HRESULT SearchTableForMultipleRows(
+ ULONG ixTbl, // Table to search.
+ CMiniColDef sColumn, // Sorted key column, containing search value.
+ ULONG ulTarget, // Target for search.
+ RID *pEnd, // [OPTIONAL, OUT]
+ RID *pFoundRid) // First RID found, or 0.
+ {
+ HRESULT hr;
+ ULONG ridBegin; // RID of first entry.
+ ULONG ridEnd; // RID of first entry past last entry.
+
+ // Search for any entry in the table.
+ IfFailRet(static_cast<Impl*>(this)->vSearchTable(ixTbl, sColumn, ulTarget, &ridBegin));
+
+ // If nothing found, return invalid RID.
+ if (ridBegin == 0)
+ {
+ if (pEnd != NULL)
+ {
+ *pEnd = 0;
+ }
+ *pFoundRid = 0;
+ return S_OK;
+ }
+
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ // If you change the rows touched while searching, please update
+ // CMiniMdRW::GetHotMetadataTokensSearchAware
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+ // End will be at least one larger than found record.
+ ridEnd = ridBegin + 1;
+
+ // Search back to start of group.
+ for (;;)
+ {
+ void *pRow;
+ if (ridBegin <= 1)
+ {
+ break;
+ }
+ IfFailRet(static_cast<Impl*>(this)->vGetRow(ixTbl, ridBegin-1, &pRow));
+ if (getIX(pRow, sColumn) != ulTarget)
+ {
+ break;
+ }
+ --ridBegin;
+ }
+
+ // If desired, search forward to end of group.
+ if (pEnd != NULL)
+ {
+ for (;;)
+ {
+ void *pRow;
+ if (ridEnd > GetCountRecs(ixTbl))
+ {
+ break;
+ }
+ IfFailRet(static_cast<Impl*>(this)->vGetRow(ixTbl, ridEnd, &pRow));
+ if (getIX(pRow, sColumn) != ulTarget)
+ {
+ break;
+ }
+ ++ridEnd;
+ }
+ *pEnd = ridEnd;
+ }
+
+ *pFoundRid = ridBegin;
+ return S_OK;
+ } // SearchTableForMultipleRows
+
+ //*****************************************************************************
// Get name and sig of a methodDef
//*****************************************************************************
HRESULT CommonGetMethodDefProps(
diff --git a/src/md/inc/metamodelro.h b/src/md/inc/metamodelro.h
index 00d4ead5f9..9d77ea04aa 100644
--- a/src/md/inc/metamodelro.h
+++ b/src/md/inc/metamodelro.h
@@ -29,7 +29,7 @@
template <class MiniMd> class CLiteWeightStgdb;
class CMiniMdRW;
class MDInternalRO;
-class CMiniMd : public CMiniMdTemplate<CMiniMd>
+class CMiniMd final: public CMiniMdTemplate<CMiniMd>
{
public:
friend class CLiteWeightStgdb<CMiniMd>;
diff --git a/src/md/runtime/mdinternalro.cpp b/src/md/runtime/mdinternalro.cpp
index 64a4054d28..28d63c1397 100644
--- a/src/md/runtime/mdinternalro.cpp
+++ b/src/md/runtime/mdinternalro.cpp
@@ -963,7 +963,7 @@ HRESULT MDInternalRO::GetCustomAttributeByName( // S_OK or error.
__deref_out_bcount(*pcbData) const void **ppData, // [OUT] Put pointer to data here.
__out ULONG *pcbData) // [OUT] Put size of data here.
{
- return m_LiteWeightStgdb.m_MiniMd.CommonGetCustomAttributeByName(tkObj, szName, ppData, pcbData);
+ return m_LiteWeightStgdb.m_MiniMd.CommonGetCustomAttributeByNameEx(tkObj, szName, NULL, ppData, pcbData);
} // MDInternalRO::GetCustomAttributeByName
diff --git a/src/md/runtime/metamodel.cpp b/src/md/runtime/metamodel.cpp
index 83addc6d6c..8f0ef83451 100644
--- a/src/md/runtime/metamodel.cpp
+++ b/src/md/runtime/metamodel.cpp
@@ -861,86 +861,6 @@ CMiniMdBase::GetCountRecs(
return m_Schema.m_cRecs[ixTbl];
} // CMiniMdBase::GetCountRecs
-//*****************************************************************************
-// Search a table for multiple (adjacent) rows containing the given
-// key value. EG, InterfaceImpls all point back to the implementing class.
-//*****************************************************************************
-__checkReturn
-HRESULT
-CMiniMdBase::SearchTableForMultipleRows(
- ULONG ixTbl, // Table to search.
- CMiniColDef sColumn, // Sorted key column, containing search value.
- ULONG ulTarget, // Target for search.
- RID *pEnd, // [OPTIONAL, OUT]
- RID *pFoundRid) // First RID found, or 0.
-{
- HRESULT hr;
- ULONG ridBegin; // RID of first entry.
- ULONG ridEnd; // RID of first entry past last entry.
-
- // Search for any entry in the table.
- IfFailRet(vSearchTable(ixTbl, sColumn, ulTarget, &ridBegin));
-
- // If nothing found, return invalid RID.
- if (ridBegin == 0)
- {
- if (pEnd != NULL)
- {
- *pEnd = 0;
- }
- *pFoundRid = 0;
- return S_OK;
- }
-
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- // If you change the rows touched while searching, please update
- // CMiniMdRW::GetHotMetadataTokensSearchAware
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-
- // End will be at least one larger than found record.
- ridEnd = ridBegin + 1;
-
- // Search back to start of group.
- for (;;)
- {
- void *pRow;
- if (ridBegin <= 1)
- {
- break;
- }
- IfFailRet(vGetRow(ixTbl, ridBegin-1, &pRow));
- if (getIX(pRow, sColumn) != ulTarget)
- {
- break;
- }
- --ridBegin;
- }
-
- // If desired, search forward to end of group.
- if (pEnd != NULL)
- {
- for (;;)
- {
- void *pRow;
- if (ridEnd > GetCountRecs(ixTbl))
- {
- break;
- }
- IfFailRet(vGetRow(ixTbl, ridEnd, &pRow));
- if (getIX(pRow, sColumn) != ulTarget)
- {
- break;
- }
- ++ridEnd;
- }
- *pEnd = ridEnd;
- }
-
- *pFoundRid = ridBegin;
- return S_OK;
-} // CMiniMdBase::SearchTableForMultipleRows
-
#if BIGENDIAN
// Endian Swaps the passed in blob representing a constant into the passed in StgPool
diff --git a/src/utilcode/clrhost_nodependencies.cpp b/src/utilcode/clrhost_nodependencies.cpp
index a272787e8a..09542a098e 100644
--- a/src/utilcode/clrhost_nodependencies.cpp
+++ b/src/utilcode/clrhost_nodependencies.cpp
@@ -334,55 +334,6 @@ ClrDebugState *CLRInitDebugState()
#endif //defined(_DEBUG_IMPL) && defined(ENABLE_CONTRACTS_IMPL)
-
-LPVOID ClrAllocInProcessHeapBootstrap (DWORD dwFlags, SIZE_T dwBytes)
-{
-#if defined(SELF_NO_HOST)
- static HANDLE hHeap = NULL;
-
- // This could race, but the result would be that this
- // variable gets double initialized.
- if (hHeap == NULL)
- hHeap = ClrGetProcessHeap();
-
- return ClrHeapAlloc(hHeap, dwFlags, S_SIZE_T(dwBytes));
-#else //!defined(SELF_NO_HOST)
- FastAllocInProcessHeapFunc pfnHeapAlloc = (FastAllocInProcessHeapFunc)
- GetClrCallbacks().m_pfnGetCLRFunction("EEHeapAllocInProcessHeap");
- if (pfnHeapAlloc != NULL)
- {
- __ClrAllocInProcessHeap = pfnHeapAlloc;
- return pfnHeapAlloc(dwFlags, dwBytes);
- }
- return ClrHeapAlloc(ClrGetProcessHeap(), dwFlags, S_SIZE_T(dwBytes));
-#endif // !defined(SELF_NO_HOST)
-}
-FastAllocInProcessHeapFunc __ClrAllocInProcessHeap = (FastAllocInProcessHeapFunc) ClrAllocInProcessHeapBootstrap;
-
-BOOL ClrFreeInProcessHeapBootstrap (DWORD dwFlags, LPVOID lpMem)
-{
-#if defined(SELF_NO_HOST)
- static HANDLE hHeap = NULL;
-
- // This could race, but the result would be that this
- // variable gets double initialized.
- if (hHeap == NULL)
- hHeap = ClrGetProcessHeap();
-
- return ClrHeapFree(hHeap, dwFlags,lpMem);
-#else //!defined(SELF_NO_HOST)
- FastFreeInProcessHeapFunc pfnHeapFree = (FastFreeInProcessHeapFunc)
- GetClrCallbacks().m_pfnGetCLRFunction("EEHeapFreeInProcessHeap");
- if (pfnHeapFree)
- {
- __ClrFreeInProcessHeap = pfnHeapFree;
- return (*pfnHeapFree)(dwFlags,lpMem);
- }
- return ClrHeapFree(ClrGetProcessHeap(),dwFlags,lpMem);
-#endif //!defined(SELF_NO_HOST)
-}
-FastFreeInProcessHeapFunc __ClrFreeInProcessHeap = (FastFreeInProcessHeapFunc) ClrFreeInProcessHeapBootstrap;
-
const NoThrow nothrow = { 0 };
#ifdef HAS_ADDRESS_SANITIZER
diff --git a/src/vm/ceemain.cpp b/src/vm/ceemain.cpp
index 6856d481cd..e621de7a8f 100644
--- a/src/vm/ceemain.cpp
+++ b/src/vm/ceemain.cpp
@@ -1179,31 +1179,6 @@ void ForceEEShutdown(ShutdownCompleteAction sca)
EEPolicy::HandleExitProcess(sca);
}
-//---------------------------------------------------------------------------
-// %%Function: IsRuntimeStarted
-//
-// Parameters:
-// pdwStartupFlags: out parameter that is set to the startup flags if the
-// runtime is started.
-//
-// Returns:
-// TRUE if the runtime has been started, FALSE otherwise.
-//
-// Description:
-// This is a helper used only by the v4+ Shim to determine if this runtime
-// has ever been started. It is exposed ot the Shim via GetCLRFunction.
-// ---------------------------------------------------------------------------
-BOOL IsRuntimeStarted(DWORD *pdwStartupFlags)
-{
- LIMITED_METHOD_CONTRACT;
-
- if (pdwStartupFlags != NULL) // this parameter is optional
- {
- *pdwStartupFlags = 0;
- }
- return g_fEEStarted;
-}
-
static bool WaitForEndOfShutdown_OneIteration()
{
CONTRACTL{
diff --git a/src/vm/ceemain.h b/src/vm/ceemain.h
index 25152564c0..3a6fe377d6 100644
--- a/src/vm/ceemain.h
+++ b/src/vm/ceemain.h
@@ -25,9 +25,6 @@ HRESULT EnsureEEStarted(COINITIEE flags);
// Wrapper around EnsureEEStarted which also sets startup mode.
HRESULT InitializeEE(COINITIEE flags);
-// Has the EE been started up?
-BOOL IsRuntimeStarted(DWORD *pdwStartupFlags);
-
// Enum to control what happens at the end of EE shutdown. There are two options:
// 1. Call ::ExitProcess to cause the process to terminate gracefully. This is how
// shutdown normally ends. "Shutdown" methods that take this action as an argument
diff --git a/src/vm/hosting.cpp b/src/vm/hosting.cpp
index 5b447221bd..980706066f 100644
--- a/src/vm/hosting.cpp
+++ b/src/vm/hosting.cpp
@@ -240,11 +240,6 @@ LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
{
WRAPPER_NO_CONTRACT;
-#ifdef _DEBUG
- // Check whether (indispensable) implicit casting in ClrAllocInProcessHeapBootstrap is safe.
- static FastAllocInProcessHeapFunc pFunc = EEHeapAllocInProcessHeap;
-#endif
-
static HANDLE ProcessHeap = NULL;
if (ProcessHeap == NULL)
@@ -296,11 +291,6 @@ BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
}
CONTRACTL_END;
-#ifdef _DEBUG
- // Check whether (indispensable) implicit casting in ClrFreeInProcessHeapBootstrap is safe.
- static FastFreeInProcessHeapFunc pFunc = EEHeapFreeInProcessHeap;
-#endif
-
static HANDLE ProcessHeap = NULL;
if (ProcessHeap == NULL)
diff --git a/src/vm/methodtable.cpp b/src/vm/methodtable.cpp
index d0dd136925..e9384aa7f8 100644
--- a/src/vm/methodtable.cpp
+++ b/src/vm/methodtable.cpp
@@ -8550,20 +8550,19 @@ UINT32 MethodTable::MethodDataObject::GetObjectSize(MethodTable *pMT)
//==========================================================================================
// This will fill in all the MethodEntry slots present in the current MethodTable
-void MethodTable::MethodDataObject::Init(MethodTable *pMT, MethodData *pParentData)
+void MethodTable::MethodDataObject::Init(MethodData *pParentData)
{
CONTRACTL {
THROWS;
WRAPPER(GC_TRIGGERS);
- PRECONDITION(CheckPointer(pMT));
+ PRECONDITION(CheckPointer(m_pDeclMT));
PRECONDITION(CheckPointer(pParentData, NULL_OK));
- PRECONDITION(!pMT->IsInterface());
+ PRECONDITION(!m_pDeclMT->IsInterface());
PRECONDITION(pParentData == NULL ||
- (pMT->ParentEquals(pParentData->GetDeclMethodTable()) &&
- pMT->ParentEquals(pParentData->GetImplMethodTable())));
+ (m_pDeclMT->ParentEquals(pParentData->GetDeclMethodTable()) &&
+ m_pDeclMT->ParentEquals(pParentData->GetImplMethodTable())));
} CONTRACTL_END;
- m_pMT = pMT;
m_iNextChainDepth = 0;
m_containsMethodImpl = FALSE;
@@ -8583,7 +8582,7 @@ BOOL MethodTable::MethodDataObject::PopulateNextLevel()
return FALSE;
}
// Now move up the chain to the target.
- MethodTable *pMTCur = m_pMT;
+ MethodTable *pMTCur = m_pDeclMT;
for (UINT32 i = 0; pMTCur != NULL && i < iChainDepth; i++) {
pMTCur = pMTCur->GetParentMethodTable();
}
@@ -8626,7 +8625,7 @@ void MethodTable::MethodDataObject::FillEntryDataForAncestor(MethodTable * pMT)
if (pMT->GetClass()->ContainsMethodImpls())
m_containsMethodImpl = TRUE;
- if (m_containsMethodImpl && pMT != m_pMT)
+ if (m_containsMethodImpl && pMT != m_pDeclMT)
return;
unsigned nVirtuals = pMT->GetNumVirtuals();
@@ -8643,7 +8642,7 @@ void MethodTable::MethodDataObject::FillEntryDataForAncestor(MethodTable * pMT)
// We want to fill all methods introduced by the actual type we're gathering
// data for, and the virtual methods of the parent and above
- if (pMT == m_pMT)
+ if (pMT == m_pDeclMT)
{
if (m_containsMethodImpl && slot < nVirtuals)
continue;
@@ -8699,7 +8698,7 @@ DispatchSlot MethodTable::MethodDataObject::GetImplSlot(UINT32 slotNumber)
{
WRAPPER_NO_CONTRACT;
_ASSERTE(slotNumber < GetNumMethods());
- return DispatchSlot(m_pMT->GetRestoredSlot(slotNumber));
+ return DispatchSlot(m_pDeclMT->GetRestoredSlot(slotNumber));
}
//==========================================================================================
@@ -8733,13 +8732,13 @@ MethodDesc *MethodTable::MethodDataObject::GetImplMethodDesc(UINT32 slotNumber)
if (pMDRet == NULL)
{
_ASSERTE(slotNumber < GetNumVirtuals());
- pMDRet = m_pMT->GetMethodDescForSlot(slotNumber);
+ pMDRet = m_pDeclMT->GetMethodDescForSlot(slotNumber);
_ASSERTE(CheckPointer(pMDRet));
pEntry->SetImplMethodDesc(pMDRet);
}
else
{
- _ASSERTE(slotNumber >= GetNumVirtuals() || pMDRet == m_pMT->GetMethodDescForSlot(slotNumber));
+ _ASSERTE(slotNumber >= GetNumVirtuals() || pMDRet == m_pDeclMT->GetMethodDescForSlot(slotNumber));
}
return pMDRet;
@@ -8759,7 +8758,7 @@ void MethodTable::MethodDataObject::InvalidateCachedVirtualSlot(UINT32 slotNumbe
MethodDesc *MethodTable::MethodDataInterface::GetDeclMethodDesc(UINT32 slotNumber)
{
WRAPPER_NO_CONTRACT;
- return m_pMT->GetMethodDescForSlot(slotNumber);
+ return m_pDeclMT->GetMethodDescForSlot(slotNumber);
}
//==========================================================================================
@@ -8833,7 +8832,8 @@ MethodTable::MethodDataInterfaceImpl::MethodDataInterfaceImpl(
const DispatchMapTypeID * rgDeclTypeIDs,
UINT32 cDeclTypeIDs,
MethodData * pDecl,
- MethodData * pImpl)
+ MethodData * pImpl) :
+ MethodData(pImpl->GetDeclMethodTable(), pDecl->GetDeclMethodTable())
{
WRAPPER_NO_CONTRACT;
Init(rgDeclTypeIDs, cDeclTypeIDs, pDecl, pImpl);
diff --git a/src/vm/methodtable.h b/src/vm/methodtable.h
index 2b7c516ab3..93f7644d23 100644
--- a/src/vm/methodtable.h
+++ b/src/vm/methodtable.h
@@ -3191,17 +3191,19 @@ public:
protected:
ULONG m_cRef;
+ MethodTable *const m_pImplMT;
+ MethodTable *const m_pDeclMT;
public:
- MethodData() : m_cRef(1) { LIMITED_METHOD_CONTRACT; }
+ MethodData(MethodTable *implMT, MethodTable *declMT) : m_cRef(1), m_pImplMT(implMT), m_pDeclMT(declMT) { LIMITED_METHOD_CONTRACT; }
virtual ~MethodData() { LIMITED_METHOD_CONTRACT; }
virtual MethodData *GetDeclMethodData() = 0;
- virtual MethodTable *GetDeclMethodTable() = 0;
+ MethodTable *GetDeclMethodTable() { return m_pDeclMT; }
virtual MethodDesc *GetDeclMethodDesc(UINT32 slotNumber) = 0;
virtual MethodData *GetImplMethodData() = 0;
- virtual MethodTable *GetImplMethodTable() = 0;
+ MethodTable *GetImplMethodTable() { return m_pImplMT; }
virtual DispatchSlot GetImplSlot(UINT32 slotNumber) = 0;
// Returns INVALID_SLOT_NUMBER if no implementation exists.
virtual UINT32 GetImplSlotNumber(UINT32 slotNumber) = 0;
@@ -3291,42 +3293,35 @@ protected:
static UINT32 GetObjectSize(MethodTable *pMT);
// Constructor. Make sure you have allocated enough memory using GetObjectSize.
- inline MethodDataObject(MethodTable *pMT)
- { WRAPPER_NO_CONTRACT; Init(pMT, NULL); }
+ inline MethodDataObject(MethodTable *pMT) : MethodData(pMT, pMT)
+ { WRAPPER_NO_CONTRACT; Init(NULL); }
- inline MethodDataObject(MethodTable *pMT, MethodData *pParentData)
- { WRAPPER_NO_CONTRACT; Init(pMT, pParentData); }
+ inline MethodDataObject(MethodTable *pMT, MethodData *pParentData) : MethodData(pMT, pMT)
+ { WRAPPER_NO_CONTRACT; Init(pParentData); }
virtual ~MethodDataObject() { LIMITED_METHOD_CONTRACT; }
virtual MethodData *GetDeclMethodData()
{ LIMITED_METHOD_CONTRACT; return this; }
- virtual MethodTable *GetDeclMethodTable()
- { LIMITED_METHOD_CONTRACT; return m_pMT; }
virtual MethodDesc *GetDeclMethodDesc(UINT32 slotNumber);
virtual MethodData *GetImplMethodData()
{ LIMITED_METHOD_CONTRACT; return this; }
- virtual MethodTable *GetImplMethodTable()
- { LIMITED_METHOD_CONTRACT; return m_pMT; }
virtual DispatchSlot GetImplSlot(UINT32 slotNumber);
virtual UINT32 GetImplSlotNumber(UINT32 slotNumber);
virtual MethodDesc *GetImplMethodDesc(UINT32 slotNumber);
virtual void InvalidateCachedVirtualSlot(UINT32 slotNumber);
virtual UINT32 GetNumVirtuals()
- { LIMITED_METHOD_CONTRACT; return m_pMT->GetNumVirtuals(); }
+ { LIMITED_METHOD_CONTRACT; return m_pDeclMT->GetNumVirtuals(); }
virtual UINT32 GetNumMethods()
- { LIMITED_METHOD_CONTRACT; return m_pMT->GetCanonicalMethodTable()->GetNumMethods(); }
+ { LIMITED_METHOD_CONTRACT; return m_pDeclMT->GetCanonicalMethodTable()->GetNumMethods(); }
protected:
- void Init(MethodTable *pMT, MethodData *pParentData);
+ void Init(MethodData *pParentData);
BOOL PopulateNextLevel();
- // This is the method table for the actual type we're gathering the data for
- MethodTable *m_pMT;
-
// This is used in staged map decoding - it indicates which type we will next decode.
UINT32 m_iNextChainDepth;
static const UINT32 MAX_CHAIN_DEPTH = UINT32_MAX;
@@ -3393,12 +3388,11 @@ protected:
{ LIMITED_METHOD_CONTRACT; return sizeof(MethodDataInterface); }
// Constructor. Make sure you have allocated enough memory using GetObjectSize.
- MethodDataInterface(MethodTable *pMT)
+ MethodDataInterface(MethodTable *pMT) : MethodData(pMT, pMT)
{
LIMITED_METHOD_CONTRACT;
CONSISTENCY_CHECK(CheckPointer(pMT));
CONSISTENCY_CHECK(pMT->IsInterface());
- m_pMT = pMT;
}
virtual ~MethodDataInterface()
{ LIMITED_METHOD_CONTRACT; }
@@ -3408,8 +3402,6 @@ protected:
//
virtual MethodData *GetDeclMethodData()
{ LIMITED_METHOD_CONTRACT; return this; }
- virtual MethodTable *GetDeclMethodTable()
- { LIMITED_METHOD_CONTRACT; return m_pMT; }
virtual MethodDesc *GetDeclMethodDesc(UINT32 slotNumber);
//
@@ -3417,10 +3409,8 @@ protected:
//
virtual MethodData *GetImplMethodData()
{ LIMITED_METHOD_CONTRACT; return this; }
- virtual MethodTable *GetImplMethodTable()
- { LIMITED_METHOD_CONTRACT; return m_pMT; }
virtual DispatchSlot GetImplSlot(UINT32 slotNumber)
- { WRAPPER_NO_CONTRACT; return DispatchSlot(m_pMT->GetRestoredSlot(slotNumber)); }
+ { WRAPPER_NO_CONTRACT; return DispatchSlot(m_pDeclMT->GetRestoredSlot(slotNumber)); }
virtual UINT32 GetImplSlotNumber(UINT32 slotNumber)
{ LIMITED_METHOD_CONTRACT; return slotNumber; }
virtual MethodDesc *GetImplMethodDesc(UINT32 slotNumber);
@@ -3430,13 +3420,9 @@ protected:
// Slot count data
//
virtual UINT32 GetNumVirtuals()
- { LIMITED_METHOD_CONTRACT; return m_pMT->GetNumVirtuals(); }
+ { LIMITED_METHOD_CONTRACT; return m_pDeclMT->GetNumVirtuals(); }
virtual UINT32 GetNumMethods()
- { LIMITED_METHOD_CONTRACT; return m_pMT->GetNumMethods(); }
-
- protected:
- // This is the method table for the actual type we're gathering the data for
- MethodTable *m_pMT;
+ { LIMITED_METHOD_CONTRACT; return m_pDeclMT->GetNumMethods(); }
}; // class MethodDataInterface
//--------------------------------------------------------------------------------------
diff --git a/src/vm/util.cpp b/src/vm/util.cpp
index 2e2648e909..2b2bb236b3 100644
--- a/src/vm/util.cpp
+++ b/src/vm/util.cpp
@@ -1848,10 +1848,6 @@ HMODULE CLRGetModuleHandle(LPCWSTR lpModuleFileName)
}
#endif // !FEATURE_PAL
-LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes);
-BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem);
-BOOL IsRuntimeStarted(DWORD *pdwStartupFlags);
-
void *GetCLRFunction(LPCSTR FunctionName)
{
@@ -1860,19 +1856,7 @@ void *GetCLRFunction(LPCSTR FunctionName)
LIMITED_METHOD_CONTRACT;
- if (strcmp(FunctionName, "EEHeapAllocInProcessHeap") == 0)
- {
- func = (void*)EEHeapAllocInProcessHeap;
- }
- else if (strcmp(FunctionName, "EEHeapFreeInProcessHeap") == 0)
{
- func = (void*)EEHeapFreeInProcessHeap;
- }
- else if (strcmp(FunctionName, "IsRuntimeStarted") == 0)
- {
- func = (void*)IsRuntimeStarted;
- }
- else {
_ASSERTE ("Unknown function name");
func = NULL;
}