Skip to content
Merged
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
16 changes: 8 additions & 8 deletions src/coreclr/interpreter/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2508,15 +2508,15 @@ void InterpCompiler::EmitCall(CORINFO_RESOLVED_TOKEN* constrainedClass, bool rea
}
else if ((callInfo.classFlags & CORINFO_FLG_ARRAY) && !readonly)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
else if ((callInfo.classFlags & CORINFO_FLG_ARRAY) && !readonly)
else if (callInfo.classFlags & CORINFO_FLG_ARRAY)

!readonly should not be needed here

Copy link
Member

Choose a reason for hiding this comment

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

Instead, you can check for newobj opcode and then you do not need the condition below:

if ((callInfo.classFlags & CORINFO_FLG_ARRAY) && newObj)

Copy link
Member

Choose a reason for hiding this comment

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

(It is what RuyJIT does - look for impImportNewObjArray.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks!

{
CORINFO_SIG_INFO ctorSignature;
CORINFO_CLASS_HANDLE ctorClass;
CORINFO_CLASS_HANDLE arrayClsHnd = m_compHnd->getMethodClass(resolvedCallToken.hMethod);
uint32_t rank = m_compHnd->getArrayRank(arrayClsHnd);

m_compHnd->getMethodSig(resolvedCallToken.hMethod, &ctorSignature);
ctorClass = m_compHnd->getMethodClass(resolvedCallToken.hMethod);

AddIns(INTOP_NEWMDARR);
m_pLastNewIns->data[0] = GetDataItemIndex(ctorClass);
m_pLastNewIns->data[1] = numArgs;
if (callInfo.sig.retType == CORINFO_TYPE_VOID && callInfo.sig.numArgs == rank && (m_compHnd->getMethodAttribs(resolvedCallToken.hMethod) & CORINFO_FLG_CONSTRUCTOR) != 0)
Copy link
Member

Choose a reason for hiding this comment

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

callInfo.sig.numArgs == rank condition is not 100% right. The multi-dimm array constructors can take rank or rank * 2 arguments.

The overload that takes rank * 2 arguments is not expressible in C#. It allows you to specify lower bounds.

{
AddIns(INTOP_NEWMDARR);
m_pLastNewIns->data[0] = GetDataItemIndex(arrayClsHnd);
m_pLastNewIns->data[1] = rank;
}
}
else
{
Expand Down
Loading