Skip to content

Commit

Permalink
[RISC-V] Skip ComputeReturnFlags in ArgIteratorTemplate::HasRetBuffArg
Browse files Browse the repository at this point in the history
ComputeReturnFlags on RISC-V is complicated due to ABI rules on enregistering small structs and it can even potentially trigger an unnecessary class load. So take a shortcut when we only need to check whether a struct is returned in a buffer.
  • Loading branch information
tomeksowi committed Feb 2, 2024
1 parent 53d8003 commit c4f7e13
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/coreclr/vm/callingconvention.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,26 @@ class ArgIteratorTemplate : public ARGITERATOR_BASE
{
WRAPPER_NO_CONTRACT;
if (!(m_dwFlags & RETURN_FLAGS_COMPUTED))
{
#ifdef TARGET_RISCV64
// On RISC-V computing all return flags is complicated due to ABI rules on enregistering small structs
// so just check struct size and be done with it.
TypeHandle valueType;
switch (this->GetReturnType(&valueType))
{
case ELEMENT_TYPE_TYPEDBYREF:
return (sizeof(TypedByRef) > ENREGISTERED_RETURNTYPE_INTEGER_MAXSIZE);
case ELEMENT_TYPE_VALUETYPE:
assert(!valueType.IsNull());
assert(!valueType.IsTypeDesc());
return (valueType.GetSize() > ENREGISTERED_RETURNTYPE_INTEGER_MAXSIZE);
default:
return false;
}
#else
ComputeReturnFlags();
#endif
}
return (m_dwFlags & RETURN_HAS_RET_BUFFER);
}

Expand Down

0 comments on commit c4f7e13

Please sign in to comment.