Skip to content

Commit e028232

Browse files
committed
Separate code manager for the interpreter
This change adds a separate code manager for the interpreted code. Here is an overview of the changes: * A base class EECodeGenManager is extracted from the EEJitManager * A new class InterpreterJitManager derived from the EECodeGenManager is added and implemented. * Similarly, a base class CEECodeGenInfo is extracted from the CEEJitInfo * A new class CInterpreterJitInfo derived from the CEECodeGenInfo is added and implemented * The CodeHeader and RealCodeHeader became base classes and JitCodeHeader, RealJitCodeHeader, InterpreterCodeHeader and RealInterpreterCodeHeader were added. The CodeHeader derivates don't add any extra data, the JitCodeHeader just provides the methods that are needed to access Jit specific members of the RealJitCodeHeader. * The UnsafeJitFunction is refactored so that the interpreter (if enabled) is invoked first and then the AltJit / Jit ones are called. * A new DOTNET_Interpreter, DOTNET_InterpreterPath and DOTNET_InterpreterName env vars are added to match the existing AltJit ones.
1 parent 5f97ddf commit e028232

16 files changed

+1255
-691
lines changed

src/coreclr/debug/daccess/fntableaccess.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static NTSTATUS OutOfProcessFindHeader(ReadMemoryFunction fpReadMemory,PVOID pUs
137137
return STATUS_SUCCESS;
138138
}
139139

140-
#define CODE_HEADER FakeRealCodeHeader
140+
#define CODE_HEADER FakeJitRealCodeHeader
141141
#define ResolveCodeHeader(pHeader) \
142142
if (pHeader) \
143143
{ \
@@ -169,7 +169,7 @@ extern "C" NTSTATUS OutOfProcessFunctionTableCallbackEx(IN ReadMemoryFunction
169169
*ppFunctions = 0;
170170
*pnEntries = 0;
171171

172-
DWORD_PTR pHp = JitMan + (DWORD_PTR)offsetof(FakeEEJitManager, m_pCodeHeap);
172+
DWORD_PTR pHp = JitMan + (DWORD_PTR)offsetof(FakeEECodeGenManager, m_pCodeHeap);
173173

174174
move(pHp, pHp);
175175

src/coreclr/debug/daccess/fntableaccess.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define _FN_TABLE_ACCESS_H
1212

1313

14-
struct FakeEEJitManager
14+
struct FakeEECodeGenManager
1515
{
1616
LPVOID __VFN_table;
1717
LPVOID m_runtimeSupport;
@@ -55,7 +55,7 @@ typedef struct _FakeHpRealCodeHdr
5555
LPVOID hdrMDesc; // changed from MethodDesc*
5656
DWORD nUnwindInfos;
5757
T_RUNTIME_FUNCTION unwindInfos[0];
58-
} FakeRealCodeHeader;
58+
} FakeJitRealCodeHeader;
5959

6060
typedef struct _FakeHpCodeHdr
6161
{
@@ -76,7 +76,7 @@ class CheckDuplicatedStructLayouts
7676
{
7777
#define CHECK_OFFSET(cls, fld) CPP_ASSERT(cls##fld, offsetof(Fake##cls, fld) == offsetof(cls, fld))
7878

79-
CHECK_OFFSET(EEJitManager, m_pCodeHeap);
79+
CHECK_OFFSET(EECodeGenManager, m_pCodeHeap);
8080

8181
CHECK_OFFSET(HeapList, hpNext);
8282
CHECK_OFFSET(HeapList, startAddress);
@@ -85,8 +85,8 @@ class CheckDuplicatedStructLayouts
8585
CHECK_OFFSET(HeapList, pHdrMap);
8686

8787
#if !defined(TARGET_X86)
88-
CHECK_OFFSET(RealCodeHeader, nUnwindInfos);
89-
CHECK_OFFSET(RealCodeHeader, unwindInfos);
88+
CHECK_OFFSET(JitRealCodeHeader, nUnwindInfos);
89+
CHECK_OFFSET(JitRealCodeHeader, unwindInfos);
9090
#endif // !TARGET_X86
9191

9292
#undef CHECK_OFFSET

src/coreclr/inc/clrconfigvalues.h

+6
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,12 @@ RETAIL_CONFIG_STRING_INFO(EXTERNAL_AltJitOs, W("AltJitOS"), "Sets target OS for
324324
RETAIL_CONFIG_STRING_INFO(EXTERNAL_AltJitExcludeAssemblies, W("AltJitExcludeAssemblies"), "Do not use AltJit on this semicolon-delimited list of assemblies.")
325325
#endif // defined(ALLOW_SXS_JIT)
326326

327+
#ifdef FEATURE_INTERPRETER
328+
RETAIL_CONFIG_STRING_INFO(EXTERNAL_InterpreterName, W("InterpreterName"), "Primary interpreter to use")
329+
CONFIG_STRING_INFO(INTERNAL_InterpreterPath, W("InterpreterPath"), "Full path to the interpreter to use")
330+
RETAIL_CONFIG_STRING_INFO(EXTERNAL_Interpreter, W("Interpreter"), "Enables Interpreter and selectively limits it to the specified methods.")
331+
#endif // FEATURE_INTERPRETER
332+
327333
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_JitHostMaxSlabCache, W("JitHostMaxSlabCache"), 0x1000000, "Sets jit host max slab cache size, 16MB default")
328334

329335
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_JitOptimizeType, W("JitOptimizeType"), 0 /* OPT_DEFAULT */, "")

src/coreclr/inc/corjit.h

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ enum CorJitAllocMemFlag
5252
CORJIT_ALLOCMEM_FLG_32BYTE_ALIGN = 0x00000004, // The code will be 32-byte aligned
5353
CORJIT_ALLOCMEM_FLG_RODATA_32BYTE_ALIGN = 0x00000008, // The read-only data will be 32-byte aligned
5454
CORJIT_ALLOCMEM_FLG_RODATA_64BYTE_ALIGN = 0x00000010, // The read-only data will be 64-byte aligned
55+
CORJIT_ALLOCMEM_FLG_INTERPRETED = 0x00000020, // The code is interpreted byte code
5556
};
5657

5758
inline CorJitAllocMemFlag operator |(CorJitAllocMemFlag a, CorJitAllocMemFlag b)

src/coreclr/inc/dacvars.h

+3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ DEFINE_DACVAR(PTR_EEJitManager, ExecutionManager__m_pEEJitManager, ExecutionMana
8484
#ifdef FEATURE_READYTORUN
8585
DEFINE_DACVAR(PTR_ReadyToRunJitManager, ExecutionManager__m_pReadyToRunJitManager, ExecutionManager::m_pReadyToRunJitManager)
8686
#endif
87+
#ifdef FEATURE_INTERPRETER
88+
DEFINE_DACVAR(PTR_InterpreterJitManager, ExecutionManager__m_pInterpreterJitManager, ExecutionManager::m_pInterpreterJitManager)
89+
#endif
8790

8891
DEFINE_DACVAR_NO_DUMP(VMHELPDEF *, dac__hlpFuncTable, ::hlpFuncTable)
8992
DEFINE_DACVAR(VMHELPDEF *, dac__hlpDynamicFuncTable, ::hlpDynamicFuncTable)

src/coreclr/inc/vptr_list.h

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ VPTR_CLASS(EEJitManager)
99
#ifdef FEATURE_READYTORUN
1010
VPTR_CLASS(ReadyToRunJitManager)
1111
#endif
12+
#ifdef FEATURE_INTERPRETER
13+
VPTR_CLASS(InterpreterJitManager)
14+
#endif
1215
VPTR_CLASS(EECodeManager)
1316

1417
VPTR_CLASS(RangeList)

src/coreclr/interpreter/eeinterp.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ CorJitResult CILInterp::compileMethod(ICorJitInfo* compHnd,
5252

5353
// TODO: replace this by something like the JIT does to support multiple methods being specified and we don't
5454
// keep fetching it on each call to compileMethod
55-
const char *methodToInterpret = g_interpHost->getStringConfigValue("AltJit");
55+
const char *methodToInterpret = g_interpHost->getStringConfigValue("Interpreter");
5656
bool doInterpret = (methodName != NULL && strcmp(methodName, methodToInterpret) == 0);
5757
g_interpHost->freeStringConfigValue(methodToInterpret);
5858

@@ -72,23 +72,18 @@ CorJitResult CILInterp::compileMethod(ICorJitInfo* compHnd,
7272

7373
uint32_t sizeOfCode = sizeof(InterpMethod*) + IRCodeSize * sizeof(int32_t);
7474

75-
// TODO: get rid of the need to allocate fake unwind info.
76-
compHnd->reserveUnwindInfo(false /* isFunclet */, false /* isColdCode */ , 8 /* unwindSize */);
7775
AllocMemArgs args;
7876
args.hotCodeSize = sizeOfCode;
7977
args.coldCodeSize = 0;
8078
args.roDataSize = 0;
8179
args.xcptnsCount = 0;
82-
args.flag = CORJIT_ALLOCMEM_DEFAULT_CODE_ALIGN;
80+
args.flag = CORJIT_ALLOCMEM_DEFAULT_CODE_ALIGN | CORJIT_ALLOCMEM_FLG_INTERPRETED;
8381
compHnd->allocMem(&args);
8482

8583
// We store first the InterpMethod pointer as the code header, followed by the actual code
8684
*(InterpMethod**)args.hotCodeBlockRW = pMethod;
8785
memcpy ((uint8_t*)args.hotCodeBlockRW + sizeof(InterpMethod*), pIRCode, IRCodeSize * sizeof(int32_t));
8886

89-
// TODO: get rid of the need to allocate fake unwind info
90-
compHnd->allocUnwindInfo((uint8_t*)args.hotCodeBlock, (uint8_t*)args.coldCodeBlock, 0, 1, 0, nullptr, CORJIT_FUNC_ROOT);
91-
9287
*entryAddress = (uint8_t*)args.hotCodeBlock;
9388
*nativeSizeOfCode = sizeOfCode;
9489

0 commit comments

Comments
 (0)