-
Notifications
You must be signed in to change notification settings - Fork 2.7k
(Re)Enable NativeVarargs for CoreCLR #18373
Conversation
a1dcf8c
to
ce2fe51
Compare
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.
LGTM
ce2fe51
to
eaa9b20
Compare
#ifdef _TARGET_UNIX_ | ||
// Currently native varargs is not implemented on non windows targets. | ||
// | ||
// Note that some targets like Arm64 Unix should not need much work as |
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.
The ABI is not the same for ARM64 Unix - we've discussed it together some time ago. And with Amd64, things are even more complex on unix - the variable args can be passed in registers, the va_list is a special structure containing the indices of the gen purpose / fp registers, etc.
Am I missing something?
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.
The comment is addressing code generation. For arm64 unix the ABI for varargs is not different from the regular calling convention.
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.
Ah, makes sense, I was somehow mislead into thinking you were comparing the actual windows and Unix abis.
src/vm/callingconvention.h
Outdated
return FALSE; | ||
#else // UNIX_AMD64_ABI | ||
#else // !UNIX_AMD64_ABI |
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.
The comment was correct - the convention in the VM is to always use the condition from the #ifdef, not the negation.
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.
Ok will address.
@@ -132,54 +131,5 @@ public override bool Equals(Object o) | |||
{ | |||
throw new NotSupportedException(SR.NotSupported_NYI); | |||
} | |||
#else | |||
public ArgIterator(RuntimeArgumentHandle arglist) | |||
{ |
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.
You should keep this throwing implementation for Unix until/if the varargs are actually implemented for Unix
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.
Is there a platform specific define that can be used here?
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.
PLATFORM_UNIX
or PLATFORM_WINDOWS
src/vm/jitinterface.cpp
Outdated
@@ -489,13 +489,6 @@ CEEInfo::ConvToJitSig( | |||
IfFailThrow(sig.GetCallingConvInfo(&data)); | |||
sigRet->callConv = (CorInfoCallConv) data; | |||
|
|||
if ((isCallConv(sigRet->callConv, IMAGE_CEE_CS_CALLCONV_VARARG)) || |
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.
We should continue throwing here for unix
d1974c4
to
17ec636
Compare
@@ -1,114 +0,0 @@ | |||
// Licensed to the .NET Foundation under one or more agreements. |
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.
Should we keep these tests for Unix?
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.
Personally I do not see the value of the test and conditionally excluding it by platform will be more work to undo later. If there are strong opinions to keep them then I can add them back.
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.
This test would have caught the wrong ifdef that I have commented on...
Are we going to implement varargs support on Unix for next release? If yes, I do not have a problem with deleting these tests now. If not, we should keep them.
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.
Fair point will add them back thank you.
17ec636
to
0dff2d0
Compare
src/vm/jitinterface.cpp
Outdated
@@ -489,12 +489,14 @@ CEEInfo::ConvToJitSig( | |||
IfFailThrow(sig.GetCallingConvInfo(&data)); | |||
sigRet->callConv = (CorInfoCallConv) data; | |||
|
|||
#ifdef _TARGET_UNIX_ |
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.
_TARGET_UNIX_
is JIT-specific define. Outside of JIT, we have PLATFORM_UNIX
.
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.
Thank you for catching this.
This will allow coreclr run programs which have native varargs. It also re-enables the ArgIterator type for managed to managed native vararg calls. This will allow the use of the __arglist keyword. Limitations: NYI statements have been added for all Unix Targets. With this change __arglist (native varargs) will be supported, but not yet tested on: Amd64 Windows x86 Windows Arm32 Windows Arm64 Windows This change does not re-enable native vararg tests. This will be done in a seperate change.
0dff2d0
to
890cd77
Compare
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.
Looks Good
( with minor comments )
src/jit/morph.cpp
Outdated
// Note that some targets like Arm64 Unix should not need much work as | ||
// the ABI is the same. While other targets may only need small changes | ||
// such as amd64 Unix, which just expects RAX to pass numFPArguments. | ||
NYI("Morhing Vararg call not yet implemented on non Windows targets."); |
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.
Spelling: Morhing => Morphing
src/jit/morph.cpp
Outdated
// the ABI is the same. While other targets may only need small changes | ||
// such as amd64 Unix, which just expects RAX to pass numFPArguments. | ||
NYI("Morhing Vararg call not yet implemented on non Windows targets."); | ||
} | ||
#endif |
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.
// TARGET_UNIX
* Enable NativeVarargs for CoreCLR This will allow coreclr run programs which have native varargs. It also re-enables the ArgIterator type for managed to managed native vararg calls. This will allow the use of the __arglist keyword. Limitations: NYI statements have been added for all Unix Targets. With this change __arglist (native varargs) will be supported, but not yet tested on: Amd64 Windows x86 Windows Arm32 Windows Arm64 Windows This change does not re-enable native vararg tests. This will be done in a separate change. Commit migrated from dotnet/coreclr@e600470
This will allow coreclr run programs which have native varargs.
It also re-enables the ArgIterator type for managed to managed native
vararg calls which will allow the use of the __arglist keyword.
This change also deletes a test which expects an invalid program exception
for native varargs usage.
Limitations:
NYI statements have been added for all Unix Targets.
With this change __arglist (native varargs) will be supported, but not
yet tested on:
This change does not address re-enablabling native vararg tests. This will be done
in a seperate change.
See #18377 for on initial thoughts on varargs bringup on
unix platforms.