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

RISC-V: Fix potential crash in C2_MacroAssembler::arrays_equals

XMLWordPrintable

    • b16
    • riscv
    • linux

      Hi, The current behavior of C2_MacroAssembler::arrays_equals always load longword before comparison.
      When array[0] is aligned to 32-bit (especially after JDK-8139457 which tries to relax alignment
      of array elements), the last longword load will exceed the array limit and may touch the next
      word beyond object layout in heap memory. So this should bear a similar problem as JDK-8328138.

      Proposed fix changes this behavior and aligns with handling in C2_MacroAssembler::string_equals,
      which will check the number of remaining array elements before loading the next longword.
      No obvious changes witnessed from the JMH numbers or benchmarks like SPECjbb2015.

      Patch also removed the AvoidUnalignedAccesses check in C2_MacroAssembler::string_equals as we
      don't see extra performance gain when setting AvoidUnalignedAccesses to false when testing the
      JMH tests or benchmarks like SPECjbb2015 on three popular RISC-V hardware platforms. We can
      consider adding it back if it turns out to be usefull on future new hardwares.

            gcao Gui Cao
            gcao Gui Cao
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: