Skip to content

Commit

Permalink
Simplify jitconfigvalues.h (#100704)
Browse files Browse the repository at this point in the history
* Simplify jitconfigvalues.h

It's been confusing to know if a configuration switch is available
in DEBUG or non-DEBUG (Release) builds because you need to figure
out which `ifdef` section it is defined in.

This simplifies it by eliminating `#ifdef DEBUG` in jitconfigvalues.h.
Each config variable is explicitly using `CONFIG_...` for DEBUG or
`RELEASE_CONFIG_...` for non-DEBUG builds.

I reformatted some of the CONFIG definitions to put the comments before
the CONFIG definition instead of on the same line, so they read better
after jit-format processes them.

* Fix OPT_CONFIG defines
  • Loading branch information
BruceForstall authored Apr 9, 2024
1 parent 656f340 commit f6f9199
Show file tree
Hide file tree
Showing 4 changed files with 393 additions and 349 deletions.
2 changes: 1 addition & 1 deletion src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3031,7 +3031,7 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
codeGen->setVerbose(true);
}

treesBeforeAfterMorph = (JitConfig.TreesBeforeAfterMorph() == 1);
treesBeforeAfterMorph = (JitConfig.JitDumpBeforeAfterMorph() == 1);
morphNum = 0; // Initialize the morphed-trees counting.

expensiveDebugCheckLevel = JitConfig.JitExpensiveDebugCheckLevel();
Expand Down
12 changes: 6 additions & 6 deletions src/coreclr/jit/jitconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ void JitConfigValues::initialize(ICorJitHost* host)
{
assert(!m_isInitialized);

#define CONFIG_INTEGER(name, key, defaultValue) m_##name = host->getIntConfigValue(key, defaultValue);
#define CONFIG_STRING(name, key) m_##name = host->getStringConfigValue(key);
#define CONFIG_METHODSET(name, key) \
#define RELEASE_CONFIG_INTEGER(name, key, defaultValue) m_##name = host->getIntConfigValue(key, defaultValue);
#define RELEASE_CONFIG_STRING(name, key) m_##name = host->getStringConfigValue(key);
#define RELEASE_CONFIG_METHODSET(name, key) \
const WCHAR* name##value = host->getStringConfigValue(key); \
m_##name.initialize(name##value, host); \
host->freeStringConfigValue(name##value);
Expand All @@ -211,9 +211,9 @@ void JitConfigValues::destroy(ICorJitHost* host)
return;
}

#define CONFIG_INTEGER(name, key, defaultValue)
#define CONFIG_STRING(name, key) host->freeStringConfigValue(m_##name);
#define CONFIG_METHODSET(name, key) m_##name.destroy(host);
#define RELEASE_CONFIG_INTEGER(name, key, defaultValue)
#define RELEASE_CONFIG_STRING(name, key) host->freeStringConfigValue(m_##name);
#define RELEASE_CONFIG_METHODSET(name, key) m_##name.destroy(host);

#include "jitconfigvalues.h"

Expand Down
15 changes: 9 additions & 6 deletions src/coreclr/jit/jitconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,30 @@ class JitConfigValues
};

private:
#define CONFIG_INTEGER(name, key, defaultValue) int m_##name;
#define CONFIG_STRING(name, key) const WCHAR* m_##name;
#define CONFIG_METHODSET(name, key) MethodSet m_##name;

#define RELEASE_CONFIG_INTEGER(name, key, defaultValue) int m_##name;
#define RELEASE_CONFIG_STRING(name, key) const WCHAR* m_##name;
#define RELEASE_CONFIG_METHODSET(name, key) MethodSet m_##name;

#include "jitconfigvalues.h"

public:
#define CONFIG_INTEGER(name, key, defaultValue) \
#define RELEASE_CONFIG_INTEGER(name, key, defaultValue) \
inline int name() const \
{ \
return m_##name; \
}
#define CONFIG_STRING(name, key) \
#define RELEASE_CONFIG_STRING(name, key) \
inline const WCHAR* name() const \
{ \
return m_##name; \
}
#define CONFIG_METHODSET(name, key) \
#define RELEASE_CONFIG_METHODSET(name, key) \
inline const MethodSet& name() const \
{ \
return m_##name; \
}

#include "jitconfigvalues.h"

private:
Expand Down
Loading

0 comments on commit f6f9199

Please sign in to comment.