[riscv-port] RFR: 8278322: riscv: Support RVC: compressed instructions

Yadong Wang yadongwang at openjdk.java.net
Wed Dec 8 07:32:32 UTC 2021


On Tue, 7 Dec 2021 09:24:22 GMT, Xiaolin Zheng <xlinzheng at openjdk.org> wrote:

> > > About the _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 for not compressible - with this, those instructions should keep their origin 4-byte form and remain uncompressed.
> >
> >
> > 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 `movptr`, whose length is fixed, including `lui+addi+slli+addi+slli+addi`. For instructions like `addi`s, if we compress them to a 16-byte form, we will face troubles when we want to relocate them to another place since the new address may not be presented by simple `c.addi`s -- because `c.addi` could only present [-32, +31] but `addi` could present [-2048, +2047]. With this respect, it may be a good choice to remain their original forms for the patchable places, though quite conservative.

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.
How about we make a "**white**" list to compressed instruction generation. You can make a compressed region where you think it's safe to do so,for example:


{
CompressRegion cr;
__ addi(rd, rd, 1);
}

-------------

PR: https://git.openjdk.java.net/riscv-port/pull/24



More information about the riscv-port-dev mailing list