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

(porting) suggested improvements to make VM easier to port (2's compliment)

XMLWordPrintable

    • 1.2
    • generic
    • solaris_2.5.1

      Licensee made a minimal effort to produce source that is more portable.
      In several cases, however, the effort to do so was too large and the change will
      only work on licensee platform. In other cases, licensee kept the code in the
      shared directory instead of moving it into the platform specific directory.
      Obviously these changes will need much more work before they can be released.

      In the following patch listing, "L" refers to the left path which is original
      file from JavaSoft and "R" refers to the right path which is our modified file.
      At the end of each "---------" line is "2's complement", see below for
      explanation.

      Portability, "Two's Complement" explanation:
      --------------------------------------------
      There are several places that fetch two or more characters as a signed integer.
      They assume that the native representation of integers is 2's complement. For
      2's complement, fetching the first byte as a signed value, shifting it, and
      ORing in the other bytes works. On the ClearPath HMP NX (A Series) platform,
      the native representation for integers is signed-magnitude. That is, a separate
      sign bit and the value is always represented as a non-negative integer. To
      convert two or more characters to a signed integer, all characters must be
      fetched, shifted (as unsigned values) and ORed together. Then we can convert
      them from unsigned to signed. (For the geekheads, we add 2**(bits-1), AND
      (2**bits)-1, and then subtract 2**(bits-1)).

      Specific examples follow:

      Comparison of J:\JAE1_2T\src\share\javavm\runtime\EXECUTEJAVA.C and
      J:\PC\SHARE\javavm\runtime\EXECUTEJAVA.C
      Version 1.62

      ----------------------------------------------------- 2's complement
      L164 #define pc2signedshort(pc) ((((signed char *)(pc))[1] << 8) | pc[2])
      L165 #define pc2signedlong(pc) ((((signed char *)(pc))[1] << 24) | (pc[2]
      << 16) | (pc[3] << 8) | (pc[4]))

      R164 #define pc2signedshort(pc) /* srb */ (((((pc)[1] << 8 | (pc)[2]) +
      0x8000 ) & 0xFFFF ) - 0x8000 )
      R165 #define pc2signedlong(pc) /* srb */ (((((pc)[1] << 24 | (pc)[2] << 16 |
      (pc)[3] << 8 | (pc)[4]) + 0x80000000) & 0xFFFFFFFF) - 0x80000000)

      ----------------------------------------------------- 2's complement
      L1735 offset = (((signed char *)pc)[4] << 8) + pc[5];

      R1735 offset = pc2signedshort(pc+3); /* srb */

            duke J. Duke
            jbenoit Jonathan Benoit (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: