(Re)Enable NativeVarargs for CoreCLR#18373
Conversation
a1dcf8c to
ce2fe51
Compare
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.
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.
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.
Ah, makes sense, I was somehow mislead into thinking you were comparing the actual windows and Unix abis.
src/vm/callingconvention.h
Outdated
| PORTABILITY_ASSERT("ArgIteratorTemplate::IsVarArgPassedByRef"); | ||
| return FALSE; | ||
| #else // UNIX_AMD64_ABI | ||
| #else // !UNIX_AMD64_ABI |
There was a problem hiding this comment.
The comment was correct - the convention in the VM is to always use the condition from the #ifdef, not the negation.
| } | ||
| #else | ||
| public ArgIterator(RuntimeArgumentHandle arglist) | ||
| { |
There was a problem hiding this comment.
You should keep this throwing implementation for Unix until/if the varargs are actually implemented for Unix
There was a problem hiding this comment.
Is there a platform specific define that can be used here?
There was a problem hiding this comment.
PLATFORM_UNIX or PLATFORM_WINDOWS
| IfFailThrow(sig.GetCallingConvInfo(&data)); | ||
| sigRet->callConv = (CorInfoCallConv) data; | ||
|
|
||
| if ((isCallConv(sigRet->callConv, IMAGE_CEE_CS_CALLCONV_VARARG)) || |
There was a problem hiding this comment.
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.
Should we keep these tests for Unix?
There was a problem hiding this comment.
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.
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.
Fair point will add them back thank you.
17ec636 to
0dff2d0
Compare
src/vm/jitinterface.cpp
Outdated
| IfFailThrow(sig.GetCallingConvInfo(&data)); | ||
| sigRet->callConv = (CorInfoCallConv) data; | ||
|
|
||
| #ifdef _TARGET_UNIX_ |
There was a problem hiding this comment.
_TARGET_UNIX_ is JIT-specific define. Outside of JIT, we have PLATFORM_UNIX.
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
briansull
left a comment
There was a problem hiding this comment.
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."); |
src/jit/morph.cpp
Outdated
| // such as amd64 Unix, which just expects RAX to pass numFPArguments. | ||
| NYI("Morhing Vararg call not yet implemented on non Windows targets."); | ||
| } | ||
| #endif |
* 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.