From e41441b7078572c4ecabbca5ce63cd96a6a9c674 Mon Sep 17 00:00:00 2001 From: Andrew Au Date: Mon, 30 Mar 2020 11:25:50 -0700 Subject: [PATCH 1/5] Eliminate dead configuration code --- src/coreclr/src/vm/eeconfig.cpp | 140 +---------------------- src/coreclr/src/vm/eeconfig.h | 196 -------------------------------- 2 files changed, 2 insertions(+), 334 deletions(-) diff --git a/src/coreclr/src/vm/eeconfig.cpp b/src/coreclr/src/vm/eeconfig.cpp index dc43f141eabf5..6bf3effec1b03 100644 --- a/src/coreclr/src/vm/eeconfig.cpp +++ b/src/coreclr/src/vm/eeconfig.cpp @@ -40,63 +40,6 @@ using namespace clr; Volatile GCStressPolicy::InhibitHolder::s_nGcStressDisabled = 0; #endif // STRESS_HEAP - -ConfigSource::ConfigSource() -{ - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - FORBID_FAULT; - } CONTRACTL_END; - - m_pNext = this; - m_pPrev = this; -}// ConfigSource::ConfigSource - -ConfigSource::~ConfigSource() -{ - CONTRACTL { - NOTHROW; - FORBID_FAULT; - GC_NOTRIGGER; - MODE_ANY; - } CONTRACTL_END; - - for(ConfigStringHashtable::Iterator iter = m_Table.Begin(), end = m_Table.End(); iter != end; iter++) - { - ConfigStringKeyValuePair * pair = *(iter); - delete[] pair->key; - delete[] pair->value; - delete pair; - } -}// ConfigSource::~ConfigSource - -ConfigStringHashtable * ConfigSource::Table() -{ - LIMITED_METHOD_CONTRACT; - return &(m_Table); -}// ConfigSource::Table - -void ConfigSource::Add(ConfigSource* prev) -{ - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - PRECONDITION(CheckPointer(prev)); - PRECONDITION(CheckPointer(prev->m_pNext)); - } CONTRACTL_END; - - m_pPrev = prev; - m_pNext = prev->m_pNext; - - m_pNext->m_pPrev = this; - prev->m_pNext = this; -}// ConfigSource::Add - - - /**************************************************************/ // Poor mans narrow LPUTF8 NarrowWideChar(__inout_z LPWSTR str) @@ -364,24 +307,6 @@ HRESULT EEConfig::Init() return S_OK; } -#ifdef _DEBUG -static int DumpConfigTable(ConfigStringHashtable* table, __in_z LPCSTR label, int count) -{ - LIMITED_METHOD_CONTRACT; - LOG((LF_ALWAYS, LL_ALWAYS, label, count++)); - LOG((LF_ALWAYS, LL_ALWAYS, "*********************************\n", count++)); - for(ConfigStringHashtable::Iterator iter = table->Begin(), end = table->End(); iter != end; iter++) - { - ConfigStringKeyValuePair * pair = *(iter); - LPCWSTR keyString = pair->key; - LPCWSTR data = pair->value; - LOG((LF_ALWAYS, LL_ALWAYS, "%S = %S\n", keyString, data)); - } - LOG((LF_ALWAYS, LL_ALWAYS, "\n")); - return count; -} -#endif - /**************************************************************/ HRESULT EEConfig::Cleanup() { @@ -400,18 +325,7 @@ HRESULT EEConfig::Cleanup() DWORD setting = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_DumpConfiguration); if (setting != 0) { - ConfigList::ConfigIter iter(&m_Configuration); - int count = 0; - for(ConfigStringHashtable* table = iter.Next();table; table = iter.Next()) - { - count = DumpConfigTable(table, "\nSystem Configuration Table: %d\n", count); - } - ConfigList::ConfigIter iter2(&m_Configuration); - count = 0; - for (ConfigStringHashtable* table = iter2.Previous();table; table = iter2.Previous()) - { - count = DumpConfigTable(table, "\nApplication Configuration Table: %d\n", count); - } + } } #endif @@ -1347,59 +1261,9 @@ HRESULT EEConfig::GetConfiguration_DontUse_(__in_z LPCWSTR pKey, ConfigSearch di } CONTRACT_END; Thread *pThread = GetThread(); - ConfigStringKeyValuePair * pair = NULL; *pValue = NULL; - ConfigList::ConfigIter iter(&m_Configuration); - - switch(direction) { - case CONFIG_SYSTEMONLY: - { - // for things that only admin should be able to set - ConfigStringHashtable* table = iter.Next(); - if(table != NULL) - { - pair = table->Lookup(pKey); - if(pair != NULL) - { - *pValue = pair->value; - RETURN S_OK; - } - } - RETURN E_FAIL; - } - case CONFIG_SYSTEM: - { - for(ConfigStringHashtable* table = iter.Next(); - table != NULL; - table = iter.Next()) - { - pair = table->Lookup(pKey); - if(pair != NULL) - { - *pValue = pair->value; - RETURN S_OK; - } - } - RETURN E_FAIL; - } - case CONFIG_APPLICATION: { - for(ConfigStringHashtable* table = iter.Previous(); - table != NULL; - table = iter.Previous()) - { - pair = table->Lookup(pKey); - if(pair != NULL) - { - *pValue = pair->value; - RETURN S_OK; - } - } - RETURN E_FAIL; - } - default: - RETURN E_FAIL; - } + RETURN E_FAIL; } bool EEConfig::RequireZap(LPCUTF8 assemblyName) const diff --git a/src/coreclr/src/vm/eeconfig.h b/src/coreclr/src/vm/eeconfig.h index e28f64834ebe3..cc1819f8bd766 100644 --- a/src/coreclr/src/vm/eeconfig.h +++ b/src/coreclr/src/vm/eeconfig.h @@ -41,199 +41,6 @@ class TypeNamesList }; #endif -typedef struct _ConfigStringKeyValuePair -{ - WCHAR * key; - WCHAR * value; - - _ConfigStringKeyValuePair() - { - key = NULL; - value = NULL; - } - - WCHAR * GetKey() - { - return key; - } -} ConfigStringKeyValuePair; - -typedef WStringSHash ConfigStringHashtable; - -class ConfigList; - -// -// Holds a pointer to a hashtable that is populated with data from config files. -// Also acts as a node for a circular doubly-linked list. -// -class ConfigSource -{ - friend class ConfigList; -public: - ConfigSource(); - ~ConfigSource(); - - ConfigStringHashtable* Table(); - - // - // Connect this node into the list that prev is in. - // - void Add(ConfigSource* prev); - - ConfigSource* Next() - { - LIMITED_METHOD_CONTRACT; - return m_pNext; - } - - ConfigSource* Previous() - { - LIMITED_METHOD_CONTRACT; - return m_pPrev; - } - - -private: - ConfigStringHashtable m_Table; - ConfigSource *m_pNext; - ConfigSource *m_pPrev; -}; - -// -// Wrapper around the ConfigSource circular doubly-linked list. -// -class ConfigList -{ -public: - // - // Iterator for traversing through a ConfigList. - // - class ConfigIter - { - public: - ConfigIter(ConfigList* pList) - { - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - // MODE_ANY; - FORBID_FAULT; - } CONTRACTL_END; - - pEnd = &(pList->m_pElement); - pCurrent = pEnd; - } - - // - // TODO: Check if iterating through the list once skips an element. - // Returns the next node. If the next node is the head, returns null. - // Note that iteration can be resumed by calling next again. - // - ConfigStringHashtable* Next() - { - CONTRACT (ConfigStringHashtable*) { - NOTHROW; - GC_NOTRIGGER; - // MODE_ANY; - FORBID_FAULT; - POSTCONDITION(CheckPointer(RETVAL, NULL_OK)); - } CONTRACT_END; - - pCurrent = pCurrent->Next();; - if(pCurrent == pEnd) - RETURN NULL; - else - RETURN pCurrent->Table(); - } - - ConfigStringHashtable* Previous() - { - CONTRACT (ConfigStringHashtable*) { - NOTHROW; - GC_NOTRIGGER; - FORBID_FAULT; - // MODE_ANY; - POSTCONDITION(CheckPointer(RETVAL, NULL_OK)); - } CONTRACT_END; - - pCurrent = pCurrent->Previous(); - if(pCurrent == pEnd) - RETURN NULL; - else - RETURN pCurrent->Table(); - } - - private: - ConfigSource* pEnd; - ConfigSource* pCurrent; - }; - - ConfigStringHashtable* Add() - { - CONTRACT (ConfigStringHashtable*) { - NOTHROW; - GC_NOTRIGGER; - // MODE_ANY; - POSTCONDITION(CheckPointer(RETVAL, NULL_OK)); - } CONTRACT_END; - - ConfigSource* pEntry = new (nothrow) ConfigSource(); - - if (pEntry == NULL) - RETURN NULL; - - pEntry->Add(&m_pElement); - RETURN pEntry->Table(); - } - - ConfigStringHashtable* Append() - { - CONTRACT (ConfigStringHashtable*) { - NOTHROW; - GC_NOTRIGGER; - // MODE_ANY; - POSTCONDITION(CheckPointer(RETVAL, NULL_OK)); - } CONTRACT_END; - - ConfigSource* pEntry = new (nothrow) ConfigSource(); - if (pEntry == NULL) - RETURN NULL; - - pEntry->Add(m_pElement.Previous()); - RETURN pEntry->Table(); - } - - void Append(ConfigSource * pEntry) - { - LIMITED_METHOD_CONTRACT; - PRECONDITION(CheckPointer(pEntry)); - - pEntry->Add(m_pElement.Previous()); - } - - ~ConfigList() - { - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - // MODE_ANY; - FORBID_FAULT; - } CONTRACTL_END; - - ConfigSource* pNext = m_pElement.Next(); - while(pNext != &m_pElement) { - ConfigSource *last = pNext; - pNext = pNext->m_pNext; - delete last; - } - } - -friend class ConfigIter; - -private: - ConfigSource m_pElement; -}; - enum { OPT_BLENDED, OPT_SIZE, OPT_SPEED, @@ -1007,9 +814,6 @@ class EEConfig #endif // _DEBUG - // New configuration - ConfigList m_Configuration; - #ifdef _DEBUG DWORD dwNgenForceFailureMask; DWORD dwNgenForceFailureCount; From df43b1160fffdf4999a92bebe4712f0ccf5d0568 Mon Sep 17 00:00:00 2001 From: Andrew Au Date: Tue, 31 Mar 2020 09:04:58 -0700 Subject: [PATCH 2/5] Remove more dead code --- src/coreclr/src/inc/clrconfigvalues.h | 1 - src/coreclr/src/vm/eeconfig.cpp | 13 ------------- 2 files changed, 14 deletions(-) diff --git a/src/coreclr/src/inc/clrconfigvalues.h b/src/coreclr/src/inc/clrconfigvalues.h index 175a376b18f57..fc711dc2f18c9 100644 --- a/src/coreclr/src/inc/clrconfigvalues.h +++ b/src/coreclr/src/inc/clrconfigvalues.h @@ -773,7 +773,6 @@ CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_CPUFeatures, W("CPUFeatures"), "") RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_DisableConfigCache, W("DisableConfigCache"), 0, "Used to disable the \"probabilistic\" config cache, which walks through the appropriate config registry keys on init and probabilistically keeps track of which exist.", CLRConfig::REGUTIL_default) RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_DisableStackwalkCache, W("DisableStackwalkCache"), "") RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_DoubleArrayToLargeObjectHeap, W("DoubleArrayToLargeObjectHeap"), "Controls double[] placement") -CONFIG_DWORD_INFO(INTERNAL_DumpConfiguration, W("DumpConfiguration"), 0, "Dumps runtime properties of xml configuration files to the log.") CONFIG_STRING_INFO(INTERNAL_DumpOnClassLoad, W("DumpOnClassLoad"), "Dumps information about loaded class to log.") CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_ExpandAllOnLoad, W("ExpandAllOnLoad"), "") CONFIG_STRING_INFO_DIRECT_ACCESS(INTERNAL_ForcedRuntime, W("ForcedRuntime"), "Verify version of CLR loaded") diff --git a/src/coreclr/src/vm/eeconfig.cpp b/src/coreclr/src/vm/eeconfig.cpp index 6bf3effec1b03..31f690716f29f 100644 --- a/src/coreclr/src/vm/eeconfig.cpp +++ b/src/coreclr/src/vm/eeconfig.cpp @@ -317,19 +317,6 @@ HRESULT EEConfig::Cleanup() MODE_ANY; } CONTRACTL_END; -#ifdef _DEBUG - if (g_pConfig) { - // TODO: Do we even need this? CLRConfig::GetConfigValue has FORBID_FAULT in its contract. - FAULT_NOT_FATAL(); // If GetConfigValue fails the alloc, that's ok. - - DWORD setting = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_DumpConfiguration); - if (setting != 0) - { - - } - } -#endif - if (m_fFreepZapSet) delete[] pZapSet; delete[] szZapBBInstr; From 2ab03709d21caed5299864cc355cedbccd9603f7 Mon Sep 17 00:00:00 2001 From: Andrew Au Date: Tue, 31 Mar 2020 12:17:52 -0700 Subject: [PATCH 3/5] Eliminating EEConfig::GetConfiguration_DontUse_ --- src/coreclr/src/vm/eeconfig.cpp | 160 +------------------------------- src/coreclr/src/vm/eeconfig.h | 10 -- 2 files changed, 5 insertions(+), 165 deletions(-) diff --git a/src/coreclr/src/vm/eeconfig.cpp b/src/coreclr/src/vm/eeconfig.cpp index 31f690716f29f..1b5a2edf4a93d 100644 --- a/src/coreclr/src/vm/eeconfig.cpp +++ b/src/coreclr/src/vm/eeconfig.cpp @@ -397,24 +397,7 @@ HRESULT EEConfig::GetConfigString_DontUse_(__in_z LPCWSTR name, __deref_out_z LP POSTCONDITION(CheckPointer(outVal, NULL_OK)); } CONTRACT_END; - LPWSTR pvalue = REGUTIL::GetConfigString_DontUse_(name, fPrependCOMPLUS); - if(pvalue == NULL && g_pConfig != NULL) - { - LPCWSTR pResult; - if(SUCCEEDED(g_pConfig->GetConfiguration_DontUse_(name, direction, &pResult)) && pResult != NULL) - { - size_t len = wcslen(pResult) + 1; - pvalue = new (nothrow) WCHAR[len]; - if (pvalue == NULL) - { - RETURN E_OUTOFMEMORY; - } - - wcscpy_s(pvalue,len,pResult); - } - } - - *outVal = pvalue; + *outVal = REGUTIL::GetConfigString_DontUse_(name, fPrependCOMPLUS); RETURN S_OK; } @@ -434,25 +417,7 @@ DWORD EEConfig::GetConfigDWORD_DontUse_(__in_z LPCWSTR name, DWORD defValue, DWO } CONTRACTL_END; // @TODO: After everyone has moved off registry, key remove the following line in golden - DWORD result = REGUTIL::GetConfigDWORD_DontUse_(name, defValue, (REGUTIL::CORConfigLevel)level, fPrependCOMPLUS); - if(result == defValue && g_pConfig != NULL) - { - LPCWSTR pvalue; - if(SUCCEEDED(g_pConfig->GetConfiguration_DontUse_(name, direction, &pvalue)) && pvalue != NULL) - { - WCHAR *end; - errno = 0; - result = wcstoul(pvalue, &end, 0); - // errno is ERANGE if the number is out of range, and end is set to pvalue if - // no valid conversion exists. - if (errno == ERANGE || end == pvalue) - { - result = defValue; - } - } - } - - return result; + return REGUTIL::GetConfigDWORD_DontUse_(name, defValue, (REGUTIL::CORConfigLevel)level, fPrependCOMPLUS); } // @@ -471,73 +436,7 @@ ULONGLONG EEConfig::GetConfigULONGLONG_DontUse_(__in_z LPCWSTR name, ULONGLONG d } CONTRACTL_END; // @TODO: After everyone has moved off registry, key remove the following line in golden - ULONGLONG result = REGUTIL::GetConfigULONGLONG_DontUse_(name, defValue, (REGUTIL::CORConfigLevel)level, fPrependCOMPLUS); - if(result == defValue && g_pConfig != NULL) - { - LPCWSTR pvalue; - if(SUCCEEDED(g_pConfig->GetConfiguration_DontUse_(name, direction, &pvalue)) && pvalue != NULL) - { - WCHAR *end; - errno = 0; - result = _wcstoui64(pvalue, &end, 0); - // errno is ERANGE if the number is out of range, and end is set to pvalue if - // no valid conversion exists. - if (errno == ERANGE || end == pvalue) - { - result = defValue; - } - } - } - - return result; -} - -// -// NOTE: This function is deprecated; use the CLRConfig class instead. -// To use the CLRConfig class, add an entry in file:../inc/CLRConfigValues.h. -// -// This is very similar to GetConfigDWORD, except that it favors the settings in config files over those in the -// registry. This is the Shim's policy with configuration flags, and there are a few flags in EEConfig that adhere -// to this policy. -// -DWORD EEConfig::GetConfigDWORDFavoringConfigFile_DontUse_(__in_z LPCWSTR name, - DWORD defValue, - DWORD level, - BOOL fPrependCOMPLUS, - ConfigSearch direction) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - PRECONDITION(CheckPointer(name)); - } CONTRACTL_END; - - DWORD result = defValue; - - if (g_pConfig != NULL) - { - LPCWSTR pvalue; - if (SUCCEEDED(g_pConfig->GetConfiguration_DontUse_(name, direction, &pvalue)) && pvalue != NULL) - { - WCHAR *end = NULL; - errno = 0; - result = wcstoul(pvalue, &end, 0); - // errno is ERANGE if the number is out of range, and end is set to pvalue if - // no valid conversion exists. - if (errno == ERANGE || end == pvalue) - { - result = defValue; - } - } - else - { - result = REGUTIL::GetConfigDWORD_DontUse_(name, defValue, (REGUTIL::CORConfigLevel)level, fPrependCOMPLUS); - } - } - - return result; + return REGUTIL::GetConfigULONGLONG_DontUse_(name, defValue, (REGUTIL::CORConfigLevel)level, fPrependCOMPLUS); } // @@ -554,24 +453,7 @@ DWORD EEConfig::GetConfigDWORDInternal_DontUse_(__in_z LPCWSTR name, DWORD defVa } CONTRACTL_END; // @TODO: After everyone has moved off registry, key remove the following line in golden - DWORD result = REGUTIL::GetConfigDWORD_DontUse_(name, defValue, (REGUTIL::CORConfigLevel)level, fPrependCOMPLUS); - if(result == defValue) - { - LPCWSTR pvalue; - if(SUCCEEDED(GetConfiguration_DontUse_(name, direction, &pvalue)) && pvalue != NULL) - { - WCHAR *end = NULL; - errno = 0; - result = wcstoul(pvalue, &end, 0); - // errno is ERANGE if the number is out of range, and end is set to pvalue if - // no valid conversion exists. - if (errno == ERANGE || end == pvalue) - { - result = defValue; - } - } - } - return result; + return REGUTIL::GetConfigDWORD_DontUse_(name, defValue, (REGUTIL::CORConfigLevel)level, fPrependCOMPLUS); } /**************************************************************/ @@ -1217,39 +1099,7 @@ HRESULT EEConfig::GetConfigValueCallback(__in_z LPCWSTR pKey, __deref_out_opt LP // Ensure that both options aren't set. _ASSERTE(!(systemOnly && applicationFirst)); - if(g_pConfig != NULL) - { - ConfigSearch direction = CONFIG_SYSTEM; - if(systemOnly) - { - direction = CONFIG_SYSTEMONLY; - } - else if(applicationFirst) - { - direction = CONFIG_APPLICATION; - } - - RETURN g_pConfig->GetConfiguration_DontUse_(pKey, direction, pValue); - } - else - { - RETURN E_FAIL; - } -} - -HRESULT EEConfig::GetConfiguration_DontUse_(__in_z LPCWSTR pKey, ConfigSearch direction, __deref_out_opt LPCWSTR* pValue) -{ - CONTRACT (HRESULT) { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - PRECONDITION(CheckPointer(pValue)); - PRECONDITION(CheckPointer(pKey)); - } CONTRACT_END; - - Thread *pThread = GetThread(); - - *pValue = NULL; + // TODO: Eliminate this function as well. RETURN E_FAIL; } diff --git a/src/coreclr/src/vm/eeconfig.h b/src/coreclr/src/vm/eeconfig.h index cc1819f8bd766..70650d4ab8631 100644 --- a/src/coreclr/src/vm/eeconfig.h +++ b/src/coreclr/src/vm/eeconfig.h @@ -540,14 +540,6 @@ class EEConfig DWORD level=(DWORD) REGUTIL::COR_CONFIG_ALL, BOOL fPrependCOMPLUS = TRUE, ConfigSearch direction = CONFIG_SYSTEM); - // - // NOTE: The following function is deprecated; use the CLRConfig class instead. - // To access a configuration value through CLRConfig, add an entry in file:../inc/CLRConfigValues.h. - // - static DWORD GetConfigDWORDFavoringConfigFile_DontUse_(__in_z LPCWSTR name, DWORD defValue, - DWORD level=(DWORD) REGUTIL::COR_CONFIG_ALL, - BOOL fPrependCOMPLUS = TRUE, - ConfigSearch direction = CONFIG_SYSTEM); // // NOTE: The following function is deprecated; use the CLRConfig class instead. @@ -861,8 +853,6 @@ class EEConfig #endif public: - HRESULT GetConfiguration_DontUse_(__in_z LPCWSTR pKey, ConfigSearch direction, __deref_out_opt LPCWSTR* value); - DWORD GetConfigDWORDInternal_DontUse_ (__in_z LPCWSTR name, DWORD defValue, //for getting data in the constructor of EEConfig DWORD level=(DWORD) REGUTIL::COR_CONFIG_ALL, BOOL fPrependCOMPLUS = TRUE, From eaec04cec413a53bc0d5c215b1160a069e7f2830 Mon Sep 17 00:00:00 2001 From: Andrew Au Date: Wed, 1 Apr 2020 13:01:32 -0700 Subject: [PATCH 4/5] Eliminate EEConfig::GetConfigValueCallback --- src/coreclr/src/inc/clrconfig.h | 10 -- src/coreclr/src/utilcode/clrconfig.cpp | 121 ------------------------- src/coreclr/src/vm/eeconfig.cpp | 27 ------ src/coreclr/src/vm/eeconfig.h | 4 - 4 files changed, 162 deletions(-) diff --git a/src/coreclr/src/inc/clrconfig.h b/src/coreclr/src/inc/clrconfig.h index 62d6db6ab316c..4f0cb11978dd4 100644 --- a/src/coreclr/src/inc/clrconfig.h +++ b/src/coreclr/src/inc/clrconfig.h @@ -66,10 +66,6 @@ class CLRConfig EEConfig_default = 0, }; - // Function pointer definition used for calling EEConfig::GetConfigValueCallback . - typedef HRESULT (* GetConfigValueFunction) - (__in_z LPCWSTR /*pKey*/, __deref_out_opt LPCWSTR* /*value*/, BOOL /*systemOnly*/, BOOL /*applicationFirst*/); - // Struct used to store information about where/how to find a Config DWORD. // NOTE: Please do NOT create instances of this struct. Use the macros in file:CLRConfigValues.h instead. typedef struct ConfigDWORDInfo @@ -182,13 +178,7 @@ class CLRConfig // Free a string returned by GetConfigValue static void FreeConfigString(__in __in_z LPWSTR name); - // Register EEConfig's GetConfigValueCallback function so CLRConfig can look in config files. - static void RegisterGetConfigValueCallback(GetConfigValueFunction func); - private: - // Function pointer to EEConfig's GetConfigValueCallback function (can't static bind from utilcode to VM) - static GetConfigValueFunction s_GetConfigValueCallback; - // Helper method to translate LookupOptions to REGUTIL::CORConfigLevel static REGUTIL::CORConfigLevel GetConfigLevel(LookupOptions options); diff --git a/src/coreclr/src/utilcode/clrconfig.cpp b/src/coreclr/src/utilcode/clrconfig.cpp index f28ef55556ce9..e52afa5471387 100644 --- a/src/coreclr/src/utilcode/clrconfig.cpp +++ b/src/coreclr/src/utilcode/clrconfig.cpp @@ -18,12 +18,6 @@ #define ERANGE 34 #endif -// -// Initialize the EEConfig::GetConfiguration function pointer to NULL. If EEConfig isn't init'ed, this will -// stay NULL and CLRConfig will ignore config files. -// -CLRConfig::GetConfigValueFunction CLRConfig::s_GetConfigValueCallback = NULL; - // // Creating structs using the macro table in CLRConfigValues.h // @@ -126,39 +120,6 @@ BOOL CLRConfig::IsConfigEnabled(const ConfigDWORDInfo & info) } } - // - // Check config files through EEConfig. - // - if(CheckLookupOption(info, IgnoreConfigFiles) == FALSE && // Check that we aren't ignoring config files. - s_GetConfigValueCallback != NULL)// Check that GetConfigValueCallback function has been registered. - { - LPCWSTR pvalue; - - // EEConfig lookup options. - BOOL systemOnly = CheckLookupOption(info, ConfigFile_SystemOnly) ? TRUE : FALSE; - BOOL applicationFirst = CheckLookupOption(info, ConfigFile_ApplicationFirst) ? TRUE : FALSE; - - if(SUCCEEDED(s_GetConfigValueCallback(info.name, &pvalue, systemOnly, applicationFirst)) && pvalue != NULL) - { - WCHAR * end; - errno = 0; - result = wcstoul(pvalue, &end, 0); - - // errno is ERANGE if the number is out of range, and end is set to pvalue if - // no valid conversion exists. - if (errno == ERANGE || end == pvalue) - { - if(pvalue[0]!=0) - return TRUE; - - result = info.defaultValue; - } - - if(result>0) - return TRUE; - } - } - // // If we are favoring config files and we don't have a result from EEConfig, we check REGUTIL here. // @@ -247,41 +208,6 @@ DWORD CLRConfig::GetConfigValue(const ConfigDWORDInfo & info, bool acceptExplici } } - // - // Check config files through EEConfig. - // - if (CheckLookupOption(info, IgnoreConfigFiles) == FALSE && // Check that we aren't ignoring config files. - s_GetConfigValueCallback != NULL)// Check that GetConfigValueCallback function has been registered. - { - LPCWSTR pvalue; - - // EEConfig lookup options. - BOOL systemOnly = CheckLookupOption(info, ConfigFile_SystemOnly) ? TRUE : FALSE; - BOOL applicationFirst = CheckLookupOption(info, ConfigFile_ApplicationFirst) ? TRUE : FALSE; - - if (SUCCEEDED(s_GetConfigValueCallback(info.name, &pvalue, systemOnly, applicationFirst)) && pvalue != NULL) - { - WCHAR * end; - errno = 0; - DWORD resultMaybe = wcstoul(pvalue, &end, 0); - - // errno is ERANGE if the number is out of range, and end is set to pvalue if - // no valid conversion exists. - if (errno != ERANGE && end != pvalue) - { - *isDefault = false; - return resultMaybe; - } - else - { - // If an invalid value is defined we treat it as the default value. - // i.e. we don't look further. - *isDefault = true; - return info.defaultValue; - } - } - } - // // If we are favoring config files and we don't have a result from EEConfig, we check REGUTIL here. // @@ -401,31 +327,6 @@ HRESULT CLRConfig::GetConfigValue(const ConfigStringInfo & info, __deref_out_z L result = REGUTIL::GetConfigString_DontUse_(info.name, prependCOMPlus, level); } - // - // Check config files through EEConfig. - // - if(result == NULL && // Check that we don't have a value from REGUTIL - CheckLookupOption(info, IgnoreConfigFiles) == FALSE && // Check that we aren't ignoring config files. - s_GetConfigValueCallback != NULL) // Check that GetConfigValueCallback function has been registered. - { - LPCWSTR pResult; - - // EEConfig lookup options. - BOOL systemOnly = CheckLookupOption(info, ConfigFile_SystemOnly) ? TRUE : FALSE; - BOOL applicationFirst = CheckLookupOption(info, ConfigFile_ApplicationFirst) ? TRUE : FALSE; - - if(SUCCEEDED(s_GetConfigValueCallback(info.name, &pResult, systemOnly, applicationFirst)) && pResult != NULL) - { - size_t len = wcslen(pResult) + 1; - result = new (nothrow) WCHAR[len]; - if (result == NULL) - { - RETURN E_OUTOFMEMORY; - } - wcscpy_s(result, len, pResult); - } - } - // // If we are favoring config files and we don't have a result from EEConfig, we check REGUTIL here. // @@ -470,18 +371,6 @@ BOOL CLRConfig::IsConfigOptionSpecified(LPCWSTR name) } CONTRACTL_END; - // Check config files - { - LPCWSTR result = NULL; - - if (s_GetConfigValueCallback != NULL && - SUCCEEDED(s_GetConfigValueCallback(name, &result, FALSE, FALSE)) && - result != NULL) - { - return TRUE; - } - } - // Check REGUTIL, both with and without the COMPlus_ prefix { LPWSTR result = NULL; @@ -589,16 +478,6 @@ void CLRConfig::FreeConfigString(__in_z LPWSTR str) delete [] str; } -// -// Register EEConfig's GetConfigValueCallback function so CLRConfig can look in config files. -// -//static -void CLRConfig::RegisterGetConfigValueCallback(GetConfigValueFunction func) -{ - LIMITED_METHOD_CONTRACT; - s_GetConfigValueCallback = func; -} - // // Helper method to translate LookupOptions to REGUTIL::CORConfigLevel. // diff --git a/src/coreclr/src/vm/eeconfig.cpp b/src/coreclr/src/vm/eeconfig.cpp index 1b5a2edf4a93d..fbb3e083b391b 100644 --- a/src/coreclr/src/vm/eeconfig.cpp +++ b/src/coreclr/src/vm/eeconfig.cpp @@ -299,11 +299,6 @@ HRESULT EEConfig::Init() fGDBJitEmitDebugFrame = false; #endif - // After initialization, register the code:#GetConfigValueCallback method with code:CLRConfig to let - // CLRConfig access config files. This is needed because CLRConfig lives outside the VM and can't - // statically link to EEConfig. - CLRConfig::RegisterGetConfigValueCallback(&GetConfigValueCallback); - return S_OK; } @@ -1081,28 +1076,6 @@ fTrackDynamicMethodDebugInfo = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_ return hr; } -// -// #GetConfigValueCallback -// Provides a way for code:CLRConfig to access configuration file values. -// -// static -HRESULT EEConfig::GetConfigValueCallback(__in_z LPCWSTR pKey, __deref_out_opt LPCWSTR* pValue, BOOL systemOnly, BOOL applicationFirst) -{ - CONTRACT (HRESULT) { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - PRECONDITION(CheckPointer(pValue)); - PRECONDITION(CheckPointer(pKey)); - } CONTRACT_END; - - // Ensure that both options aren't set. - _ASSERTE(!(systemOnly && applicationFirst)); - - // TODO: Eliminate this function as well. - RETURN E_FAIL; -} - bool EEConfig::RequireZap(LPCUTF8 assemblyName) const { LIMITED_METHOD_CONTRACT; diff --git a/src/coreclr/src/vm/eeconfig.h b/src/coreclr/src/vm/eeconfig.h index 70650d4ab8631..c5316d6381c45 100644 --- a/src/coreclr/src/vm/eeconfig.h +++ b/src/coreclr/src/vm/eeconfig.h @@ -512,10 +512,6 @@ class EEConfig // Helpers to read configuration - // This function exposes the config file data to CLRConfig. A pointer to this function is passed into CLRConfig on EEConfig::init. - // We are using BOOLs instead of ConfigSearch for direction since CLRConfig isn't always linked to EEConfig. - static HRESULT GetConfigValueCallback(__in_z LPCWSTR pKey, __deref_out_opt LPCWSTR* value, BOOL systemOnly, BOOL applicationFirst); - // // NOTE: The following function is deprecated; use the CLRConfig class instead. // To access a configuration value through CLRConfig, add an entry in file:../inc/CLRConfigValues.h. From 43833bdc9ed7fec93b155da085136ff86b1a9433 Mon Sep 17 00:00:00 2001 From: Andrew Au Date: Wed, 1 Apr 2020 13:57:57 -0700 Subject: [PATCH 5/5] Eliminate ConfigSearch --- src/coreclr/src/vm/eeconfig.cpp | 8 ++++---- src/coreclr/src/vm/eeconfig.h | 18 ++++-------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/coreclr/src/vm/eeconfig.cpp b/src/coreclr/src/vm/eeconfig.cpp index fbb3e083b391b..c976380f94b5f 100644 --- a/src/coreclr/src/vm/eeconfig.cpp +++ b/src/coreclr/src/vm/eeconfig.cpp @@ -381,7 +381,7 @@ HRESULT EEConfig::Cleanup() // NOTE: This function is deprecated; use the CLRConfig class instead. // To use the CLRConfig class, add an entry in file:../inc/CLRConfigValues.h. // -HRESULT EEConfig::GetConfigString_DontUse_(__in_z LPCWSTR name, __deref_out_z LPWSTR *outVal, BOOL fPrependCOMPLUS, ConfigSearch direction) +HRESULT EEConfig::GetConfigString_DontUse_(__in_z LPCWSTR name, __deref_out_z LPWSTR *outVal, BOOL fPrependCOMPLUS) { CONTRACT(HRESULT) { NOTHROW; @@ -402,7 +402,7 @@ HRESULT EEConfig::GetConfigString_DontUse_(__in_z LPCWSTR name, __deref_out_z LP // NOTE: This function is deprecated; use the CLRConfig class instead. // To use the CLRConfig class, add an entry in file:../inc/CLRConfigValues.h. // -DWORD EEConfig::GetConfigDWORD_DontUse_(__in_z LPCWSTR name, DWORD defValue, DWORD level, BOOL fPrependCOMPLUS, ConfigSearch direction) +DWORD EEConfig::GetConfigDWORD_DontUse_(__in_z LPCWSTR name, DWORD defValue, DWORD level, BOOL fPrependCOMPLUS) { CONTRACTL { NOTHROW; @@ -421,7 +421,7 @@ DWORD EEConfig::GetConfigDWORD_DontUse_(__in_z LPCWSTR name, DWORD defValue, DWO // // Note for PAL: right now PAL does not have a _wcstoui64 API, so I am temporarily reading in all numbers as // a 32-bit number. When we have the _wcstoui64 API on MAC we will use that instead of wcstoul. -ULONGLONG EEConfig::GetConfigULONGLONG_DontUse_(__in_z LPCWSTR name, ULONGLONG defValue, DWORD level, BOOL fPrependCOMPLUS, ConfigSearch direction) +ULONGLONG EEConfig::GetConfigULONGLONG_DontUse_(__in_z LPCWSTR name, ULONGLONG defValue, DWORD level, BOOL fPrependCOMPLUS) { CONTRACTL { NOTHROW; @@ -438,7 +438,7 @@ ULONGLONG EEConfig::GetConfigULONGLONG_DontUse_(__in_z LPCWSTR name, ULONGLONG d // NOTE: This function is deprecated; use the CLRConfig class instead. // To use the CLRConfig class, add an entry in file:../inc/CLRConfigValues.h. // -DWORD EEConfig::GetConfigDWORDInternal_DontUse_(__in_z LPCWSTR name, DWORD defValue, DWORD level, BOOL fPrependCOMPLUS, ConfigSearch direction) +DWORD EEConfig::GetConfigDWORDInternal_DontUse_(__in_z LPCWSTR name, DWORD defValue, DWORD level, BOOL fPrependCOMPLUS) { CONTRACTL { NOTHROW; diff --git a/src/coreclr/src/vm/eeconfig.h b/src/coreclr/src/vm/eeconfig.h index c5316d6381c45..cd9deac9658e1 100644 --- a/src/coreclr/src/vm/eeconfig.h +++ b/src/coreclr/src/vm/eeconfig.h @@ -55,12 +55,6 @@ enum ParseCtl { class EEConfig { public: - typedef enum { - CONFIG_SYSTEM, - CONFIG_APPLICATION, - CONFIG_SYSTEMONLY - } ConfigSearch; - static HRESULT Setup(); HRESULT Init(); @@ -516,8 +510,7 @@ class EEConfig // NOTE: The following function is deprecated; use the CLRConfig class instead. // To access a configuration value through CLRConfig, add an entry in file:../inc/CLRConfigValues.h. // - static HRESULT GetConfigString_DontUse_(__in_z LPCWSTR name, __deref_out_z LPWSTR*out, BOOL fPrependCOMPLUS = TRUE, - ConfigSearch direction = CONFIG_SYSTEM); // Note that you own the returned string! + static HRESULT GetConfigString_DontUse_(__in_z LPCWSTR name, __deref_out_z LPWSTR*out, BOOL fPrependCOMPLUS = TRUE); // Note that you own the returned string! // // NOTE: The following function is deprecated; use the CLRConfig class instead. @@ -525,8 +518,7 @@ class EEConfig // static DWORD GetConfigDWORD_DontUse_(__in_z LPCWSTR name, DWORD defValue, DWORD level=(DWORD) REGUTIL::COR_CONFIG_ALL, - BOOL fPrependCOMPLUS = TRUE, - ConfigSearch direction = CONFIG_SYSTEM); + BOOL fPrependCOMPLUS = TRUE); // // NOTE: The following function is deprecated; use the CLRConfig class instead. @@ -534,8 +526,7 @@ class EEConfig // static ULONGLONG GetConfigULONGLONG_DontUse_(__in_z LPCWSTR name, ULONGLONG defValue, DWORD level=(DWORD) REGUTIL::COR_CONFIG_ALL, - BOOL fPrependCOMPLUS = TRUE, - ConfigSearch direction = CONFIG_SYSTEM); + BOOL fPrependCOMPLUS = TRUE); // // NOTE: The following function is deprecated; use the CLRConfig class instead. @@ -851,8 +842,7 @@ class EEConfig DWORD GetConfigDWORDInternal_DontUse_ (__in_z LPCWSTR name, DWORD defValue, //for getting data in the constructor of EEConfig DWORD level=(DWORD) REGUTIL::COR_CONFIG_ALL, - BOOL fPrependCOMPLUS = TRUE, - ConfigSearch direction = CONFIG_SYSTEM); + BOOL fPrependCOMPLUS = TRUE); enum BitForMask { CallSite_1 = 0x0001,