Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate dead configuration code #34285

Merged
merged 5 commits into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/coreclr/src/inc/clrconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/src/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
121 changes: 0 additions & 121 deletions src/coreclr/src/utilcode/clrconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down Expand Up @@ -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.
//
Expand Down Expand Up @@ -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.
//
Expand Down Expand Up @@ -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.
//
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
//
Expand Down
Loading