Skip to content

[clr-interp] Emit INTOP_NEWMDARR only for array ctor #116544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 6 additions & 12 deletions src/coreclr/interpreter/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2554,24 +2554,18 @@ void InterpCompiler::EmitCall(CORINFO_RESOLVED_TOKEN* constrainedClass, bool rea
}
m_pLastNewIns->data[0] = GetDataItemIndex(callInfo.hMethod);
}
else if ((callInfo.classFlags & CORINFO_FLG_ARRAY) && newObj)
{
AddIns(INTOP_NEWMDARR);
m_pLastNewIns->data[0] = GetDataItemIndex(resolvedCallToken.hClass);
m_pLastNewIns->data[1] = callInfo.sig.numArgs;
}
else if (isCalli)
{
AddIns(INTOP_CALLI);
m_pLastNewIns->data[0] = GetDataItemIndex(calliCookie);
m_pLastNewIns->SetSVars2(CALL_ARGS_SVAR, callIFunctionPointerVar);
}
else if ((callInfo.classFlags & CORINFO_FLG_ARRAY) && !readonly)
{
CORINFO_SIG_INFO ctorSignature;
CORINFO_CLASS_HANDLE ctorClass;

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;
}
else
{
// Normal call
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/vm/interpexec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ static void InterpBreakpoint()
}
#endif

static OBJECTREF CreateMultiDimArray(MethodTable* arrayClass, int8_t* stack, int32_t dimsOffset, int rank)
static OBJECTREF CreateMultiDimArray(MethodTable* arrayClass, int8_t* stack, int32_t dimsOffset, int numArgs)
{
int32_t* dims = (int32_t*)alloca(rank * sizeof(int32_t));
for (int i = 0; i < rank; i++)
int32_t* dims = (int32_t*)alloca(numArgs * sizeof(int32_t));
for (int i = 0; i < numArgs; i++)
{
dims[i] = *(int32_t*)(stack + dimsOffset + i * 8);
}

return AllocateArrayEx(arrayClass, dims, rank);
return AllocateArrayEx(arrayClass, dims, numArgs);
}

#define LOCAL_VAR_ADDR(offset,type) ((type*)(stack + (offset)))
Expand Down