* It should reflect the usefulness:overhead ratio.
*/
-const LPCWSTR Compiler::s_compStressModeNames[STRESS_COUNT + 1] = {
+const LPCWSTR Compiler::s_compStressModeNamesW[STRESS_COUNT + 1] = {
#define STRESS_MODE(mode) W("STRESS_") W(#mode),
STRESS_MODES
#undef STRESS_MODE
};
+const char* Compiler::s_compStressModeNames[STRESS_COUNT + 1] = {
+#define STRESS_MODE(mode) "STRESS_" #mode,
+
+ STRESS_MODES
+#undef STRESS_MODE
+};
+
//------------------------------------------------------------------------
// compStressCompile: determine if a stress mode should be enabled
//
{
if (verbose)
{
- printf("\n\n*** JitStress: %ws ***\n\n", s_compStressModeNames[stressArea]);
+ printf("\n\n*** JitStress: %s ***\n\n", s_compStressModeNames[stressArea]);
}
compActiveStressModes[stressArea] = 1;
}
}
//------------------------------------------------------------------------
+// compStressAreaHash: Get (or compute) a hash code for a stress area.
+//
+// Arguments:
+// stressArea - stress mode
+//
+// Returns:
+// A hash code for the specific stress area.
+//
+unsigned Compiler::compStressAreaHash(compStressArea area)
+{
+ static LONG s_hashCodes[STRESS_COUNT];
+ assert(static_cast<unsigned>(area) < ArrLen(s_hashCodes));
+
+ unsigned result = (unsigned)s_hashCodes[area];
+ if (result == 0)
+ {
+ result = HashStringA(s_compStressModeNames[area]);
+ if (result == 0)
+ {
+ result = 1;
+ }
+
+ InterlockedExchange(&s_hashCodes[area], (LONG)result);
+ }
+
+ return result;
+}
+
+//------------------------------------------------------------------------
// compStressCompileHelper: helper to determine if a stress mode should be enabled
//
// Arguments:
// Does user explicitly prevent using this STRESS_MODE through the command line?
const WCHAR* strStressModeNamesNot = JitConfig.JitStressModeNamesNot();
if ((strStressModeNamesNot != nullptr) &&
- (wcsstr(strStressModeNamesNot, s_compStressModeNames[stressArea]) != nullptr))
+ (wcsstr(strStressModeNamesNot, s_compStressModeNamesW[stressArea]) != nullptr))
{
return false;
}
const WCHAR* strStressModeNames = JitConfig.JitStressModeNames();
if (strStressModeNames != nullptr)
{
- if (wcsstr(strStressModeNames, s_compStressModeNames[stressArea]) != nullptr)
+ if (wcsstr(strStressModeNames, s_compStressModeNamesW[stressArea]) != nullptr)
{
return true;
}
// Get a hash which can be compared with 'weight'
assert(stressArea != 0);
- const unsigned hash = (info.compMethodHash() ^ stressArea ^ stressLevel) % MAX_STRESS_WEIGHT;
+ const unsigned hash = (info.compMethodHash() ^ compStressAreaHash(stressArea) ^ stressLevel) % MAX_STRESS_WEIGHT;
assert(hash < MAX_STRESS_WEIGHT && weight <= MAX_STRESS_WEIGHT);
return (hash < weight);
STRESS_MODE(MAKE_CSE) \
STRESS_MODE(LEGACY_INLINE) \
STRESS_MODE(CLONE_EXPR) \
- STRESS_MODE(USE_CMOV) \
STRESS_MODE(FOLD) \
STRESS_MODE(MERGED_RETURNS) \
STRESS_MODE(BB_PROFILE) \
// clang-format on
#ifdef DEBUG
- static const LPCWSTR s_compStressModeNames[STRESS_COUNT + 1];
+ static const LPCWSTR s_compStressModeNamesW[STRESS_COUNT + 1];
+ static const char* s_compStressModeNames[STRESS_COUNT + 1];
BYTE compActiveStressModes[STRESS_COUNT];
#endif // DEBUG
bool compStressCompile(compStressArea stressArea, unsigned weightPercentage);
bool compStressCompileHelper(compStressArea stressArea, unsigned weightPercentage);
+ static unsigned compStressAreaHash(compStressArea area);
#ifdef DEBUG