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

NativeArray is inconsistent in using long for length and index in some places and int for the same in other places

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • None
    • core-libs
    • None
    • b96
    • Verified

      I would argue that we should favor ints wherever possible. At the end we do Java array accesses and they only take ints. Even if there is no performance regression a horrible cascade of (int) casts will appear in the code for the long case, making it much harder to read.

      I also assume that there IS performance loss if every access did a[(int)x] instead of a[x]

      ML: Andreas - you were working on fixing this, but we decided, I think to go with mostly ints and treat negative and too large once as special cases of SparseArrayFilter

      AW: I can do a performance assessment later. I agree we should favor long indices, if there is no regression. Otherwise I think it's ok to use ints.

      ML: I would argue that we should favor ints wherever possible. At the end we do Java array accesses and they only take ints. Even if there is no performance regression a horrible cascade of (int) casts will appear in the code for the long case, making it much harder to read.

      I also assume that there IS performance loss if every access did a[(int)x] instead of a[x]

      AW: Yes, there probably is some performance loss (in fact, from my measurements, I think there's a minimal loss already from using longs now where we had used int before). Attached webrev.zip that add long get and set methods to ArrayData. Also ironed out a few glitches here and there. Passes ant test and test262parallel. Unfortunately, I'm getting lower scores on crypto and navier-stokes... :-\

            hannesw Hannes Wallnoefer
            lagergren Marcus Lagergren
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: