Skip to content
This repository has been archived by the owner on Mar 15, 2022. It is now read-only.

Implement translation of jmp msil instruction. #725

Merged
merged 1 commit into from
Jul 31, 2015

Conversation

erozenfeld
Copy link
Member

jmp is implemented as a call marked with musttail followed by a ret.

If the caller has a secret parameter we need to pass it to the jmp call
because the signature and the calling convention of the caller and
the musttail call must match. To accommodate that a parallel
LLVM change modifies CLR_SecretParameter calling convention
to make the secret parameter the first pointer-sized parameter
(still passed in R10) rather than a parameter passed with a
"CLR_SecretParameter" attribute.

All indirect parameters are passed as they come to the caller, without
copying them to the current frame.

Indirect result parameter is typed as a managed pointer in a jmp call
because we type indirect result parameter for the caller as a
managed pointer.

Closes #192.

jmp is implemented as a call marked with musttail followed by a ret.

If the caller has a secret parameter we need to pass it to the jmp call
because the signature and the calling convention of the caller and
the musttail call must match. To accommodate that a parallel
LLVM change modifies CLR_SecretParameter calling convention
to make the secret parameter the first pointer-sized parameter
(still passed in R10) rather than a parameter passed with a
"CLR_SecretParameter" attribute.

All indirect parameters are passed as they come to the caller, without
copying them to the current frame.

Indirect result parameter is typed as a managed pointer in a jmp call
because we type indirect result parameter for the caller as a
managed pointer.

Closes dotnet#192.
@erozenfeld
Copy link
Member Author

@pgavlin PTAL

@@ -312,7 +312,7 @@ CallSite ABICallSignature::emitUnmanagedCall(GenIR &Reader, Value *Target,

Value *ABICallSignature::emitCall(GenIR &Reader, Value *Target, bool MayThrow,
ArrayRef<Value *> Args,
Value *IndirectionCell,
Value *IndirectionCell, bool IsJmp,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that it looks like we'll need to do most (all?) of the transformations that are conditional on this parameter for tail calls as well, I wonder if it wouldn't be better to split this into bool IsTailCall, bool MustTailCall (or bool IsTailCall, bool IsJmp). Or maybe even something like:

enum CallKind
{
    Normal = 0,
    TailCall = 1,
    MustTailCall =2
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jmp is different from tail.call. For example, tail.call doesn't have to have the same signature as the caller so we don't have to pass a secret parameter. I would rather keep this as IsJmp for now to make it clear that this code has only been implemented and tested for jmp. When we get to tail calls we will probably do something like what you suggested.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, that seems fine. You're right about the restrictions--I had misread the lang ref.

@pgavlin
Copy link
Contributor

pgavlin commented Jul 31, 2015

LGTM.

@erozenfeld
Copy link
Member Author

llilc test failures are expected until corresponding llvm changes are in.

erozenfeld added a commit that referenced this pull request Jul 31, 2015
Implement translation of jmp msil instruction.
@erozenfeld erozenfeld merged commit 2111f50 into dotnet:master Jul 31, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants