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

(porting) sizearray() - portability improvements to make VM easier to port

XMLWordPrintable

    • generic
    • generic

      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 Power of 2, see below for explanation.


      Original code porting problem reported as:
      ----------------------------------------------------- Power of 2
      L1416 return l << ((t == T_CLASS) ? OBJECT_SIZE_SHIFT : T_SIZEFIELD(t));

      R1428 return l * ((t == T_CLASS) ? OBJECT_SIZE_FACTOR /* srb */
      R1429 : T_ELEMENT_SIZE(t)); /* srb */



      It is in gc.c inside sizearray(), the patched code is:

      1360c1356
      < return ((t == T_CLASS) ? l * sizeof(JHandle*) : l <<
      T_SIZEFIELD(t));
      ---
      > return l << ((t == T_CLASS) ? OBJECT_SIZE_SHIFT :
      T_SIZEFIELD(t));

      This fixed the case where 't' is 'T_CLASS'. But where 't' is not
      'T_CLASS', then code still does a shift of the element count 'l' by the
      T_SIZEFIELD to get the array size. That works on most machines where
      the size of primitive types are 1, 2, 4, and 8 (all powers of 2) but not
      on our machine where the sizes are 1, 6, and 12. On our machine we have
      to multiply 'l' by the 1, 6, or 12, which are gotten from indexing an
      array by 't'.

            collins Gary Collins (Inactive)
            jbenoit Jonathan Benoit (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: