Skip to content
Merged
Changes from 2 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
13 changes: 5 additions & 8 deletions src/coreclr/interpreter/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2506,17 +2506,14 @@ void InterpCompiler::EmitCall(CORINFO_RESOLVED_TOKEN* constrainedClass, bool rea
}
m_pLastNewIns->data[0] = GetDataItemIndex(callInfo.hMethod);
}
else if ((callInfo.classFlags & CORINFO_FLG_ARRAY) && !readonly)
else if ((callInfo.classFlags & CORINFO_FLG_ARRAY) && newObj)
{
CORINFO_SIG_INFO ctorSignature;
CORINFO_CLASS_HANDLE ctorClass;

m_compHnd->getMethodSig(resolvedCallToken.hMethod, &ctorSignature);
ctorClass = m_compHnd->getMethodClass(resolvedCallToken.hMethod);
CORINFO_CLASS_HANDLE arrayClsHnd = m_compHnd->getMethodClass(resolvedCallToken.hMethod);
uint32_t rank = m_compHnd->getArrayRank(arrayClsHnd);

AddIns(INTOP_NEWMDARR);
m_pLastNewIns->data[0] = GetDataItemIndex(ctorClass);
m_pLastNewIns->data[1] = numArgs;
m_pLastNewIns->data[0] = GetDataItemIndex(arrayClsHnd);
m_pLastNewIns->data[1] = rank;
Copy link
Member

Choose a reason for hiding this comment

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

This should not be rank. This should be the actual number of the arguments in the signature, so that the code handles different overloads of array constructor correctly. The earlier code looks correct, the new code looks wrong. I think this part of the change should be reverted.

Copy link
Member

Choose a reason for hiding this comment

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

Also, you can rename the argument name on the executor side to numArgs to avoid confusion

static OBJECTREF CreateMultiDimArray(MethodTable* arrayClass, int8_t* stack, int32_t dimsOffset, int rank)

Copy link
Member Author

Choose a reason for hiding this comment

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

This should be the actual number of the arguments in the signature, so that the code handles different overloads of array constructor correctly.

Sorry I overlooked this even though you mentioned it. I was focused on #116493 and I think the error was not properly guarding the INTOP_NEWMDARR case, which caused other instance methods to take the same path.

}
else
{
Expand Down
Loading