Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion src/coreclr/inc/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ enum {
LF_ALL = 0xFFFFFFFF, // Used only to mask bits. Never use as LOG((LF_ALL, ...))

// LogFacility2: all 32-bit of LogFacility are used, need a 2nd DWORD for more facilities
LF2_MULTICOREJIT = 0x00000001 // Multicore JIT
LF2_MULTICOREJIT = 0x00000001, // Multicore JIT
LF2_INTERPRETER = 0x00000002, // Interpreter
};


Expand Down
110 changes: 26 additions & 84 deletions src/coreclr/vm/callstubgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1985,47 +1985,35 @@ PCODE GPRegsRefStoreRoutines[] =

#endif // TARGET_RISCV64

#define LOG_COMPUTE_CALL_STUB 0

PCODE CallStubGenerator::GetStackRoutine()
{
#if LOG_COMPUTE_CALL_STUB
printf("Load_Stack\n");
#endif
LOG2((LF2_INTERPRETER, LL_INFO10000, "Load_Stack\n"));
return m_interpreterToNative ? (PCODE)Load_Stack : (PCODE)Store_Stack;
}

#if defined(TARGET_APPLE) && defined(TARGET_ARM64)
PCODE CallStubGenerator::GetStackRoutine_1B()
{
#if LOG_COMPUTE_CALL_STUB
printf("GetStackRoutine_1B\n");
#endif
LOG2((LF2_INTERPRETER, LL_INFO10000, "GetStackRoutine_1B\n"));
return m_interpreterToNative ? (PCODE)Load_Stack_1B : (PCODE)Store_Stack_1B;
}

PCODE CallStubGenerator::GetStackRoutine_2B()
{
#if LOG_COMPUTE_CALL_STUB
printf("GetStackRoutine_2B\n");
#endif
LOG2((LF2_INTERPRETER, LL_INFO10000, "GetStackRoutine_2B\n"));
return m_interpreterToNative ? (PCODE)Load_Stack_2B : (PCODE)Store_Stack_2B;
}

PCODE CallStubGenerator::GetStackRoutine_4B()
{
#if LOG_COMPUTE_CALL_STUB
printf("GetStackRoutine_4B\n");
#endif
LOG2((LF2_INTERPRETER, LL_INFO10000, "GetStackRoutine_4B\n"));
return m_interpreterToNative ? (PCODE)Load_Stack_4B : (PCODE)Store_Stack_4B;
}
#endif // TARGET_APPLE && TARGET_ARM64

