Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8305690

[X86] Do not emit two REX prefixes in Assembler::prefix

XMLWordPrintable

    • b19

        Currently, the method `Assembler::prefix`, shown below, may emit two REX prefixes when the `adr` needs `REX_B` and `dst` needs `REX_R`. It seems this code path is not invoked by any caller, so the bug is not exposed now.

        ```
        void Assembler::prefix(Register dst, Address adr, Prefix p) {
          if (adr.base_needs_rex()) {
            if (adr.index_needs_rex()) {
              assert(false, "prefix(Register dst, Address adr, Prefix p) does not support handling of an X");
            } else {
              prefix(REX_B); // <-- here
            }
          } else {
            if (adr.index_needs_rex()) {
              assert(false, "prefix(Register dst, Address adr, Prefix p) does not support handling of an X");
            }
          }
          if (dst->encoding() >= 8) {
            p = (Prefix)(p | REX_R);
          }
          if (p != Prefix_EMPTY) {
            // do not generate an empty prefix
            prefix(p);
          }
        }
        ```

              gli Guoxiong Li
              gli Guoxiong Li
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: