summaryrefslogtreecommitdiff
path: root/src/inc
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 /src/inc
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
Diffstat (limited to 'src/inc')
-rw-r--r--src/inc/clrhost.h13
-rw-r--r--src/inc/stgpool.h36
2 files changed, 43 insertions, 6 deletions
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