From e98c471075c236bcdbd6dca7c3490ac875dd85d3 Mon Sep 17 00:00:00 2001 From: Andrew Au Date: Wed, 1 Apr 2020 19:27:21 -0700 Subject: [PATCH] Eliminate dead configuration code (#34285) * Eliminate dead configuration code * Remove more dead code * Eliminating EEConfig::GetConfiguration_DontUse_ * Eliminate EEConfig::GetConfigValueCallback * Eliminate ConfigSearch --- src/coreclr/src/inc/clrconfig.h | 10 - src/coreclr/src/inc/clrconfigvalues.h | 1 - src/coreclr/src/utilcode/clrconfig.cpp | 121 ------------ src/coreclr/src/vm/eeconfig.cpp | 342 +-------------------------------- src/coreclr/src/vm/eeconfig.h | 228 +--------------------- 5 files changed, 12 insertions(+), 690 deletions(-) diff --git a/src/coreclr/src/inc/clrconfig.h b/src/coreclr/src/inc/clrconfig.h index 62d6db6..4f0cb11 100644 --- a/src/coreclr/src/inc/clrconfig.h +++ b/src/coreclr/src/inc/clrconfig.h @@ -66,10 +66,6 @@ public: 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 @@ public: // 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/inc/clrconfigvalues.h b/src/coreclr/src/inc/clrconfigvalues.h index 175a376..fc711dc 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/utilcode/clrconfig.cpp b/src/coreclr/src/utilcode/clrconfig.cpp index f28ef55..e52afa5 100644 --- a/src/coreclr/src/utilcode/clrconfig.cpp +++ b/src/coreclr/src/utilcode/clrconfig.cpp @@ -19,12 +19,6 @@ #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 // @@ -127,39 +121,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. // if(CheckLookupOption(info, FavorConfigFile) == TRUE) @@ -248,41 +209,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. // if (CheckLookupOption(info, FavorConfigFile) == TRUE) @@ -402,31 +328,6 @@ HRESULT CLRConfig::GetConfigValue(const ConfigStringInfo & info, __deref_out_z L } // - // 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. // if(result==NULL && @@ -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; @@ -590,16 +479,6 @@ void CLRConfig::FreeConfigString(__in_z LPWSTR 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. // //static diff --git a/src/coreclr/src/vm/eeconfig.cpp b/src/coreclr/src/vm/eeconfig.cpp index dc43f14..c976380 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) @@ -356,32 +299,9 @@ 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; } -#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() { @@ -392,30 +312,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) - { - 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 - if (m_fFreepZapSet) delete[] pZapSet; delete[] szZapBBInstr; @@ -485,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; @@ -496,24 +392,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; } @@ -523,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; @@ -533,25 +412,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); } // @@ -560,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; @@ -570,80 +431,14 @@ 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; + return REGUTIL::GetConfigULONGLONG_DontUse_(name, defValue, (REGUTIL::CORConfigLevel)level, fPrependCOMPLUS); } // // 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; -} - -// -// 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; @@ -653,24 +448,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); } /**************************************************************/ @@ -1298,110 +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)); - - 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(); - 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; - } -} - 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 e28f648..cd9deac 100644 --- a/src/coreclr/src/vm/eeconfig.h +++ b/src/coreclr/src/vm/eeconfig.h @@ -41,199 +41,6 @@ public: }; #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, @@ -248,12 +55,6 @@ enum ParseCtl { class EEConfig { public: - typedef enum { - CONFIG_SYSTEM, - CONFIG_APPLICATION, - CONFIG_SYSTEMONLY - } ConfigSearch; - static HRESULT Setup(); HRESULT Init(); @@ -705,16 +506,11 @@ public: // 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. // - 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. @@ -722,8 +518,7 @@ public: // 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. @@ -731,16 +526,7 @@ public: // static ULONGLONG GetConfigULONGLONG_DontUse_(__in_z LPCWSTR name, ULONGLONG 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. - // 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); + BOOL fPrependCOMPLUS = TRUE); // // NOTE: The following function is deprecated; use the CLRConfig class instead. @@ -1007,9 +793,6 @@ private: //---------------------------------------------------------------- #endif // _DEBUG - // New configuration - ConfigList m_Configuration; - #ifdef _DEBUG DWORD dwNgenForceFailureMask; DWORD dwNgenForceFailureCount; @@ -1057,12 +840,9 @@ private: //---------------------------------------------------------------- #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, - ConfigSearch direction = CONFIG_SYSTEM); + BOOL fPrependCOMPLUS = TRUE); enum BitForMask { CallSite_1 = 0x0001, -- 2.7.4