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

Commit ebbea0a

Browse files
committed
Inline refactor: revise checks in fgFindJumpTargets
In this method, the inliner will check for unsupported opcodes and similar things. Refactor these checks to directly bail out if an issue is discovered, rather than going to a common handler snippet. There are two functionality changes: First, if an unsupported opcode is found (currently: switch, jmp, calli, localloc, cpblk, mkrefany, rethrow) mark the inlinee as never inlinable, rather than just failing the current attempt. This should not change externally visible behavior but will improve jit TP marginally if such cases are common. Second, for NETCF quirk handling, make sure to guard some of the observations with a check that we're reading the IL for inlining.
1 parent 09bd376 commit ebbea0a

File tree

1 file changed

+38
-48
lines changed

1 file changed

+38
-48
lines changed

src/jit/flowgraph.cpp

Lines changed: 38 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4198,8 +4198,6 @@ void Compiler::fgFindJumpTargets(const BYTE * codeAddr,
41984198

41994199
OPCODE opcode;
42004200

4201-
const char * inlineFailReason = NULL;
4202-
42034201
var_types varType = DUMMY_INIT(TYP_UNDEF); // TYP_ type
42044202
typeInfo ti; // Verifier type.
42054203

@@ -4436,10 +4434,13 @@ void Compiler::fgFindJumpTargets(const BYTE * codeAddr,
44364434

44374435
#ifdef FEATURE_LEGACYNETCF
44384436

4439-
if (stateNetCFQuirks >= 0)
4437+
if (compIsForInlining())
44404438
{
4441-
inlineFailReason = "Windows Phone OS 7 compatibility - Inlinee contains control flow.";
4442-
goto InlineNever;
4439+
if (stateNetCFQuirks >= 0)
4440+
{
4441+
compInlineResult->setNever("Windows Phone OS 7 compatibility - Inlinee contains control flow");
4442+
return;
4443+
}
44434444
}
44444445

44454446
#endif // FEATURE_LEGACYNETCF
@@ -4483,14 +4484,14 @@ void Compiler::fgFindJumpTargets(const BYTE * codeAddr,
44834484

44844485
if (stateNetCFQuirks >= 0)
44854486
{
4486-
inlineFailReason = "Windows Phone OS 7 compatibility - Inlinee contains control flow.";
4487-
goto InlineNever;
4487+
compInlineResult->setNever("Windows Phone OS 7 compatibility - Inlinee contains control flow");
4488+
return;
44884489
}
44894490

44904491
#endif // FEATURE_LEGACYNETCF
44914492

4492-
inlineFailReason = "Inlinee contains SWITCH instruction.";
4493-
goto InlineFailed;
4493+
compInlineResult->setNever("Inlinee contains SWITCH instruction");
4494+
return;
44944495
}
44954496

44964497
// Make sure we don't go past the end reading the number of cases
@@ -4549,10 +4550,13 @@ void Compiler::fgFindJumpTargets(const BYTE * codeAddr,
45494550

45504551
#ifdef FEATURE_LEGACYNETCF
45514552

4552-
if (stateNetCFQuirks >= 0)
4553+
if (compIsForInlining())
45534554
{
4554-
inlineFailReason = "Windows Phone OS 7 compatibility - Inlinee contains prefix.";
4555-
goto InlineNever;
4555+
if (stateNetCFQuirks >= 0)
4556+
{
4557+
compInlineResult->setNever("Windows Phone OS 7 compatibility - Inlinee contains prefix");
4558+
return;
4559+
}
45564560
}
45574561

45584562
#endif // FEATURE_LEGACYNETCF
@@ -4572,10 +4576,13 @@ void Compiler::fgFindJumpTargets(const BYTE * codeAddr,
45724576

45734577
#ifdef FEATURE_LEGACYNETCF
45744578

4575-
if (stateNetCFQuirks >= 0)
4579+
if (compIsForInlining())
45764580
{
4577-
inlineFailReason = "Windows Phone OS 7 compatibility - Inlinee contains throw.";
4578-
goto InlineNever;
4581+
if (stateNetCFQuirks >= 0)
4582+
{
4583+
compInlineResult->setNever("Windows Phone OS 7 compatibility - Inlinee contains throw");
4584+
return;
4585+
}
45794586
}
45804587

45814588
#endif // FEATURE_LEGACYNETCF
@@ -4624,14 +4631,16 @@ void Compiler::fgFindJumpTargets(const BYTE * codeAddr,
46244631
//Consider making this only for not force inline.
46254632
if (compIsForInlining())
46264633
{
4634+
char *message;
46274635
#ifdef DEBUG
4628-
inlineFailReason = (char*)compAllocator->nraAlloc(128);
4629-
sprintf((char*)inlineFailReason, "Unsupported opcode for inlining: %s\n",
4636+
message = (char*)compAllocator->nraAlloc(128);
4637+
sprintf((char*)message, "Unsupported opcode for inlining: %s\n",
46304638
opcodeNames[opcode]);
46314639
#else
4632-
inlineFailReason = "Unsupported opcode for inlining.";
4640+
message = "Unsupported opcode for inlining";
46334641
#endif
4634-
goto InlineFailed;
4642+
compInlineResult->setNever(message);
4643+
return;
46354644
}
46364645
break;
46374646

@@ -4755,8 +4764,8 @@ void Compiler::fgFindJumpTargets(const BYTE * codeAddr,
47554764
stateNetCFQuirks++;
47564765
if (varNum != expectedVarNum)
47574766
{
4758-
inlineFailReason = "Windows Phone OS 7 compatibility - out of order ldarg.";
4759-
goto InlineNever;
4767+
compInlineResult->setNever("Windows Phone OS 7 compatibility - out of order ldarg");
4768+
return;
47604769
}
47614770
}
47624771

@@ -4770,10 +4779,13 @@ void Compiler::fgFindJumpTargets(const BYTE * codeAddr,
47704779

47714780
#ifdef FEATURE_LEGACYNETCF
47724781

4773-
if (stateNetCFQuirks >= 0)
4782+
if (compIsForInlining())
47744783
{
4775-
inlineFailReason = "Windows Phone OS 7 compatibility - address taken.";
4776-
goto InlineNever;
4784+
if (stateNetCFQuirks >= 0)
4785+
{
4786+
compInlineResult->setNever("Windows Phone OS 7 compatibility - address taken");
4787+
return;
4788+
}
47774789
}
47784790

47794791
#endif // FEATURE_LEGACYNETCF
@@ -4898,8 +4910,8 @@ void Compiler::fgFindJumpTargets(const BYTE * codeAddr,
48984910
/* The inliner keeps the args as trees and clones them. Storing the arguments breaks that
48994911
* simplification. To allow this, flag the argument as written to and spill it before
49004912
* inlining. That way the STARG in the inlinee is trivial. */
4901-
inlineFailReason = "Inlinee writes to an argument.";
4902-
goto InlineNever;
4913+
compInlineResult->setNever("Inlinee writes to an argument");
4914+
return;
49034915
}
49044916
else
49054917
{
@@ -5045,28 +5057,6 @@ void Compiler::fgFindJumpTargets(const BYTE * codeAddr,
50455057
}
50465058

50475059
return;
5048-
5049-
CorInfoInline failResult;
5050-
InlineNever:
5051-
compInlineResult->setNever(inlineFailReason);
5052-
goto Report;
5053-
InlineFailed:
5054-
compInlineResult->setFailure(inlineFailReason);
5055-
5056-
Report:
5057-
#ifdef DEBUG
5058-
if (verbose)
5059-
{
5060-
impCurOpcName = opcodeNames[opcode];
5061-
printf("\n\nInline expansion aborted due to opcode [%02u] OP_%s in method %s\n",
5062-
codeAddr-codeBegp-1, impCurOpcName, info.compFullName);
5063-
}
5064-
#endif
5065-
5066-
noway_assert(compIsForInlining());
5067-
noway_assert(impInlineInfo->fncHandle == info.compMethodHnd);
5068-
5069-
return;
50705060
}
50715061
#ifdef _PREFAST_
50725062
#pragma warning(pop)

0 commit comments

Comments
 (0)