Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion src/coreclr/clrdefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ if(CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_AMD64)
add_compile_definitions(OUT_OF_PROCESS_SETTHREADCONTEXT)
endif(CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_AMD64)

if(NOT CLR_CMAKE_TARGET_ARCH_I386)
if(NOT CLR_CMAKE_TARGET_ARCH_I386 AND NOT FEATURE_PORTABLE_ENTRYPOINTS)
add_definitions(-DFEATURE_PORTABLE_SHUFFLE_THUNKS)
endif()

Expand Down
8 changes: 6 additions & 2 deletions src/coreclr/vm/comdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ BOOL GenerateShuffleArrayPortable(MethodDesc* pMethodSrc, MethodDesc *pMethodDst
}
#endif // FEATURE_PORTABLE_SHUFFLE_THUNKS

#ifndef FEATURE_PORTABLE_ENTRYPOINTS
BOOL GenerateShuffleArray(MethodDesc* pInvoke, MethodDesc *pTargetMeth, SArray<ShuffleEntry> * pShuffleEntryArray)
{
STANDARD_VM_CONTRACT;
Expand Down Expand Up @@ -773,8 +774,8 @@ BOOL GenerateShuffleArray(MethodDesc* pInvoke, MethodDesc *pTargetMeth, SArray<S
}
return TRUE;
}

static ShuffleThunkCache* s_pShuffleThunkCache = NULL;
#endif // !FEATURE_PORTABLE_ENTRYPOINTS

// One time init.
void COMDelegate::Init()
Expand All @@ -786,8 +787,9 @@ void COMDelegate::Init()
MODE_ANY;
}
CONTRACTL_END;

#ifndef FEATURE_PORTABLE_ENTRYPOINTS
s_pShuffleThunkCache = new ShuffleThunkCache(SystemDomain::GetGlobalLoaderAllocator()->GetStubHeap());
#endif
}

#ifdef FEATURE_COMINTEROP
Expand Down Expand Up @@ -913,6 +915,7 @@ static PCODE SetupShuffleThunk(MethodTable * pDelMT, MethodDesc *pTargetMeth)

MethodDesc *pMD = pClass->GetInvokeMethod();

