Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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/vm/callhelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ void MethodDescCallSite::CallTargetWorker(const ARG_SLOT *pArguments, ARG_SLOT *
callDescrData.fpReturnSize = fpReturnSize;
callDescrData.pTarget = m_pCallTarget;
#ifdef TARGET_WASM
callDescrData.nArgsSize = m_argIt.GetArgSize();
callDescrData.nArgsSize = nStackBytes;
#endif // TARGET_WASM

CallDescrWorkerWithHandler(&callDescrData);
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/vm/contractimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ struct DispatchToken
{
LIMITED_METHOD_CONTRACT;
return typeID > MAX_TYPE_ID_SMALL
#ifdef _DEBUG
// WASM-TODO: fix fat tokens
#if defined(_DEBUG) && !defined(TARGET_WASM)
// Stress the overflow mechanism in debug builds.
|| ((typeID != TYPE_ID_THIS_CLASS) && ((typeID % 7) < 4))
#endif
Expand Down
6 changes: 5 additions & 1 deletion src/coreclr/vm/virtualcallstub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2318,14 +2318,18 @@ VirtualCallStubManager::Resolver(
}
}
#endif // defined(LOGGING) || defined(_DEBUG)

#ifndef FEATURE_PORTABLE_ENTRYPOINTS
BOOL fSlotCallsPrestub = DoesSlotCallPrestub(implSlot.GetTarget());
if (!fSlotCallsPrestub)
{
// Only patch to a target if it's not going to call the prestub.
fShouldPatch = TRUE;
}
else
#else
BOOL fSlotCallsPrestub = FALSE;
fShouldPatch = TRUE;
#endif // !FEATURE_PORTABLE_ENTRYPOINTS
{
// Getting the MethodDesc is very expensive,
// so only call this when we are calling the prestub
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/wasm/cgencpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

inline unsigned StackElemSize(unsigned parmSize, bool isValueType = false /* unused */, bool isFloatHfa = false /* unused */)
{
_ASSERTE("The function is not implemented on wasm");
return 0;
const unsigned stackSlotSize = sizeof(void*);
return ALIGN_UP(parmSize, stackSlotSize);
}

inline TADDR GetSP(const T_CONTEXT * context)
Expand Down
19 changes: 15 additions & 4 deletions src/coreclr/vm/wasm/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,12 @@ namespace
(*fptr)(ARG(0), ARG(1), ARG(2));
}

void CallFunc_I32_I32_I32_I32_RetVoid(PCODE pcode, int8_t *pArgs, int8_t *pRet)
{
void (*fptr)(int32_t, int32_t, int32_t, int32_t) = (void (*)(int32_t, int32_t, int32_t, int32_t))pcode;
(*fptr)(ARG(0), ARG(1), ARG(2), ARG(3));
}

void CallFunc_I32_I32_I32_I32_I32_I32_RetVoid(PCODE pcode, int8_t *pArgs, int8_t *pRet)
{
void (*fptr)(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t) = (void (*)(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t))pcode;
Expand Down Expand Up @@ -521,7 +527,7 @@ namespace
(void*)&CallFunc_I32_RetVoid,
(void*)&CallFunc_I32_I32_RetVoid,
(void*)&CallFunc_I32_I32_I32_RetVoid,
NULL,
(void*)&CallFunc_I32_I32_I32_I32_RetVoid,
NULL,
(void*)&CallFunc_I32_I32_I32_I32_I32_I32_RetVoid,
};
Expand Down Expand Up @@ -687,10 +693,17 @@ namespace
if (!returnsVoid && ConvertibleTo(sig.GetReturnType(), sig, true /* isReturn */) != ConvertType::ToI32)
return NULL;

uint32_t numArgs = sig.NumFixedArgs() + (sig.HasThis() ? 1 : 0);
ConvertType args[16];
_ASSERTE(sig.NumFixedArgs() < ARRAY_SIZE(args));
_ASSERTE(numArgs < ARRAY_SIZE(args));

uint32_t i = 0;

if (sig.HasThis())
{
args[i++] = ConvertType::ToI32;
}

// Ensure all arguments are wasm i32 compatible types.
for (CorElementType argType = sig.NextArg();
argType != ELEMENT_TYPE_END;
Expand All @@ -704,8 +717,6 @@ namespace
args[i++] = type;
}

uint32_t numArgs = sig.NumFixedArgs();

// Check for homogeneous i32 argument types.
for (uint32_t j = 0; j < numArgs; j++)
{
Expand Down
Loading