diff options
author | Pat Gavlin <pagavlin@microsoft.com> | 2016-04-13 16:06:18 -0700 |
---|---|---|
committer | Pat Gavlin <pagavlin@microsoft.com> | 2016-04-13 16:06:18 -0700 |
commit | aba977ee03f85f059aca1bdb0b0e1202f25d04cd (patch) | |
tree | 5f8bc97014598aa3742fdb2ec0b351de711b1f66 /src/jit/jit.h | |
parent | 517207b9d3f2a53c726a8682c1331cf7bdb0360b (diff) | |
download | coreclr-aba977ee03f85f059aca1bdb0b0e1202f25d04cd.tar.gz coreclr-aba977ee03f85f059aca1bdb0b0e1202f25d04cd.tar.bz2 coreclr-aba977ee03f85f059aca1bdb0b0e1202f25d04cd.zip |
Collect the JIT's TLS variables in a single type.
Instead of storing pointers to the thread-local compiler instance
and the current logging environment in separate TLS slots, wrap
these values in a struct and store a pointer to the struct in a
single TLS slot. This simplifies and standardizes the JIT's interface
to its TLS storage, especially when it is being statically linked
into another program or library that cannot use standard TLS.
Note that for release builds, the logging environment is not used
and a pointer to the current compiler instance is stored directly
into the JIT's TLS slot as an implementation detail of the TLS
wrapper type.
Diffstat (limited to 'src/jit/jit.h')
-rw-r--r-- | src/jit/jit.h | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/src/jit/jit.h b/src/jit/jit.h index 59863a41ae..73e05f25b6 100644 --- a/src/jit/jit.h +++ b/src/jit/jit.h @@ -476,13 +476,13 @@ const bool dspGCtbls = true; #ifdef DEBUG void JitDump(const char* pcFormat, ...); -#define JITDUMP(...) { if (GetTlsCompiler()->verbose) JitDump(__VA_ARGS__); } +#define JITDUMP(...) { if (JitTls::GetCompiler()->verbose) JitDump(__VA_ARGS__); } #define JITLOG(x) { JitLogEE x; } #define JITLOG_THIS(t, x) { (t)->JitLogEE x; } #define DBEXEC(flg, expr) if (flg) {expr;} -#define DISPNODE(t) if (GetTlsCompiler()->verbose) GetTlsCompiler()->gtDispTree(t, nullptr, nullptr, true); -#define DISPTREE(x) if (GetTlsCompiler()->verbose) GetTlsCompiler()->gtDispTree(x) -#define VERBOSE GetTlsCompiler()->verbose +#define DISPNODE(t) if (JitTls::GetCompiler()->verbose) JitTls::GetCompiler()->gtDispTree(t, nullptr, nullptr, true); +#define DISPTREE(x) if (JitTls::GetCompiler()->verbose) JitTls::GetCompiler()->gtDispTree(x) +#define VERBOSE JitTls::GetCompiler()->verbose #else // !DEBUG #define JITDUMP(...) #define JITLOG(x) @@ -813,9 +813,26 @@ enum CompMemKind CMK_Count }; -// These methods are implemented by VM when jit & VM are merged in one dll (eg. coreclr.dll) -Compiler* GetTlsCompiler(); -void SetTlsCompiler(Compiler* c); +class Compiler; +class JitTls +{ +#ifdef DEBUG + Compiler* m_compiler; + LogEnv m_logEnv; + JitTls* m_next; +#endif + +public: + JitTls(ICorJitInfo* jitInfo); + ~JitTls(); + +#ifdef DEBUG + static LogEnv* GetLogEnv(); +#endif + + static Compiler* GetCompiler(); + static void SetCompiler(Compiler* compiler); +}; #if defined(DEBUG) @@ -824,13 +841,13 @@ void SetTlsCompiler(Compiler* c); template<typename T> T dspPtr(T p) { - return (p == 0) ? 0 : (GetTlsCompiler()->opts.dspDiffable ? T(0xD1FFAB1E) : p); + return (p == 0) ? 0 : (JitTls::GetCompiler()->opts.dspDiffable ? T(0xD1FFAB1E) : p); } template<typename T> T dspOffset(T o) { - return (o == 0) ? 0 : (GetTlsCompiler()->opts.dspDiffable ? T(0xD1FFAB1E) : o); + return (o == 0) ? 0 : (JitTls::GetCompiler()->opts.dspDiffable ? T(0xD1FFAB1E) : o); } #else // !defined(DEBUG) |