-
Notifications
You must be signed in to change notification settings - Fork 18
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
8278322: riscv: Support RVC: compressed instructions #24
Conversation
👋 Welcome back xlinzheng! A progress list of the required criteria for merging this PR into |
I would humbly recommend adding my colleague Wei Kuai([email protected]) as a co-author of this patch, especially including facilitating me to troubleshoot problems that are not easy to address, out of his insightfulness, and also the support of the compression of MachBranchNodes coming afterward, etc. He has done quite a bunch of contributions to this patch. /contributor add Wei Kuai [email protected] |
@zhengxiaolinX |
Why the compressed instructions can not be patched? |
Thank you for your reviews, yadong. For example, if we need to relocate oops to another place, we may emit a |
Well, I don't think it's a good idea for assembler to emit 16-bit compressed instructions by default. Let's say, In this case, I think it should be safe to emit a compressed C.ADD when possible here for this instruct. |
The solution by this PR is hooking the assembler and making all instructions as compressed as possible except 'patchable' instructions, because we must make enough room of immutable constants embedded. Let us call it a "block" list solution. I don't think there's a proper way to ensure the list is complete, and if incomplete, the result may be a wierd exception/crash or unexpected behavior, and it will be difficult to review and debug.
|
Thanks for your reviews, Felix and Yadong, and also thanks for your advice -- also quite sorry for the late reply. I think I totally understand your concerns. Firstly please let me talk about my opinion about this.
I think your suggestions are indeed reasonable in your aspects, for safety. About our first scheme:We may mark some instructions as compressible by adding function arguments. But compressed instructions can be used in almost every place in the code cache, like C1, C2, interpreter, and stub code. The range is quite big -- for instance, after some time we may want to compress some intrinsics, say, After
We might not add extra explicit arguments to them since this may make maintenance quite hard. :-) About our second scheme:Considering the As code function and features begin to complete, we may continue to make code compress further denser afterward. If we want to use this region to include a quite large range of function, of which we think is safe to compress.
Inside the
As the inherent laws of things, the number of So comes
I think finally it may become the solution of this patch (i.e. the blacklist)... :-) I hope this analysis is reasonable and it could bring you some smiles. In that the blacklist must be the core of exclusions, I might recommend focusing on the maintenance of the blacklist, because anyway, we might face the blacklist in the future. To relieve your concerns, maybe making But, to step back, I totally understand your points as well. If you still consider the whitelist scheme might be a good scheme for you, I will choose to use your scheme for now, and add the About splitting the patch:Let's come back to our topic. I have considered from your angle and I begin to realize this design might be quite counterintuitive for guys who always use the normal 4-byte instructions to work; and also because of this 'blacklist' mode, which may cause a burden for reviewers to review. But I believe the primary part (the definitions of C-Ext, like About an ideal but specious solution:In fact, I think the ideal solution might be to use another brand-new pass to handle this compression logic, at the end of C1's
I consider this strategy has other limits except for those above-mentioned ones. So I did not choose this plan. It might be so energy-consuming for me to write so many words in English to explain my reasoning and write analysis in detail. If there are some typos or errors, please don't mind. I wonder if is there a need to arrange a small meeting or not -- we may need to split the patch, discuss friendly about solutions and precautions, and gradually reach a consensus. I think for this patch, we might finally reach that place. Thanks again for your reviews and advice. Sincerely, |
That's exactly what I mean :-)
No. Passing one extra argument here won't affect future code maintainance in anyway here. |
Thanks for your quick response, Felix. In fact, I could not realize the philosophy inside this strategy -- so just one double-check: after this, if we define |
In fact, I am not expecting we catch all the possible places in the backend converting to compressed instructions. |
Based on my last comment, I think we can then further consider the "CompressibleRegion" solution suggested by Yadong. |
Thank you for your explanation, Felix. :-) Seems we finally reach a consensus now.
I think I could get your meaning this time.
Yadong's plan works for me. I am quite in favor of his strategy. I will implement this approach ASAP. Maybe next week I might open another PR including this implementation and the definition of compressed instructions presented in the I am going to close this PR, save it for future reference, and may open another PR and start from scratch. Before that, just one more question: would you mind my keeping definitions of C-Ext instructions into one separate file like |
I am happy that we are agreed on this solution ;-)
Yes, I think |
Totally agree -- |
@zhengxiaolinX I think a seperate file for rvc is a good choice, and maybe we should do the same thing for rvv later. |
Thanks for your suggestion, Yadong. In fact I nearly have the same consideration about this. RISC-V is a modularized ISA with pluggable extensions. Now that extensions will be supported one by one, I think the codebase will inevitably be full of lots of unreadable |
Hi team,
This patch support RISC-V RVC extension. It can introduce:
In my observation, the code size footprint could be reduced to nearly a level of the AArch64 back-end. About the performance, there seems a stable ~0.7% performance improvement on SPECjbb2015 on one HiFive Unleashed board, considering the code density increase. I think the performance aspect might be a speculative behavior on different hardware implementations because C910's performance might be better than that, but HiFive Unleashed may be more general.
Things about this patch:
_nc
postfix of some of Assembler instructions: we know a bunch of places should be reserved for patching, where we cannot change them into compressed instructions._nc
is short fornot compressible
- with this, those instructions should keep their origin 4-byte form and remain uncompressed.The macros after their expansion might be like:
For further information, please see comments in
assembler_riscv_cext.hpp
.--
This patch may need some time to acquire a review. I have been polishing this patch for quite a long time and it might seem stable under a bunch of full-tier tests and some tier1 jdk/hotspot jtreg tests. But I think we might mark it
experimental
at first, though it is turned on by default. The original patch, just for reference, might be quite different from the current one.I am pleased to receive any suggestion.
Thanks,
Xiaolin
Progress
Issue
Contributors
<[email protected]>
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/riscv-port pull/24/head:pull/24
$ git checkout pull/24
Update a local copy of the PR:
$ git checkout pull/24
$ git pull https://git.openjdk.java.net/riscv-port pull/24/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 24
View PR using the GUI difftool:
$ git pr show -t 24
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/riscv-port/pull/24.diff