-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Address APX requirements for GC and VM stubs #112587
Comments
Also, are there any similar requirements with |
@dotnet/avx512-contrib @jkotas @janvorli @MichalStrehovsky is this something you can help me gain some clarity on? |
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
It looks like gc info encoding/decoding is resilient to variable number of registers (other platforms that use the common gc info encoder have different numbers of registers). You will probably find cases like runtime/src/coreclr/gcinfo/gcinfoencoder.cpp Line 967 in 09c5809
|
Thanks helpful thanks Bruce. Looks to have some encoding from the JIT here: https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/gcencode.cpp#L4639-L4661 I will have to dig more to understand the decode side during GC. |
Yes, and note that the JIT register numbers are assumed to be equivalent to the register numbers used by the VM. |
This code is here: runtime/src/coreclr/vm/gcinfodecoder.cpp Lines 1682 to 1715 in 8d06783
You will also need to expand the context tracking structures. You can use Arm64 handling or X0-X17 registers as a blue-print: runtime/src/coreclr/inc/regdisp.h Line 173 in 8d06783
An alternative to doing all this work would be avoid storing GC tracked references in these registers. SIMD registers are on a plan like that. I assume that you do not want to do this - just mentioning this option for completeness. |
fyi, the x64 runtime/src/coreclr/vm/gcinfodecoder.cpp Lines 1424 to 1443 in 8d06783
That's possibly a reasonable short-term solution if necessary, but it's likely we want to treat the eGPR as equivalent to the current GPR in all ways, long-term. |
Thank you for the information @jkotas . I see what would need to be updated. As part of my digging, I came across https://github.com/dotnet/runtime/blob/main/src/coreclr/vm/amd64/Context.asm#L19-L46 I am slightly confused by the naming as I ask because, if the EGPRs would also need to be restored in these kinds of stubs, we may need an windows assembler with APX support. |
This method is used to jump to catch funclets among other things. The catch funclets take arguments in rcx and rdx (https://github.com/dotnet/runtime/blob/main/docs/design/coreclr/botr/clr-abi.md#the-pspsym-and-funclet-parameters). That's why this method restores these two extra volatile registers. I agree that the naming is confusing. Could you please add some comments to the code for next person wondering about this? |
Done: #112758. I have been looking to see if there are any stubs or code that would need to be updated regarding pinvoke: it's possible that an invoked function could trash the extended registers (which are volatile). Is it up to the invoking function of a pinvoke call to handle this as part of the codegen? |
Right, nothing special here. Same rules as method calls in regular C/C++. |
Thanks @jkotas . This was very helpful. @BruceForstall going to suggest to keep the issue open as it will track these changes we have to make for APX (I can see its already listed as a work item on our main APX issue). |
@anthonycanino, please feel free to reassign. |
There are a number of asm stubs in some of the GC, PInvoke, and NativeAOT code.
I'm working to establish if APX extended GPRs (EGPRS) need to be added to some of the state saving --- for what I currently see, most of the registers that are manipulated in some of this code,
src/coreclr/nativeaot/Runtime/amd64/PInvoke.asm
andsrc/coreclr/nativeaot/Runtime/amd64/GcProbe.asm
only need to address non-volatile registers --- all of the EGPRs are volatile.My question is, is there any other asm points in the code, perhaps on gc transitions etc., where register state may need to be explictly saved for Windows? I am aware most of the state saving is done with xsave, but looking to make sure all dependencies are handled.
The text was updated successfully, but these errors were encountered: