Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
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: 13 additions & 5 deletions src/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6830,7 +6830,7 @@ var_types Compiler::impImportCall(OPCODE opcode,
//-------------------------------------------------------------------------
// The "this" pointer

if (!(mflags & CORINFO_FLG_STATIC) || opcode == CEE_NEWOBJ)
if (!(mflags & CORINFO_FLG_STATIC) && !((opcode == CEE_NEWOBJ) && (newobjThis == nullptr)))
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that opcode == CEE_NEWOBJ condition was unnecessary in the original code because of CORINFO_FLG_STATIC is never set for instance constructors.

{
GenTreePtr obj;

Expand Down Expand Up @@ -11736,10 +11736,18 @@ MATH_MAYBE_CALL_NO_OVF: ovfl = false;
// At present this can only be String
else if (clsFlags & CORINFO_FLG_VAROBJSIZE)
{
// This is the case for variable-sized objects that are not
// arrays. In this case, call the constructor with a null 'this'
// pointer
newObjThisPtr = gtNewIconNode(0, TYP_REF);
if (eeGetEEInfo()->targetAbi == CORINFO_CORERT_ABI)
{
// The dummy argument does not exist in CoreRT
newObjThisPtr = nullptr;
}
else
{
// This is the case for variable-sized objects that are not
// arrays. In this case, call the constructor with a null 'this'
// pointer
newObjThisPtr = gtNewIconNode(0, TYP_REF);
}

/* Remember that this basic block contains 'new' of an object */
block->bbFlags |= BBF_HAS_NEWOBJ;
Expand Down