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

Review long and integer usage conventions

    XMLWordPrintable

Details

    • Enhancement
    • Status: Closed
    • P3
    • Resolution: Fixed
    • 8
    • 8
    • core-libs
    • None
    • b93
    • Verified

    Description

      We should review usage of long in Nashorn code. Most of the code converts to long using toUint32 (probably that was needed specifically for SHR, see NASHORN-670), but not consistently, and there could be code that assumes long values to be in the uint32 range.
      Can we take advantage of longs more than we do now? One thing to be aware of is obviously precision – long is more precise than double.

      Another thing to look at are usages of toInteger/toLong and toInt32/toUint32 and if they are used correctly.-- the former simply do (int)/(long) and more or less corresponds more or less[1] to ECMAScript's ToInteger, the latter return 0 if the value is infinite or NaN.
      [1] In the description of ToInteger it says: "If number is +0, −0, +∞, or −∞, return number." Our toInteger/toLong method returns int/long, Infinity -> MAX_VALUE, -Infinity -> MIN_VALUE, NaN -> 0, -0 -> +0
      We have to check all usages of ToInteger to see if that is ok.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: