This repository has been archived by the owner on Nov 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 508
Implement ldvirtftn in shared generic contexts #2339
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2683,23 +2683,33 @@ private void getCallInfo(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_RESO | |
(void*)ObjectToHandle(_compilation.NodeFactory.ReadyToRunHelper(ReadyToRunHelperId.ResolveGenericVirtualMethod, targetMethod)); | ||
pResult.nullInstanceCheck = false; | ||
} | ||
else if ((flags & CORINFO_CALLINFO_FLAGS.CORINFO_CALLINFO_LDFTN) != 0) | ||
else | ||
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. This changes the structure to fold together the virtual and non-virtual dispatch paths. While that is a simplification for now(since we only have R2R codegen), it is not in touch with longer term direction where we'll want to have more optimized codegen that handles the various cases in the most optimal form. |
||
{ | ||
pResult.kind = CORINFO_CALL_KIND.CORINFO_VIRTUALCALL_LDVIRTFTN; | ||
pResult.codePointerOrStubLookup.constLookup.accessType = InfoAccessType.IAT_VALUE; | ||
ReadyToRunHelperId helper; | ||
|
||
pResult.codePointerOrStubLookup.constLookup.addr = | ||
(void*)ObjectToHandle(_compilation.NodeFactory.ReadyToRunHelper(ReadyToRunHelperId.ResolveVirtualFunction, targetMethod)); | ||
if ((flags & CORINFO_CALLINFO_FLAGS.CORINFO_CALLINFO_LDFTN) != 0) | ||
{ | ||
pResult.kind = CORINFO_CALL_KIND.CORINFO_VIRTUALCALL_LDVIRTFTN; | ||
helper = ReadyToRunHelperId.ResolveVirtualFunction; | ||
} | ||
else | ||
{ | ||
// CORINFO_CALL_CODE_POINTER tells the JIT that this is indirect | ||
// call that should not be inlined. | ||
pResult.kind = CORINFO_CALL_KIND.CORINFO_CALL_CODE_POINTER; | ||
helper = ReadyToRunHelperId.VirtualCall; | ||
} | ||
|
||
// The current CoreRT ReadyToRun helpers do not handle null thisptr - ask the JIT to emit explicit null checks | ||
// TODO: Optimize this | ||
pResult.nullInstanceCheck = true; | ||
} | ||
else | ||
{ | ||
// CORINFO_CALL_CODE_POINTER tells the JIT that this is indirect | ||
// call that should not be inlined. | ||
pResult.kind = CORINFO_CALL_KIND.CORINFO_CALL_CODE_POINTER; | ||
// If this is a non-interface/non-GVM call, we actually don't need a runtime lookup to find the target. | ||
// We don't even need to keep track of the runtime-determined method being called because the system ensures | ||
// that if e.g. Foo<__Canon>.GetHashCode is needed and we're generating a dictionary for Foo<string>, | ||
// Foo<string>.GetHashCode is needed too. | ||
if (pResult.exactContextNeedsRuntimeLookup && | ||
!targetMethod.HasInstantiation && | ||
!targetMethod.OwningType.IsInterface) | ||
{ | ||
pResult.exactContextNeedsRuntimeLookup = false; | ||
} | ||
|
||
if (pResult.exactContextNeedsRuntimeLookup) | ||
{ | ||
|
@@ -2716,14 +2726,14 @@ private void getCallInfo(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_RESO | |
} | ||
|
||
pResult.codePointerOrStubLookup.lookupKind.runtimeLookupKind = GetGenericRuntimeLookupKind(contextMethod); | ||
pResult.codePointerOrStubLookup.lookupKind.runtimeLookupFlags = (ushort)ReadyToRunHelperId.VirtualCall; | ||
pResult.codePointerOrStubLookup.lookupKind.runtimeLookupFlags = (ushort)helper; | ||
} | ||
else | ||
{ | ||
pResult.codePointerOrStubLookup.constLookup.accessType = InfoAccessType.IAT_VALUE; | ||
|
||
pResult.codePointerOrStubLookup.constLookup.addr = | ||
(void*)ObjectToHandle(_compilation.NodeFactory.ReadyToRunHelper(ReadyToRunHelperId.VirtualCall, targetMethod)); | ||
(void*)ObjectToHandle(_compilation.NodeFactory.ReadyToRunHelper(helper, targetMethod)); | ||
} | ||
|
||
// The current CoreRT ReadyToRun helpers do not handle null thisptr - ask the JIT to emit explicit null checks | ||
|
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
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.
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.
Put in a comment describing why this shouldn't be here... Something like, the function pointer returned should be the result of the virtual dispatch, not a pointer to the virtual dispatcher.