#ifndef FEATURE_PORTABLE_ENTRYPOINTS
// We haven't already setup a shuffle thunk, go do it now (which will cache the result automatically).
StackSArray<ShuffleEntry> rShuffleEntryArray;
if (GenerateShuffleArray(pMD, pTargetMeth, &rShuffleEntryArray))
Expand All @@ -928,6 +931,7 @@ static PCODE SetupShuffleThunk(MethodTable * pDelMT, MethodDesc *pTargetMeth)
pShuffleThunk = pShuffleThunkCache->Canonicalize((const BYTE *)&rShuffleEntryArray[0], "DelegateShuffleThunk");
}
else
#endif // !FEATURE_PORTABLE_ENTRYPOINTS
{
#if defined(TARGET_RISCV64) || defined(TARGET_LOONGARCH64)
pShuffleThunk = CreateILDelegateShuffleThunk(pMD, isInstRetBuff);
Expand Down
40 changes: 31 additions & 9 deletions src/coreclr/vm/prestub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,7 @@ void MethodDesc::CreateDerivedTargetSigWithExtraParams(MetaSig& msig, SigBuilder

#ifdef FEATURE_INSTANTIATINGSTUB_AS_IL

Stub * CreateUnboxingILStubForSharedGenericValueTypeMethods(MethodDesc* pTargetMD)
Stub * CreateUnboxingILStubForValueTypeMethods(MethodDesc* pTargetMD)
{

CONTRACT(Stub*)
Expand Down Expand Up @@ -1510,13 +1510,16 @@ Stub * CreateUnboxingILStubForSharedGenericValueTypeMethods(MethodDesc* pTargetM
}
#endif

// Push the hidden context param
// The context is going to be captured from the thisptr
pCode->EmitLoadThis();
pCode->EmitLDFLDA(tokRawData);
pCode->EmitLDC(Object::GetOffsetOfFirstField());
pCode->EmitSUB();
pCode->EmitLDIND_I();
if (pTargetMD->RequiresInstMethodTableArg())
{
// Push the hidden context param
// The context is going to be captured from the thisptr
pCode->EmitLoadThis();
pCode->EmitLDFLDA(tokRawData);
pCode->EmitLDC(Object::GetOffsetOfFirstField());
pCode->EmitSUB();
pCode->EmitLDIND_I();
}

#ifndef TARGET_X86
if (msig.HasAsyncContinuation())
Expand Down Expand Up @@ -1727,13 +1730,16 @@ Stub * MakeUnboxingStubWorker(MethodDesc *pMD)
else
#endif
{
#ifdef FEATURE_PORTABLE_ENTRYPOINTS
pstub = CreateUnboxingILStubForValueTypeMethods(pUnboxedMD);
#else // !FEATURE_PORTABLE_ENTRYPOINTS
#ifdef FEATURE_INSTANTIATINGSTUB_AS_IL
#ifndef FEATURE_PORTABLE_SHUFFLE_THUNKS
if (pUnboxedMD->RequiresInstMethodTableArg())
#endif // !FEATURE_PORTABLE_SHUFFLE_THUNKS
{
_ASSERTE(pUnboxedMD->RequiresInstMethodTableArg());
pstub = CreateUnboxingILStubForSharedGenericValueTypeMethods(pUnboxedMD);
pstub = CreateUnboxingILStubForValueTypeMethods(pUnboxedMD);
}
#ifndef FEATURE_PORTABLE_SHUFFLE_THUNKS
else
Expand All @@ -1746,6 +1752,7 @@ Stub * MakeUnboxingStubWorker(MethodDesc *pMD)
pstub = sl.Link(pMD->GetLoaderAllocator()->GetStubHeap(), NEWSTUB_FL_NONE, "UnboxingStub");
}
#endif // !FEATURE_PORTABLE_SHUFFLE_THUNKS
#endif // FEATURE_PORTABLE_ENTRYPOINTS
}
RETURN pstub;
}
Expand Down Expand Up @@ -2369,12 +2376,26 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT, CallerGCMode callerGCMo
MemoryBarrier();
#endif

#if defined(FEATURE_PORTABLE_ENTRYPOINTS)
if (pStub != NULL)
{
pCode = pStub->GetEntryPoint();
pStub->DecRef();
pStub = NULL;

void* ilStubInterpData = PortableEntryPoint::GetInterpreterData(pCode);
_ASSERTE(ilStubInterpData != NULL);
SetInterpreterCode((InterpByteCodeStart*)ilStubInterpData);
}
#endif // FEATURE_PORTABLE_ENTRYPOINTS

if (pCode != (PCODE)NULL)
{
_ASSERTE(!MayHaveEntryPointSlotsToBackpatch()); // This path doesn't lock the MethodDescBackpatchTracker as it should only
// happen for jump-stampable or non-versionable methods
SetCodeEntryPoint(pCode);
}
#ifndef FEATURE_PORTABLE_ENTRYPOINTS
else
{
if (!GetOrCreatePrecode()->SetTargetInterlocked(pStub->GetEntryPoint()))
Expand All @@ -2397,6 +2418,7 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT, CallerGCMode callerGCMo
pStub->DecRef();
}
}
#endif // !FEATURE_PORTABLE_ENTRYPOINTS

_ASSERTE(!IsPointingToPrestub());
_ASSERTE(HasStableEntryPoint());
Expand Down
17 changes: 17 additions & 0 deletions src/coreclr/vm/wasm/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,13 @@ namespace
*(int32_t*)pRet = (*fptr)(ARG_IND(0), ARG(1));
}

void CallFunc_I32_I32IND_I32_I32IND_I32_RetI32(PCODE pcode, int8_t *pArgs, int8_t *pRet)
{
printf("TRACE CallFunc_I32_I32IND_I32_I32IND_I32_RetI32 pcode: %lx arg0: %x arg1: %x arg2: %x\n", pcode, ARG(0), ARG_IND(1), ARG_IND(2));
int32_t (*fptr)(int32_t, int32_t, int32_t, int32_t, int32_t) = (int32_t (*)(int32_t, int32_t, int32_t, int32_t, int32_t))pcode;
*(int32_t*)pRet = (*fptr)(ARG(0), ARG_IND(1), ARG(2), ARG_IND(3), ARG(4));
}

void CallFunc_I32IND_I32_I32_I32_I32_I32_RetI32(PCODE pcode, int8_t *pArgs, int8_t *pRet)
{
int32_t (*fptr)(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t) = (int32_t (*)(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t))pcode;
Expand Down Expand Up @@ -690,6 +697,16 @@ namespace
return (void*)&CallFunc_I32IND_I32_RetI32;
}
break;
case 5:
if (args[0] == ConvertType::ToI32 &&
args[1] == ConvertType::ToI32Indirect &&
args[2] == ConvertType::ToI32 &&
args[3] == ConvertType::ToI32Indirect &&
args[4] == ConvertType::ToI32)
{
return (void*)&CallFunc_I32_I32IND_I32_I32IND_I32_RetI32;
}
break;
case 6:
if (args[0] == ConvertType::ToI32Indirect &&
args[1] == ConvertType::ToI32 &&
Expand Down
Loading