-
Notifications
You must be signed in to change notification settings - Fork 5.2k
JIT: switch escape analysis flagging to look for calls returning IEnumerator<T>
#116978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
8660fb8
1e27322
34e56e0
ca750f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6929,30 +6929,33 @@ void Compiler::impImportBlockCode(BasicBlock* block) | |||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // If we see a local being assigned the result of a GDV-inlineable | ||||||||||||||||||||||||
| // IEnumerable<T>.GetEnumerator, keep track of both the local and the call. | ||||||||||||||||||||||||
| // GetEnumerator call, keep track of both the local and the call. | ||||||||||||||||||||||||
| // | ||||||||||||||||||||||||
| if (op1->OperIs(GT_RET_EXPR)) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| JITDUMP(".... checking for GDV of IEnumerable<T>...\n"); | ||||||||||||||||||||||||
| JITDUMP(".... checking for GDV returning IEnumerator<T>...\n"); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| GenTreeCall* const call = op1->AsRetExpr()->gtInlineCandidate; | ||||||||||||||||||||||||
| NamedIntrinsic ni = NI_Illegal; | ||||||||||||||||||||||||
| bool isEnumeratorT = false; | ||||||||||||||||||||||||
| GenTreeCall* const call = op1->AsRetExpr()->gtInlineCandidate; | ||||||||||||||||||||||||
| bool isExact = false; | ||||||||||||||||||||||||
| bool isNonNull = false; | ||||||||||||||||||||||||
| CORINFO_CLASS_HANDLE retCls = gtGetClassHandle(call, &isExact, &isNonNull); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // TODO -- handle CT_INDIRECT virtuals here too | ||||||||||||||||||||||||
| // but we don't have the right method handle | ||||||||||||||||||||||||
| // | ||||||||||||||||||||||||
| if (call->gtCallType == CT_USER_FUNC) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| ni = lookupNamedIntrinsic(call->gtCallMethHnd); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| else if (call->IsGuardedDevirtualizationCandidate()) | ||||||||||||||||||||||||
| if ((retCls != NO_CLASS_HANDLE) && info.compCompHnd->isIntrinsicType(retCls)) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| JITDUMP("No GDV IEnumerable<T> check for [%06u]\n", dspTreeID(call)); | ||||||||||||||||||||||||
| const char* namespaceName; | ||||||||||||||||||||||||
| const char* className = info.compCompHnd->getClassNameFromMetadata(retCls, &namespaceName); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if ((strcmp(namespaceName, "System.Collections.Generic") == 0) && | ||||||||||||||||||||||||
| (strcmp(className, "IEnumerator`1") == 0)) | ||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I'd expect the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. Might be small compared the cost of obtaining the strings in the first place, but every cycle counts. Will do this in a subsequent PR. |
||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
|
Comment on lines
+6949
to
+6951
|
||||||||||||||||||||||||
| if ((strcmp(namespaceName, "System.Collections.Generic") == 0) && | |
| (strcmp(className, "IEnumerator`1") == 0)) | |
| { | |
| static CORINFO_CLASS_HANDLE cachedIEnumeratorHandle = NO_CLASS_HANDLE; | |
| if (cachedIEnumeratorHandle == NO_CLASS_HANDLE) | |
| { | |
| cachedIEnumeratorHandle = info.compCompHnd->findClass("System.Collections.Generic", "IEnumerator`1"); | |
| } | |
| if (retCls == cachedIEnumeratorHandle) | |
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, copilot. There is no findClass like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps move this check in
lookupNamedIntrinsicand renameNI_System_Collections_Generic_IEnumerable_GetEnumeratorsince the constant is now unsued.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lookupNamedIntrinsicis for methods. This is a class check.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the now unneded constant and lookup support.