From: Bruce Forstall Date: Tue, 2 May 2017 00:59:38 +0000 (-0700) Subject: Refactor GT_RETURNTRAP X-Git-Tag: submit/tizen/20210909.063632~11030^2~7048^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7eda5427555d7c60a256b6ebcd62428cc1433160;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Refactor GT_RETURNTRAP Commit migrated from https://github.com/dotnet/coreclr/commit/9dd6896c63be093b785014ace188d7c1927be7de --- diff --git a/src/coreclr/src/jit/codegenarm.cpp b/src/coreclr/src/jit/codegenarm.cpp index 019641e..7c053a3 100644 --- a/src/coreclr/src/jit/codegenarm.cpp +++ b/src/coreclr/src/jit/codegenarm.cpp @@ -647,25 +647,8 @@ void CodeGen::genCodeForTreeNode(GenTreePtr treeNode) break; case GT_RETURNTRAP: - { - // this is nothing but a conditional call to CORINFO_HELP_STOP_FOR_GC - // based on the contents of 'data' - - GenTree* data = treeNode->gtOp.gtOp1->gtEffectiveVal(); - genConsumeIfReg(data); - GenTreeIntCon cns = intForm(TYP_INT, 0); - emit->emitInsBinary(INS_cmp, emitTypeSize(TYP_INT), data, &cns); - - BasicBlock* skipLabel = genCreateTempLabel(); - - emitJumpKind jmpEqual = genJumpKindForOper(GT_EQ, CK_SIGNED); - inst_JMP(jmpEqual, skipLabel); - // emit the call to the EE-helper that stops for GC (or other reasons) - - genEmitHelperCall(CORINFO_HELP_STOP_FOR_GC, 0, EA_UNKNOWN); - genDefineTempLabel(skipLabel); - } - break; + genCodeForReturnTrap(treeNode->AsOp()); + break; case GT_STOREIND: genCodeForStoreInd(treeNode->AsStoreInd()); @@ -1577,6 +1560,34 @@ void CodeGen::genLeaInstruction(GenTreeAddrMode* lea) } //------------------------------------------------------------------------ +// genCodeForReturnTrap: Produce code for a GT_RETURNTRAP node. +// +// Arguments: +// tree - the GT_RETURNTRAP node +// +void CodeGen::genCodeForReturnTrap(GenTreeOp* tree) +{ + assert(tree->OperGet() == GT_RETURNTRAP); + + // this is nothing but a conditional call to CORINFO_HELP_STOP_FOR_GC + // based on the contents of 'data' + + GenTree* data = tree->gtOp1->gtEffectiveVal(); + genConsumeIfReg(data); + GenTreeIntCon cns = intForm(TYP_INT, 0); + getEmitter()->emitInsBinary(INS_cmp, emitTypeSize(TYP_INT), data, &cns); + + BasicBlock* skipLabel = genCreateTempLabel(); + + emitJumpKind jmpEqual = genJumpKindForOper(GT_EQ, CK_SIGNED); + inst_JMP(jmpEqual, skipLabel); + // emit the call to the EE-helper that stops for GC (or other reasons) + + genEmitHelperCall(CORINFO_HELP_STOP_FOR_GC, 0, EA_UNKNOWN); + genDefineTempLabel(skipLabel); +} + +//------------------------------------------------------------------------ // genCodeForStoreInd: Produce code for a GT_STOREIND node. // // Arguments: diff --git a/src/coreclr/src/jit/codegenarm64.cpp b/src/coreclr/src/jit/codegenarm64.cpp index 8deeff3..f47e79d 100644 --- a/src/coreclr/src/jit/codegenarm64.cpp +++ b/src/coreclr/src/jit/codegenarm64.cpp @@ -2440,24 +2440,8 @@ void CodeGen::genCodeForTreeNode(GenTreePtr treeNode) break; case GT_RETURNTRAP: - { - // this is nothing but a conditional call to CORINFO_HELP_STOP_FOR_GC - // based on the contents of 'data' - - GenTree* data = treeNode->gtOp.gtOp1; - genConsumeRegs(data); - emit->emitIns_R_I(INS_cmp, EA_4BYTE, data->gtRegNum, 0); - - BasicBlock* skipLabel = genCreateTempLabel(); - - emitJumpKind jmpEqual = genJumpKindForOper(GT_EQ, CK_SIGNED); - inst_JMP(jmpEqual, skipLabel); - // emit the call to the EE-helper that stops for GC (or other reasons) - - genEmitHelperCall(CORINFO_HELP_STOP_FOR_GC, 0, EA_UNKNOWN); - genDefineTempLabel(skipLabel); - } - break; + genCodeForReturnTrap(treeNode->AsOp()); + break; case GT_STOREIND: genCodeForStoreInd(treeNode->AsStoreInd()); @@ -4019,6 +4003,33 @@ void CodeGen::genLeaInstruction(GenTreeAddrMode* lea) } //------------------------------------------------------------------------ +// genCodeForReturnTrap: Produce code for a GT_RETURNTRAP node. +// +// Arguments: +// tree - the GT_RETURNTRAP node +// +void CodeGen::genCodeForReturnTrap(GenTreeOp* tree) +{ + assert(tree->OperGet() == GT_RETURNTRAP); + + // this is nothing but a conditional call to CORINFO_HELP_STOP_FOR_GC + // based on the contents of 'data' + + GenTree* data = tree->gtOp1; + genConsumeRegs(data); + getEmitter()->emitIns_R_I(INS_cmp, EA_4BYTE, data->gtRegNum, 0); + + BasicBlock* skipLabel = genCreateTempLabel(); + + emitJumpKind jmpEqual = genJumpKindForOper(GT_EQ, CK_SIGNED); + inst_JMP(jmpEqual, skipLabel); + // emit the call to the EE-helper that stops for GC (or other reasons) + + genEmitHelperCall(CORINFO_HELP_STOP_FOR_GC, 0, EA_UNKNOWN); + genDefineTempLabel(skipLabel); +} + +//------------------------------------------------------------------------ // genCodeForStoreInd: Produce code for a GT_STOREIND node. // // Arguments: diff --git a/src/coreclr/src/jit/codegenlinear.h b/src/coreclr/src/jit/codegenlinear.h index 89322a9..1d711e3 100644 --- a/src/coreclr/src/jit/codegenlinear.h +++ b/src/coreclr/src/jit/codegenlinear.h @@ -174,6 +174,8 @@ void genCodeForStoreLclFld(GenTreeLclFld* tree); void genCodeForStoreLclVar(GenTreeLclVar* tree); +void genCodeForReturnTrap(GenTreeOp* tree); + void genCodeForStoreInd(GenTreeStoreInd* tree); void genCodeForCpObj(GenTreeObj* cpObjNode);