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

aarch64: missing side effect of killing flags for clearArray_reg_reg

    XMLWordPrintable

Details

    • b03
    • aarch64
    • generic

    Backports

      Description

            In clearArray_reg_reg, we call function: MacroAssembler::zero words(Register ptr, Register cnt).
            This function modifies the flags register by doing a cmp instruction at entry. But this is not reflected in the side effect of clearArray_reg_reg.
            We didn't see this is triggers problems. But this may pose similar risk as bug: 8224828: aarch64: rflags is not correct after safepoint poll.
            Fix is trivial:

        diff -r 2342d5af52b7 src/hotspot/cpu/aarch64/aarch64.ad
        --- a/src/hotspot/cpu/aarch64/aarch64.ad Mon Jun 22 08:09:23 2020 +0200
        +++ b/src/hotspot/cpu/aarch64/aarch64.ad Mon Jun 22 15:58:05 2020 +0800
        @@ -13845,7 +13845,7 @@
         instruct clearArray_reg_reg(iRegL_R11 cnt, iRegP_R10 base, Universe dummy, rFlagsReg cr)
         %{
           match(Set dummy (ClearArray cnt base));
        - effect(USE_KILL cnt, USE_KILL base);
        + effect(USE_KILL cnt, USE_KILL base, KILL cr);

           ins_cost(4 * INSN_COST);
           format %{ "ClearArray $cnt, $base" %}

        BTW: clearArray_imm_reg does not have the issue since it calls a different function: MacroAssembler::zero_words(Register base, u_int64_t cnt)

        13843 // clearing of an array
        13844
        13845 instruct clearArray_reg_reg(iRegL_R11 cnt, iRegP_R10 base, Universe dummy, rFlagsReg cr)
        13846 %{
        13847 match(Set dummy (ClearArray cnt base));
        13848 effect(USE_KILL cnt, USE_KILL base);
        13849
        13850 ins_cost(4 * INSN_COST);
        13851 format %{ "ClearArray $cnt, $base" %}
        13852
        13853 ins_encode %{
        13854 __ zero_words($base$$Register, $cnt$$Register);
        13855 %}
        13856
        13857 ins_pipe(pipe_class_memory);
        13858 %}

        4771 void MacroAssembler::zero_words(Register ptr, Register cnt)
        4772 {
        4773 assert(is_power_of_2(zero_words_block_size), "adjust this");
        4774 assert(ptr == r10 && cnt == r11, "mismatch in register usage");
        4775
        4776 BLOCK_COMMENT("zero_words {");
        4777 cmp(cnt, (u1)zero_words_block_size); <=================

        Attachments

          Issue Links

            Activity

              People

                fyang Fei Yang
                fyang Fei Yang
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: