Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

[ARM32/Linux] Initial bring up of FEATURE_INTERPRETER #8594

Merged
merged 2 commits into from
Dec 14, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,11 @@ RETAIL_CONFIG_DWORD_INFO(INTERNAL_InterpreterDoLoopMethods, W("InterpreterDoLoop
RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_InterpreterUseCaching, W("InterpreterUseCaching"), 1, "If non-zero, use the caching mechanism.", CLRConfig::REGUTIL_default)
RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_InterpreterLooseRules, W("InterpreterLooseRules"), 1, "If non-zero, allow ECMA spec violations required by managed C++.", CLRConfig::REGUTIL_default)
RETAIL_CONFIG_DWORD_INFO(INTERNAL_InterpreterPrintPostMortem, W("InterpreterPrintPostMortem"), 0, "Prints summary information about the execution to the console")
CONFIG_STRING_INFO_EX(INTERNAL_InterpreterLogFile, W("InterpreterLogFile"), "If non-null, append interpreter logging to this file, else use stdout", CLRConfig::REGUTIL_default)
CONFIG_DWORD_INFO(INTERNAL_DumpInterpreterStubs, W("DumpInterpreterStubs"), 0, "Prints all interpreter stubs that are created to the console")
CONFIG_DWORD_INFO(INTERNAL_TraceInterpreterEntries, W("TraceInterpreterEntries"), 0, "Logs entries to interpreted methods to the console")
CONFIG_DWORD_INFO(INTERNAL_TraceInterpreterIL, W("TraceInterpreterIL"), 0, "Logs individual instructions of interpreted methods to the console")
CONFIG_DWORD_INFO(INTERNAL_TraceInterpreterOstack, W("TraceInterpreterOstack"), 0, "Logs operand stack after each IL instruction of interpreted methods to the console")
RETAIL_CONFIG_STRING_INFO_EX(INTERNAL_InterpreterLogFile, W("InterpreterLogFile"), "If non-null, append interpreter logging to this file, else use stdout", CLRConfig::REGUTIL_default)
RETAIL_CONFIG_DWORD_INFO(INTERNAL_DumpInterpreterStubs, W("DumpInterpreterStubs"), 0, "Prints all interpreter stubs that are created to the console")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_TraceInterpreterEntries, W("TraceInterpreterEntries"), 0, "Logs entries to interpreted methods to the console")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_TraceInterpreterIL, W("TraceInterpreterIL"), 0, "Logs individual instructions of interpreted methods to the console")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_TraceInterpreterOstack, W("TraceInterpreterOstack"), 0, "Logs operand stack after each IL instruction of interpreted methods to the console")
CONFIG_DWORD_INFO(INTERNAL_TraceInterpreterVerbose, W("TraceInterpreterVerbose"), 0, "Logs interpreter progress with detailed messages to the console")
CONFIG_DWORD_INFO(INTERNAL_TraceInterpreterJITTransition, W("TraceInterpreterJITTransition"), 0, "Logs when the interpreter determines a method should be JITted")
#endif
Expand Down
15 changes: 12 additions & 3 deletions src/vm/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -903,9 +903,10 @@ CorJitResult Interpreter::GenerateInterpreterStub(CEEInfo* comp,
#endif
{
// But we also have to use r4, because ThumbEmitCondRegJump below requires a low register.
sl.ThumbEmitMovConstant(r11, 0);
sl.ThumbEmitMovConstant(r12, UINT_PTR(interpMethInfo));
sl.ThumbEmitLoadRegIndirect(r12, r12, offsetof(InterpreterMethodInfo, m_jittedCode));
sl.ThumbEmitCmpImm(r12, 0); // Set condition codes.
sl.ThumbEmitCmpReg(r12, r11); // Set condition codes.
// If r12 is zero, then go on to do the interpretation.
CodeLabel* doInterpret = sl.NewCodeLabel();
sl.ThumbEmitCondFlagJump(doInterpret, thumbCondEq.cond);
Expand Down Expand Up @@ -1578,7 +1579,7 @@ CorJitResult Interpreter::GenerateInterpreterStub(CEEInfo* comp,
#else
#error unsupported platform
#endif
stub = sl.Link();
stub = sl.Link(SystemDomain::GetGlobalLoaderAllocator()->GetStubHeap());

*nativeSizeOfCode = static_cast<ULONG>(stub->GetNumCodeBytes());
// TODO: manage reference count of interpreter stubs. Look for examples...
Expand Down Expand Up @@ -8607,6 +8608,8 @@ void Interpreter::BoxStructRefAt(unsigned ind, CORINFO_CLASS_HANDLE valCls)
if (th.IsTypeDesc())
COMPlusThrow(kInvalidOperationException,W("InvalidOperation_TypeCannotBeBoxed"));

MethodTable* pMT = th.AsMethodTable();

{
Object* res = OBJECTREFToObject(pMT->Box(valPtr));

Expand Down Expand Up @@ -9578,7 +9581,9 @@ void Interpreter::DoCallWork(bool virtualCall, void* thisArg, CORINFO_RESOLVED_T

// This is the argument slot that will be used to hold the return value.
ARG_SLOT retVal = 0;
#ifndef _ARM_
_ASSERTE (NUMBER_RETURNVALUE_SLOTS == 1);
#endif

// If the return type is a structure, then these will be initialized.
CORINFO_CLASS_HANDLE retTypeClsHnd = NULL;
Expand Down Expand Up @@ -10316,15 +10321,19 @@ void Interpreter::CallI()
}
else
{
pMD = g_pPrepareConstrainedRegionsMethod; // A random static method.
pMD = g_pExecuteBackoutCodeHelperMethod; // A random static method.
}
MethodDescCallSite mdcs(pMD, &mSig, ftnPtr);
#if 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this #if 0 out?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It triggers assertion in the Thread::ObjectRefFlush function at threads.cpp:6861:

 _ASSERTE(thread->PreemptiveGCDisabled());  // Should have been in managed code

I don't know much about GC subsystem and preemption in particular, so I just disabled that code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect that ifdefing this out will likely break more things than what it is fixing, but you are the only one playing with the interpreter these days, so if it works for you, I am ok with it.

It would be nice to add a comment next to it on why you have disabled it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, done.

// If the current method being interpreted is an IL stub, we're calling native code, so
// change the GC mode. (We'll only do this at the call if the calling convention turns out
// to be a managed calling convention.)
MethodDesc* pStubContextMD = reinterpret_cast<MethodDesc*>(m_stubContext);
bool transitionToPreemptive = (pStubContextMD != NULL && !pStubContextMD->IsIL());
mdcs.CallTargetWorker(args, &retVal, sizeof(retVal), transitionToPreemptive);
#else
mdcs.CallTargetWorker(args, &retVal, sizeof(retVal));
#endif
}
// retVal is now vulnerable.
GCX_FORBID();
Expand Down
2 changes: 1 addition & 1 deletion src/vm/interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ class InterpreterCEEInfo: public CEEInfo
{
CEEJitInfo m_jitInfo;
public:
InterpreterCEEInfo(CORINFO_METHOD_HANDLE meth): CEEInfo((MethodDesc*)meth), m_jitInfo((MethodDesc*)meth, NULL, NULL, CorJitFlag(0)) { m_pOverride = this; }
InterpreterCEEInfo(CORINFO_METHOD_HANDLE meth): CEEInfo((MethodDesc*)meth), m_jitInfo((MethodDesc*)meth, NULL, NULL, CORJIT_FLAGS::CORJIT_FLAG_SPEED_OPT) { m_pOverride = this; }

// Certain methods are unimplemented by CEEInfo (they hit an assert). They are implemented by CEEJitInfo, yet
// don't seem to require any of the CEEJitInfo state we can't provide. For those case, delegate to the "partial"
Expand Down