PCODE CallStubGenerator::GetGPRegRangeRoutine(int r1, int r2)
{
#if LOG_COMPUTE_CALL_STUB
printf("GetGPRegRangeRoutine %d %d\n", r1, r2);
#endif
LOG2((LF2_INTERPRETER, LL_INFO10000, "GetGPRegRangeRoutine %d %d\n", r1, r2));

int index = r1 * NUM_ARGUMENT_REGISTERS + r2;
PCODE routine = m_interpreterToNative ? GPRegsRoutines[index] : GPRegsStoreRoutines[index];
Expand All @@ -2036,27 +2024,21 @@ PCODE CallStubGenerator::GetGPRegRangeRoutine(int r1, int r2)
#if !defined(UNIX_AMD64_ABI) && defined(ENREGISTERED_PARAMTYPE_MAXSIZE)
PCODE CallStubGenerator::GetGPRegRefRoutine(int r)
{
#if LOG_COMPUTE_CALL_STUB
printf("GetGPRegRefRoutine %d\n", r);
#endif
LOG2((LF2_INTERPRETER, LL_INFO10000, "GetGPRegRefRoutine %d\n", r));
return m_interpreterToNative ? GPRegsRefRoutines[r] : GPRegsRefStoreRoutines[r];
}

PCODE CallStubGenerator::GetStackRefRoutine()
{
#if LOG_COMPUTE_CALL_STUB
printf("GetStackRefRoutine\n");
#endif
LOG2((LF2_INTERPRETER, LL_INFO10000, "GetStackRefRoutine\n"));
return m_interpreterToNative ? (PCODE)Load_Stack_Ref : (PCODE)Store_Stack_Ref;
}

#endif // !UNIX_AMD64_ABI && ENREGISTERED_PARAMTYPE_MAXSIZE

PCODE CallStubGenerator::GetFPRegRangeRoutine(int x1, int x2)
{
#if LOG_COMPUTE_CALL_STUB
printf("GetFPRegRangeRoutine %d %d\n", x1, x2);
#endif
LOG2((LF2_INTERPRETER, LL_INFO10000, "GetFPRegRangeRoutine %d %d\n", x1, x2));

#ifdef TARGET_ARM
_ASSERTE(!"Not support FP reg yet");
Expand All @@ -2072,9 +2054,7 @@ PCODE CallStubGenerator::GetFPRegRangeRoutine(int x1, int x2)
#ifdef TARGET_ARM64
PCODE CallStubGenerator::GetFPReg128RangeRoutine(int x1, int x2)
{
#if LOG_COMPUTE_CALL_STUB
printf("GetFPReg128RangeRoutine %d %d\n", x1, x2);
#endif
LOG2((LF2_INTERPRETER, LL_INFO10000, "GetFPReg128RangeRoutine %d %d\n", x1, x2));
int index = x1 * NUM_FLOAT_ARGUMENT_REGISTERS + x2;
PCODE routine = m_interpreterToNative ? FPRegs128LoadRoutines[index] : FPRegs128StoreRoutines[index];
_ASSERTE(routine != 0);
Expand All @@ -2083,9 +2063,7 @@ PCODE CallStubGenerator::GetFPReg128RangeRoutine(int x1, int x2)

PCODE CallStubGenerator::GetFPReg32RangeRoutine(int x1, int x2)
{
#if LOG_COMPUTE_CALL_STUB
printf("GetFPReg32RangeRoutine %d %d\n", x1, x2);
#endif
LOG2((LF2_INTERPRETER, LL_INFO10000, "GetFPReg32RangeRoutine %d %d\n", x1, x2));
int index = x1 * NUM_FLOAT_ARGUMENT_REGISTERS + x2;
return m_interpreterToNative ? FPRegs32LoadRoutines[index] : FPRegs32StoreRoutines[index];
}
Expand Down Expand Up @@ -2212,11 +2190,7 @@ extern "C" void InterpreterStubRetFloatInt();
extern "C" void InterpreterStubRetIntFloat();
#endif // TARGET_RISCV64

#if LOG_COMPUTE_CALL_STUB
#define INVOKE_FUNCTION_PTR(functionPtrName) printf(#functionPtrName "\n"); return functionPtrName
#else
#define INVOKE_FUNCTION_PTR(functionPtrName) return functionPtrName
#endif
#define INVOKE_FUNCTION_PTR(functionPtrName) LOG2((LF2_INTERPRETER, LL_INFO10000, #functionPtrName "\n")); return functionPtrName

CallStubHeader::InvokeFunctionPtr CallStubGenerator::GetInvokeFunctionPtr(CallStubGenerator::ReturnType returnType)
{
Expand Down Expand Up @@ -2334,11 +2308,7 @@ CallStubHeader::InvokeFunctionPtr CallStubGenerator::GetInvokeFunctionPtr(CallSt
}
}

#if LOG_COMPUTE_CALL_STUB
#define RETURN_TYPE_HANDLER(returnType) printf(#returnType "\n"); return (PCODE)returnType
#else
#define RETURN_TYPE_HANDLER(returnType) return (PCODE)returnType
#endif
#define RETURN_TYPE_HANDLER(returnType) LOG2((LF2_INTERPRETER, LL_INFO10000, #returnType "\n")); return (PCODE)returnType

PCODE CallStubGenerator::GetInterpreterReturnTypeHandler(CallStubGenerator::ReturnType returnType)
{
Expand Down Expand Up @@ -2470,9 +2440,7 @@ CallStubHeader *CallStubGenerator::GenerateCallStub(MethodDesc *pMD, AllocMemTra

_ASSERTE(pMD != NULL);

#if LOG_COMPUTE_CALL_STUB
printf("GenerateCallStub interpreterToNative=%d\n", interpreterToNative ? 1 : 0);
#endif // LOG_COMPUTE_CALL_STUB
LOG2((LF2_INTERPRETER, LL_INFO10000, "GenerateCallStub interpreterToNative=%d\n", interpreterToNative ? 1 : 0));
m_interpreterToNative = interpreterToNative;

MetaSig sig(pMD);
Expand Down Expand Up @@ -2603,9 +2571,7 @@ CallStubHeader *CallStubGenerator::GenerateCallStubForSig(MetaSig &sig)
if (pCachedHeader != NULL)
{
// The stub is already cached, return the cached header
#if LOG_COMPUTE_CALL_STUB
printf("CallStubHeader at %p\n", &pCachedHeader->Header);
#endif // LOG_COMPUTE_CALL_STUB
LOG2((LF2_INTERPRETER, LL_INFO10000, "CallStubHeader at %p\n", &pCachedHeader->Header));
return &pCachedHeader->Header;
}
else
Expand All @@ -2620,9 +2586,7 @@ CallStubHeader *CallStubGenerator::GenerateCallStubForSig(MetaSig &sig)
amTracker.SuppressRelease();

_ASSERTE(s_callStubCache->Lookup(cachedHeaderKey) == pHeader);
#if LOG_COMPUTE_CALL_STUB
printf("CallStubHeader at %p\n", &pHeader->Header);
#endif // LOG_COMPUTE_CALL_STUB
LOG2((LF2_INTERPRETER, LL_INFO10000, "CallStubHeader at %p\n", &pHeader->Header));
return &pHeader->Header;
}
};
Expand Down Expand Up @@ -2817,18 +2781,14 @@ void CallStubGenerator::ComputeCallStubWorker(bool hasUnmanagedCallConv, CorInfo
// in the places where it is needed such as computation of return buffers.
if (sig.GetCallingConventionInfo() & IMAGE_CEE_CS_CALLCONV_EXPLICITTHIS)
{
#if LOG_COMPUTE_CALL_STUB
printf("Managed ExplicitThis to HasThis conversion needed\n");
#endif // LOG_COMPUTE_CALL_STUB
LOG2((LF2_INTERPRETER, LL_INFO10000, "Managed ExplicitThis to HasThis conversion needed\n"));
rewriteMetaSigFromExplicitThisToHasThis = true;
}

SigBuilder sigBuilder;
if (rewriteMetaSigFromExplicitThisToHasThis)
{
#if LOG_COMPUTE_CALL_STUB
printf("Rewriting ExplicitThis to implicit this\n");
#endif // LOG_COMPUTE_CALL_STUB
LOG2((LF2_INTERPRETER, LL_INFO10000, "Rewriting ExplicitThis to implicit this\n"));
sigBuilder.AppendByte(IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS);
if ((sig.NumFixedArgs() == 0) || (sig.HasThis() && !sig.HasExplicitThis()))
{
Expand Down Expand Up @@ -2882,16 +2842,12 @@ void CallStubGenerator::ComputeCallStubWorker(bool hasUnmanagedCallConv, CorInfo
m_s2 = 0;
m_routineIndex = 0;
m_totalStackSize = argIt.SizeOfArgStack();
#if LOG_COMPUTE_CALL_STUB
printf("ComputeCallStub\n");
#endif
LOG2((LF2_INTERPRETER, LL_INFO10000, "ComputeCallStub\n"));
int numArgs = sig.NumFixedArgs() + (sig.HasThis() ? 1 : 0);

if (argIt.HasThis())
{
#if LOG_COMPUTE_CALL_STUB
printf("HasThis\n");
#endif
LOG2((LF2_INTERPRETER, LL_INFO10000, "HasThis\n"));
// The "this" argument register is not enumerated by the arg iterator, so
// we need to "inject" it here.
// CLR ABI specifies that unlike the native Windows x64 calling convention, it is passed in the first argument register.
Expand All @@ -2902,9 +2858,7 @@ void CallStubGenerator::ComputeCallStubWorker(bool hasUnmanagedCallConv, CorInfo

if (argIt.HasParamType())
{
#if LOG_COMPUTE_CALL_STUB
printf("argIt.HasParamType\n");
#endif
LOG2((LF2_INTERPRETER, LL_INFO10000, "argIt.HasParamType\n"));
// In the Interpreter calling convention the argument after the "this" pointer is the parameter type
ArgLocDesc paramArgLocDesc;
argIt.GetParamTypeLoc(&paramArgLocDesc);
Expand All @@ -2914,9 +2868,7 @@ void CallStubGenerator::ComputeCallStubWorker(bool hasUnmanagedCallConv, CorInfo

if (argIt.HasAsyncContinuation())
{
#if LOG_COMPUTE_CALL_STUB
printf("argIt.HasAsyncContinuation\n");
#endif
LOG2((LF2_INTERPRETER, LL_INFO10000, "argIt.HasAsyncContinuation\n"));
// In the Interpreter calling convention the argument after the param type is the async continuation
ArgLocDesc asyncContinuationLocDesc;
argIt.GetAsyncContinuationLoc(&asyncContinuationLocDesc);
Expand All @@ -2927,9 +2879,7 @@ void CallStubGenerator::ComputeCallStubWorker(bool hasUnmanagedCallConv, CorInfo
int ofs;
while ((ofs = argIt.GetNextOffset()) != TransitionBlock::InvalidOffset)
{
#if LOG_COMPUTE_CALL_STUB
printf("Next argument\n");
#endif
LOG2((LF2_INTERPRETER, LL_INFO10000, "Next argument\n"));
ArgLocDesc argLocDesc;
argIt.GetArgLoc(ofs, &argLocDesc);

Expand Down Expand Up @@ -2957,9 +2907,7 @@ void CallStubGenerator::ComputeCallStubWorker(bool hasUnmanagedCallConv, CorInfo

interpreterStackOffset += INTERP_STACK_SLOT_SIZE;
pRoutines[m_routineIndex++] = (PCODE)InjectInterpStackAlign;
#if LOG_COMPUTE_CALL_STUB
printf("Inject stack align argument\n");
#endif
LOG2((LF2_INTERPRETER, LL_INFO10000, "Inject stack align argument\n"));
}

assert(interpreterStackOffset == ALIGN_UP(interpreterStackOffset, align));
Expand Down Expand Up @@ -3101,9 +3049,7 @@ void CallStubGenerator::ProcessArgument(ArgIteratorType *pArgIt, ArgLocDesc& arg

if (argLocDesc.m_cGenReg != 0)
{
#if LOG_COMPUTE_CALL_STUB
printf("m_cGenReg=%d\n", (int)argLocDesc.m_cGenReg);
#endif // LOG_COMPUTE_CALL_STUB
LOG2((LF2_INTERPRETER, LL_INFO10000, "m_cGenReg=%d\n", (int)argLocDesc.m_cGenReg));
#ifdef TARGET_ARM
if (argLocDesc.m_cGenReg == 2)
{
Expand Down Expand Up @@ -3138,9 +3084,7 @@ void CallStubGenerator::ProcessArgument(ArgIteratorType *pArgIt, ArgLocDesc& arg

if (argLocDesc.m_cFloatReg != 0)
{
#if LOG_COMPUTE_CALL_STUB
printf("m_cFloatReg=%d\n", (int)argLocDesc.m_cFloatReg);
#endif // LOG_COMPUTE_CALL_STUB
LOG2((LF2_INTERPRETER, LL_INFO10000, "m_cFloatReg=%d\n", (int)argLocDesc.m_cFloatReg));
if (m_x1 == NoRange) // No active range yet
{
// Start a new range
Expand Down Expand Up @@ -3189,9 +3133,7 @@ void CallStubGenerator::ProcessArgument(ArgIteratorType *pArgIt, ArgLocDesc& arg

if (argLocDesc.m_byteStackSize != 0)
{
#if LOG_COMPUTE_CALL_STUB
printf("m_byteStackSize=%d\n", (int)argLocDesc.m_byteStackSize);
#endif // LOG_COMPUTE_CALL_STUB
LOG2((LF2_INTERPRETER, LL_INFO10000, "m_byteStackSize=%d\n", (int)argLocDesc.m_byteStackSize));
#ifdef TARGET_ARM
if (argLocDesc.m_byteStackSize >= 8)
{
Expand Down
Loading