From 730c91eeec8def2796883a6b0bac4ba24c03232e Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Sun, 26 Jan 2020 19:18:56 -0800 Subject: [PATCH 1/2] JIT: remove inlining restriction for some methods that throw We were blocking inlines for methods that throw with more than one thing on the evaluation stack. There was already logic for the non-inlining case to flush the stack and preserve pending side effects. So we can simply remove the inlining restriction. Fixes #2156. --- src/coreclr/src/jit/importer.cpp | 24 +++++------------------- src/coreclr/src/jit/inline.def | 1 - 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/coreclr/src/jit/importer.cpp b/src/coreclr/src/jit/importer.cpp index 266f6518b01cf8..919e9475fc9380 100644 --- a/src/coreclr/src/jit/importer.cpp +++ b/src/coreclr/src/jit/importer.cpp @@ -15595,23 +15595,6 @@ void Compiler::impImportBlockCode(BasicBlock* block) case CEE_THROW: - if (compIsForInlining()) - { - // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // TODO: Will this be too strict, given that we will inline many basic blocks? - // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - /* Do we have just the exception on the stack ?*/ - - if (verCurrentState.esStackDepth != 1) - { - /* if not, just don't inline the method */ - - compInlineResult->NoteFatal(InlineObservation::CALLEE_THROW_WITH_INVALID_STACK); - return; - } - } - if (tiVerificationNeeded) { tiRetVal = impStackTop().seTypeInfo; @@ -15622,11 +15605,14 @@ void Compiler::impImportBlockCode(BasicBlock* block) } } - block->bbSetRunRarely(); // any block with a throw is rare - /* Pop the exception object and create the 'throw' helper call */ + // Any block with a throw is rarely executed. + block->bbSetRunRarely(); + // Pop the exception object and create the 'throw' helper call op1 = gtNewHelperCallNode(CORINFO_HELP_THROW, TYP_VOID, gtNewCallArgs(impPopStack().val)); + // Fall through to clear out the eval stack. + EVAL_APPEND: if (verCurrentState.esStackDepth > 0) { diff --git a/src/coreclr/src/jit/inline.def b/src/coreclr/src/jit/inline.def index b4f01c513788eb..c9c613093bd56e 100644 --- a/src/coreclr/src/jit/inline.def +++ b/src/coreclr/src/jit/inline.def @@ -58,7 +58,6 @@ INLINE_OBSERVATION(NOT_PROFITABLE_INLINE, bool, "unprofitable inline", INLINE_OBSERVATION(RANDOM_REJECT, bool, "random reject", FATAL, CALLEE) INLINE_OBSERVATION(STACK_CRAWL_MARK, bool, "uses stack crawl mark", FATAL, CALLEE) INLINE_OBSERVATION(STFLD_NEEDS_HELPER, bool, "stfld needs helper", FATAL, CALLEE) -INLINE_OBSERVATION(THROW_WITH_INVALID_STACK, bool, "throw with invalid stack", FATAL, CALLEE) INLINE_OBSERVATION(TOO_MANY_ARGUMENTS, bool, "too many arguments", FATAL, CALLEE) INLINE_OBSERVATION(TOO_MANY_LOCALS, bool, "too many locals", FATAL, CALLEE) INLINE_OBSERVATION(EXPLICIT_TAIL_PREFIX, bool, "explicit tail prefix in callee",FATAL, CALLEE) From a0db6531f8d697628410bf9ed6c397aa53cfbb6c Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Mon, 27 Jan 2020 09:37:01 -0800 Subject: [PATCH 2/2] fix formatting --- src/coreclr/src/jit/importer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/src/jit/importer.cpp b/src/coreclr/src/jit/importer.cpp index 919e9475fc9380..8520e16c350e36 100644 --- a/src/coreclr/src/jit/importer.cpp +++ b/src/coreclr/src/jit/importer.cpp @@ -15611,7 +15611,7 @@ void Compiler::impImportBlockCode(BasicBlock* block) // Pop the exception object and create the 'throw' helper call op1 = gtNewHelperCallNode(CORINFO_HELP_THROW, TYP_VOID, gtNewCallArgs(impPopStack().val)); - // Fall through to clear out the eval stack. + // Fall through to clear out the eval stack. EVAL_APPEND: if (verCurrentState.esStackDepth > 0)