-
Notifications
You must be signed in to change notification settings - Fork 721
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
Preserve vector registers across JIT helpers on Power #11752
Comments
A few basic questions to begin:
I will need to save argument FPRs in certain cases (method resolve) for decompile even when VRs are saved (I don't want to deal with differing locations for the FPR values in the decompiler).
My initial feeling is that it would not be worth the effort.
|
There are 64 128-bit vector registers. They are numbered from
|
So that brings up the next questions:
Are the instructions available in our assemblers for all P platforms?
|
There are 64 VSRs, each is currently 16 bytes, and no strict alignment required but, of course, preferring 16 alignment for performance and easier access purposes.
Yes, FPRs overlap with upper-left quarter of VSRs. i.e. fpr0 overlapping with the top-half of vsr0, fpr1 with the top-half of vsr1, so on so forth. VMX/Altivec VRs (32 of them) overlap with the last portion of VSRs, i.e. v0 overlapping with vsr32, v1 with vsr33, ...., and v31 with vsr63.
That is a reasonable thing to do. I have a little concern for the performance of frequently-called helpers with this blindly saving/restoring all 64 VSRs (1KB in total), such as interface method look-up. |
Interface lookup is also at a method invocation point, so I believe there could be no live VRs at that point. It's probably not difficult to split the helpers into those that require VR treatment and those that don't. |
lxvd2x or lxvw4x can be used to restore all of them, while corresponding stxvd2x or stxvw4x can be used to save all of them.
No. power7 needs to be specified to have those assembly instructions. such as, . machine power7 pseudo op or something like that.
vsr52 - vsr63 are preserved in the ABI. Entering interpreter (from JIT) doesn't need to save/restore VSRs just like FPRs. For C stack unwinding purpose, the saving area in C stack is the traditional location at the higher-end of the frame. |
That would be good to do. |
starting POWER10, there are better instructions to save/restore them (immediate offset form, instead of index form), but it is a long shot in the future for us to drop POWER7/POWER8/POWER9. |
The preserved VR/VSR(s) are saved next (lower address) to the preserved GPRs ... as shown above. |
Can someone please point me to some doc for the vector instructions? |
https://openpowerfoundation.org/?resource_lib=power-isa-version-3-0 3.0 corresponding to POWER9 ... look for lxvd2x and stxvd2x |
those two instructions existed starting on POWER7, by the way. |
I've read the doc, and it's typically confusing - can you provide examples of the instruction use? It seems to imply that I have to have a register preloaded with the constant 4. To store multiple registers sequentially, do I need to keep adding 16 to the base register? |
Sorry, I was reading the doc for the 4x forms. The 2x ones seem more sane, though it's a shame there's no constant offset form. |
Would this be how I load vector registers 0 and 1 from consecutive storage?
|
both will work. |
Track my changes here: https://github.com/gacholio/openj9/tree/vector I won't promise it will always compile/work. So far, I've modified the outer (JIT execution) native stack frame, and saved/restored the required VRs upon entry/exit from the interpreter. |
@gita-omr Latest code in the branch should be preserving VRs across the helper calls now. It's unoptimized and untested (everything compiles and works when the vector enable bit is not set). |
Thanks! |
I believe there's an overlap in the code in saving/restoring VSR and FPR registers. The instructions |
This code is not optimized - for some of the helpers, I require the FPRs to be stored even when VRs are in use. The restore code restores the FPRs first, then the VRs if need be, so all of the values should be correctly preserved - this code could certainly be modified to do one or the other instead of both. |
@knn-k FYI |
Optionally preserve the vector registers in the assembly helpers on Power. This is controlled by the J9_EXTENDED_RUNTIME_USE_VECTOR_REGISTERS bit in the J9JavaVM extendedRuntimeFlags field. Fixes: eclipse-openj9#11752 [ci skip] Signed-off-by: Graham Chapman <graham_chapman@ca.ibm.com>
Optionally preserve the vector registers in the assembly helpers on Power. This is controlled by the J9_EXTENDED_RUNTIME_USE_VECTOR_REGISTERS bit in the J9JavaVM extendedRuntimeFlags field. Fixes: eclipse-openj9#11752 [ci skip] Signed-off-by: Graham Chapman <graham_chapman@ca.ibm.com>
Reopening for 32-bit support. |
32-bit support will be added at a later date if we deem it necessary. |
The JIT helper contract is that all registers are preserved/updated with the exception of a possible return value. Once the Power JIT starts using vector registers, the helpers must preserve them.
The text was updated successfully, but these errors were encountered: