summaryrefslogtreecommitdiff
path: root/src/jit
diff options
context:
space:
mode:
authorPat Gavlin <pagavlin@microsoft.com>2016-02-23 13:53:32 -0800
committerPat Gavlin <pagavlin@microsoft.com>2016-02-23 13:53:32 -0800
commitdfd6ab2348b4b151bb90d3bd7deb6a7304bbafac (patch)
treea81d30ebff326ea01fbe81d8b760f7c7e94b2d6c /src/jit
parent1ef30f932c1092ead58f7923f6dda999ae77780a (diff)
downloadcoreclr-dfd6ab2348b4b151bb90d3bd7deb6a7304bbafac.tar.gz
coreclr-dfd6ab2348b4b151bb90d3bd7deb6a7304bbafac.tar.bz2
coreclr-dfd6ab2348b4b151bb90d3bd7deb6a7304bbafac.zip
Expose a hosting interface for the JIT.
This is the first significant step towards removing the JIT's dependence on utilcode. This change introduces a new interface, `ICorJitHost`, that allows functionality that would usually be provided by the OS to be overridden by the program that is hosting the JIT. At the moment, this is limited to memory allocation and configuration value (e.g. environment variable) access. If the JIT exports a function named `jitStartup`, an instance of the `ICorJitHost` must be provided via that function before the first call to `getJit`. The VM and other implementors of the JIT interface have been updated accordingly. Most implementors should use the common implementation of `ICorJitHost` (cleverly named `JitHost`) in utilcode which respects the CLR's hosting policy. Note that this change does not update RyuJIT (or any other JITs) to use any of the functionality exposed by `ICorJitHost`; that work is left for future changes. [tfs-changeset: 1578176]
Diffstat (limited to 'src/jit')
-rw-r--r--src/jit/ClrJit.exports1
-rw-r--r--src/jit/dll/clrjit.def3
-rw-r--r--src/jit/ee_il_dll.cpp16
-rw-r--r--src/jit/jitpch.h4
-rw-r--r--src/jit/protojit/protojit.def3
5 files changed, 19 insertions, 8 deletions
diff --git a/src/jit/ClrJit.exports b/src/jit/ClrJit.exports
index 9a914d7038..0126e63b4d 100644
--- a/src/jit/ClrJit.exports
+++ b/src/jit/ClrJit.exports
@@ -1,2 +1,3 @@
getJit
+jitStartup
sxsJitStartup
diff --git a/src/jit/dll/clrjit.def b/src/jit/dll/clrjit.def
index 73a6ba1ae1..1603af74ca 100644
--- a/src/jit/dll/clrjit.def
+++ b/src/jit/dll/clrjit.def
@@ -3,4 +3,5 @@
; See the LICENSE file in the project root for more information.
EXPORTS
getJit
- sxsJitStartup \ No newline at end of file
+ jitStartup
+ sxsJitStartup
diff --git a/src/jit/ee_il_dll.cpp b/src/jit/ee_il_dll.cpp
index f32f87557f..f0da62d153 100644
--- a/src/jit/ee_il_dll.cpp
+++ b/src/jit/ee_il_dll.cpp
@@ -19,8 +19,10 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#endif
#include "emit.h"
+
/*****************************************************************************/
+static ICorJitHost* g_jitHost = nullptr;
static CILJit* ILJitter = 0; // The one and only JITTER I return
#ifndef FEATURE_MERGE_JIT_AND_ENGINE
HINSTANCE g_hInst = NULL;
@@ -45,8 +47,11 @@ JitOptions jitOpts =
/*****************************************************************************/
-void jitStartup()
+extern "C"
+void __stdcall jitStartup(ICorJitHost* jitHost)
{
+ g_jitHost = jitHost;
+
#ifdef FEATURE_TRACELOGGING
JitTelemetry::NotifyDllProcessAttach();
#endif
@@ -61,13 +66,16 @@ void jitShutdown()
#endif
}
+
/*****************************************************************************
* jitOnDllProcessAttach() called by DllMain() when jit.dll is loaded
*/
void jitOnDllProcessAttach()
{
- jitStartup();
+#if COR_JIT_EE_VERSION <= 460
+ jitStartup(JitHost::getJitHost());
+#endif
}
/*****************************************************************************
@@ -79,7 +87,6 @@ void jitOnDllProcessDetach()
jitShutdown();
}
-
#ifndef FEATURE_MERGE_JIT_AND_ENGINE
extern "C"
@@ -139,9 +146,6 @@ ICorJitCompiler* __stdcall getJit()
if (ILJitter == 0)
{
ILJitter = new (CILJitSingleton) CILJit();
-#ifdef FEATURE_MERGE_JIT_AND_ENGINE
- jitStartup();
-#endif
}
return(ILJitter);
}
diff --git a/src/jit/jitpch.h b/src/jit/jitpch.h
index 7c333a72c2..a3c7e24464 100644
--- a/src/jit/jitpch.h
+++ b/src/jit/jitpch.h
@@ -16,6 +16,10 @@
#include <cstdlib>
#include <intrin.h>
+#if COR_JIT_EE_VERSION <= 460
+#include "corjithost.h"
+#include "jithost.h"
+#endif
#include "jit.h"
#include "iallocator.h"
#include "hashbv.h"
diff --git a/src/jit/protojit/protojit.def b/src/jit/protojit/protojit.def
index 73a6ba1ae1..1603af74ca 100644
--- a/src/jit/protojit/protojit.def
+++ b/src/jit/protojit/protojit.def
@@ -3,4 +3,5 @@
; See the LICENSE file in the project root for more information.
EXPORTS
getJit
- sxsJitStartup \ No newline at end of file
+ jitStartup
+ sxsJitStartup