This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Inliner: enable inlining of methods with conditional throws #8038
Merged
AndyAyersMS
merged 2 commits into
dotnet:master
from
AndyAyersMS:InlineConditionalThrows
Nov 9, 2016
Merged
Inliner: enable inlining of methods with conditional throws #8038
AndyAyersMS
merged 2 commits into
dotnet:master
from
AndyAyersMS:InlineConditionalThrows
Nov 9, 2016
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Remove inlining limitation for methods that return values and have conditional throws. This limitation was most likely a vestige of an older inlining implementation that did not break trees at inline call sites. Also removed the now-unused observation and the `seenConditionalJump` member variable. Merged ifdef blocks in `impInit`. Ran full desktop testing, no issues. Enables a handful of inlines in the various code size suites. For the most part these slightly increase code size but can often shorten the non-EH paths in the code.
cc @dotnet/jit-contrib Output from jit-diff:
Example code diff: ;;; Assembly listing for method System.AppDomain:ExecuteAssembly(ref):int:this
;;; Before
G_M56995_IG01:
sub rsp, 40
nop
G_M56995_IG02:
xor r8d, r8d
mov dword ptr [rsp+20H], r8d
xor r8, r8
xor r9, r9
call [System.AppDomain:ExecuteAssembly(ref,ref,ref,int):int:this]
nop
G_M56995_IG03:
add rsp, 40
ret
;;; After
G_M56995_IG01:
push rsi
sub rsp, 32
G_M56995_IG02:
test rdx, rdx
je SHORT G_M56995_IG05
G_M56995_IG03:
xor eax, eax
G_M56995_IG04:
add rsp, 32
pop rsi
ret
G_M56995_IG05:
call [CORINFO_HELP_READYTORUN_NEW]
mov rsi, rax
mov ecx, 425
call CORINFO_HELP_STRCNS_CURRENT_MODULE
mov rdx, rax
mov rcx, rsi
call [System.ArgumentNullException:.ctor(ref):this]
mov rcx, rsi
call CORINFO_HELP_THROW
int3 |
So now methods like the following will be inlined? private int GetLength(string str)
{
if (str == null)
throw new ArgumentNullException();
return str.Length:
} |
@omariom the conditional throw will no longer block inlining, so a simple method like this should get inlined. |
@dotnet/jit-contrib anyone up for a review? It is a pretty small change... |
CarolEidt
approved these changes
Nov 9, 2016
LGTM |
Ignoring the jit diff failure. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Remove inlining limitation for methods that return values and have
conditional throws. This limitation was most likely a vestige of an
older inlining implementation that did not break trees at inline
call sites.
Also removed the now-unused observation and the
seenConditionalJump
member variable. Merged ifdef blocks in
impInit
.Ran full desktop testing, no issues.
Enables a handful of inlines in the various code size suites. For the
most part these slightly increase code size but can often shorten the
non-EH paths in the code.