Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

JIT: Use AllocObj for box allocations #13988

Merged
merged 1 commit into from
Sep 15, 2017
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
29 changes: 22 additions & 7 deletions src/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12525,13 +12525,28 @@ GenTree* Compiler::gtTryRemoveBoxUpstreamEffects(GenTree* op, BoxRemovalOptions
GenTree* boxTypeHandle = nullptr;
if (options == BR_REMOVE_AND_NARROW_WANT_TYPE_HANDLE)
{
// Note we might see GenTreeAllocObj here, if impImportAndPushBox
// starts using it instead of a bare helper call.
GenTree* asgSrc = asg->gtOp.gtOp2;
assert(asgSrc->IsCall());
GenTreeCall* newobjCall = asgSrc->AsCall();
GenTreeArgList* newobjArgs = newobjCall->gtCallArgs->AsArgList();
boxTypeHandle = newobjArgs->Current();
GenTree* asgSrc = asg->gtOp.gtOp2;
genTreeOps asgSrcOper = asgSrc->OperGet();

// Allocation may be via AllocObj or via helper call, depending
// on when this is invoked and whether the jit is using AllocObj
// for R2R allocations.
if (asgSrcOper == GT_ALLOCOBJ)
{
GenTreeAllocObj* allocObj = asgSrc->AsAllocObj();
boxTypeHandle = allocObj->gtOp.gtOp1;
}
else if (asgSrcOper == GT_CALL)
{
GenTreeCall* newobjCall = asgSrc->AsCall();
GenTreeArgList* newobjArgs = newobjCall->gtCallArgs->AsArgList();
boxTypeHandle = newobjArgs->Current();
}
else
{
unreached();
}

assert(boxTypeHandle != nullptr);
}

Expand Down
7 changes: 4 additions & 3 deletions src/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5449,12 +5449,13 @@ void Compiler::impImportAndPushBox(CORINFO_RESOLVED_TOKEN* pResolvedToken)
return;
}

op1 = gtNewHelperCallNode(info.compCompHnd->getNewHelper(pResolvedToken, info.compMethodHnd), TYP_REF,
gtNewArgList(op2));
op1 = gtNewAllocObjNode(info.compCompHnd->getNewHelper(pResolvedToken, info.compMethodHnd),
pResolvedToken->hClass, TYP_REF, op2);
}

/* Remember that this basic block contains 'new' of an object */
/* Remember that this basic block contains 'new' of an object, and so does this method */
compCurBB->bbFlags |= BBF_HAS_NEWOBJ;
optMethodFlags |= OMF_HAS_NEWOBJ;

GenTreePtr asg = gtNewTempAssign(impBoxTemp, op1);

Expand Down