Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

[Arm64/Linux] Fix GenericPInvokeCalliHelper #17659

Merged

Conversation

sdmaclea
Copy link

Fixes #17320

@jkotas @adityamandaleeka @janvorli PTAL

//
lsl \HiddenArg, \HiddenArg, #1
orr \HiddenArg, \HiddenArg, #1
.endif
Copy link
Author

Choose a reason for hiding this comment

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

This piece is needed for Windows as well. It also looks like it is needed for arm32. @adityamandaleeka has offered to take care of Windows for me.

Copy link
Author

Choose a reason for hiding this comment

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

Since it is difficult for me to compile for Windows, I much appreciate the offer to do this. The *.asm syntax is different and it would take lots of tries. Thanks @adityamandaleeka

Copy link
Member

Choose a reason for hiding this comment

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

I took a look at the code in dllimport where the corresponding right-shifting is being done. It's under !ARM and !x86. Maybe we can just make it explicitly for AMD64 only and avoid the shifting back and forth on ARM64 too?

Copy link
Author

Choose a reason for hiding this comment

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

The comment in the amd64 pinvoke code is obsolete (refers to a removed feature). It may not needed there either.

Copy link
Member

Choose a reason for hiding this comment

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

Nice 😄. After I sent the last comment, I was trying to find out who exactly is relying on this shifting/setting stuff.

Copy link
Author

Choose a reason for hiding this comment

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

I can't find the right shift code in dllimport.

I do see this.

    // The MethodDesc pointer may in fact be the unmanaged target, see PInvokeStubs.asm.
    if (pMD == NULL || (UINT_PTR)pMD & 0x1)

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

thanks

@@ -98,7 +107,7 @@ PINVOKE_STUB VarargPInvokeStub, VarargPInvokeGenILStub, VarargPInvokeStubWorker,
// x15 = VASigCookie*
// x14 = Unmanaged target
Copy link
Member

Choose a reason for hiding this comment

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

x14->x12

@@ -126,7 +126,7 @@ __PInvokeGenStubFuncName SETS "$__PInvokeGenStubFuncName":CC:"_RetBuffArg"
; x15 = VASigCookie*
; x14 = Unmanaged target
Copy link
Member

Choose a reason for hiding this comment

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

x14->x12

@sdmaclea sdmaclea force-pushed the PR-ARM64-Linux-Fix-GenericPInvokeCalli branch 2 times, most recently from 72001b8 to 091720a Compare April 18, 2018 22:39
;
shl PINVOKE_CALLI_TARGET_REGISTER, 1
or PINVOKE_CALLI_TARGET_REGISTER, 1

Copy link
Author

Choose a reason for hiding this comment

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

This should have been removed when FEATURE_INCLUDE_ALL_INTERFACES was removed in 1476776

//
shl PINVOKE_CALLI_TARGET_REGISTER, 1
or PINVOKE_CALLI_TARGET_REGISTER, 1

Copy link
Author

Choose a reason for hiding this comment

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

This should have been removed when FEATURE_INCLUDE_ALL_INTERFACES was removed in 1476776

}

#endif // _TARGET_X86_

Copy link
Author

Choose a reason for hiding this comment

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

This should have been removed when FEATURE_INCLUDE_ALL_INTERFACES was removed in 1476776

@sdmaclea
Copy link
Author

test Ubuntu arm64 Cross Debug Innerloop Build

@@ -2255,28 +2255,9 @@ void NDirectStubLinker::DoNDirect(ILCodeStream *pcsEmit, DWORD dwStubFlags, Meth

#ifndef CROSSGEN_COMPILE
Copy link
Member

Choose a reason for hiding this comment

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

Nit: #ifndef CROSSGEN_COMPILE can be removed as well, I think.

Copy link
Author

Choose a reason for hiding this comment

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

@jkotas Done

@sdmaclea sdmaclea force-pushed the PR-ARM64-Linux-Fix-GenericPInvokeCalli branch from 091720a to 7ec08b6 Compare April 19, 2018 14:28
@jkotas jkotas merged commit 094a2e8 into dotnet:master Apr 19, 2018
sdmaclea added a commit to sdmaclea/coreclr that referenced this pull request Apr 23, 2018
When _WIN64 is defined vm relies on the secret arg being
shifted left and orred with #1.

Revert part of changes from dotnet#17659 to fix dotnet/corefx#29266

Fix arm64 to match amd64

Simplify dllimport.cpp
sdmaclea added a commit to sdmaclea/coreclr that referenced this pull request Apr 23, 2018
When _WIN64 is defined vm relies on the secret arg being
shifted left and orred with #1.

Revert part of changes from dotnet#17659 to fix dotnet/corefx#29266

Fix arm64 to match amd64

Simplify dllimport.cpp
sdmaclea added a commit to sdmaclea/coreclr that referenced this pull request Apr 23, 2018
When _WIN64 is defined vm relies on the secret arg being
shifted left and orred with #1.

Revert part of changes from dotnet#17659 to fix dotnet/corefx#29266

Fix arm64 to match amd64

Simplify dllimport.cpp
jkotas pushed a commit that referenced this pull request Apr 24, 2018
When _WIN64 is defined vm relies on the secret arg being
shifted left and orred with #1.

Revert part of changes from #17659 to fix dotnet/corefx#29266

Fix arm64 to match amd64

Simplify dllimport.cpp
@sdmaclea sdmaclea deleted the PR-ARM64-Linux-Fix-GenericPInvokeCalli branch May 24, 2018 19:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants