@@ -3584,6 +3584,8 @@ unsigned Compiler::acdHelper(SpecialCodeKind codeKind)
35843584 return CORINFO_HELP_THROWDIVZERO;
35853585 case SCK_ARITH_EXCPN:
35863586 return CORINFO_HELP_OVERFLOW;
3587+ case SCK_FAIL_FAST:
3588+ return CORINFO_HELP_FAIL_FAST;
35873589 default :
35883590 assert (!" Bad codeKind" );
35893591 return 0 ;
@@ -3608,8 +3610,10 @@ BasicBlock* Compiler::fgAddCodeRef(BasicBlock* srcBlk, unsigned refData, Special
36083610 // arg slots on the stack frame if there are no other calls.
36093611 compUsesThrowHelper = true ;
36103612
3611- if (!fgUseThrowHelperBlocks ())
3613+ if (!fgUseThrowHelperBlocks () && (kind != SCK_FAIL_FAST) )
36123614 {
3615+ // We'll create a throw block in-place then (for better debugging)
3616+ // It's not needed for fail fast, since it's not recoverable anyway.
36133617 return nullptr ;
36143618 }
36153619
@@ -3620,6 +3624,7 @@ BasicBlock* Compiler::fgAddCodeRef(BasicBlock* srcBlk, unsigned refData, Special
36203624 BBJ_THROW, // SCK_ARITH_EXCP, SCK_OVERFLOW
36213625 BBJ_THROW, // SCK_ARG_EXCPN
36223626 BBJ_THROW, // SCK_ARG_RNG_EXCPN
3627+ BBJ_THROW, // SCK_FAIL_FAST
36233628 };
36243629
36253630 noway_assert (sizeof (jumpKinds) == SCK_COUNT); // sanity check
@@ -3695,6 +3700,9 @@ BasicBlock* Compiler::fgAddCodeRef(BasicBlock* srcBlk, unsigned refData, Special
36953700 case SCK_ARG_RNG_EXCPN:
36963701 msg = " for ARG_RNG_EXCPN" ;
36973702 break ;
3703+ case SCK_FAIL_FAST:
3704+ msg = " for FAIL_FAST" ;
3705+ break ;
36983706 default :
36993707 msg = " for ??" ;
37003708 break ;
@@ -3712,8 +3720,7 @@ BasicBlock* Compiler::fgAddCodeRef(BasicBlock* srcBlk, unsigned refData, Special
37123720
37133721 /* Remember that we're adding a new basic block */
37143722
3715- fgAddCodeModf = true ;
3716- fgRngChkThrowAdded = true ;
3723+ fgAddCodeModf = true ;
37173724
37183725 /* Now figure out what code to insert */
37193726
@@ -3743,6 +3750,10 @@ BasicBlock* Compiler::fgAddCodeRef(BasicBlock* srcBlk, unsigned refData, Special
37433750 helper = CORINFO_HELP_THROW_ARGUMENTOUTOFRANGEEXCEPTION;
37443751 break ;
37453752
3753+ case SCK_FAIL_FAST:
3754+ helper = CORINFO_HELP_FAIL_FAST;
3755+ break ;
3756+
37463757 default :
37473758 noway_assert (!" unexpected code addition kind" );
37483759 return nullptr ;
@@ -3759,7 +3770,6 @@ BasicBlock* Compiler::fgAddCodeRef(BasicBlock* srcBlk, unsigned refData, Special
37593770 tree = fgMorphArgs (tree);
37603771
37613772 // Store the tree in the new basic block.
3762- assert (!srcBlk->isEmpty ());
37633773 if (!srcBlk->IsLIR ())
37643774 {
37653775 fgInsertStmtAtEnd (newBlk, fgNewStmtFromTree (tree));
@@ -3781,7 +3791,7 @@ BasicBlock* Compiler::fgAddCodeRef(BasicBlock* srcBlk, unsigned refData, Special
37813791
37823792Compiler::AddCodeDsc* Compiler::fgFindExcptnTarget (SpecialCodeKind kind, unsigned refData)
37833793{
3784- assert (fgUseThrowHelperBlocks ());
3794+ assert (fgUseThrowHelperBlocks () || (kind == SCK_FAIL_FAST) );
37853795 if (!(fgExcptnTargetCache[kind] && // Try the cached value first
37863796 fgExcptnTargetCache[kind]->acdData == refData))
37873797 {
0 commit comments