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

place alignment code in platform specific files instead of in the shared files

XMLWordPrintable

    • 1.2beta3
    • generic
    • generic
    • Not verified

      I did run into a few problems where the code is not as portable as it could be.
      Mostly, it assumes that the hardware is the same as the java virtual machine,
      that is that words are 4 bytes long. On our machine, words are 6 bytes! So
      code that aligns pointers by adding 3 and masking out the least significant 2
      bits does not work.

      They are easily fixed by putting the alignment code in the platform
      specific files instead of in the shared files. They are bugs in the sense
      that these are limitations on what platforms can run the code without
      changes. To get javah to run, I had to patch these shared files:

      1) In src/share/javavm/runtime/utf8pool.c,
                 version @(#)utf8pool.c 1.8 97/06/09, the lines:

      #define UTF8PoolAlignment 4
      ...
      UTF8PoolEntry* UTF8PoolAllocate(UTF8Pool* utf8pool, size_t
      length) {
      ...
      (length + UTF8PoolAlignment - 1) &~ (UTF8PoolAlignment
      - 1);
      ...
      static UTF8PoolEntry* UTF8PoolFindFree(UTF8Pool* utf8pool,
      size_t length) {
      ...
      (length + UTF8PoolAlignment - 1) &~ (UTF8PoolAlignment
      - 1);

      should be in a platform specific file since 4 may be 6 or even
              8. If 6, then masking out the least significant bits does not work.




      2) In the same source file, src/share/javavm/runtime/utf8pool.c,
                 version @(#)utf8pool.c 1.8 97/06/09, the line:

      static int UTF8PoolHashCode(const char* data, size_t length) {
      ...
      result = (31 * result) + data[offset];

      assumes that overflow is silently ignored. That is not the case
              on our machine.



      3) In src/share/javavm/runtime/classload.c,
                 version @(#)classload.c 1.131 97/06/09, the line:

      #define ROUNDUP_SIZE(s) while ((s) % 8 != 0) (s)++

      should be in a platform specific file since the maximum
              alignment in machine specific.



      4) In src/share/javavm/runtime/classresolver.c,
                 version @(#)classresolver.c 1.106 97/06/09, the lines:

      PrepareMethods(ClassClass *cb) {
      ...
      ptr = sysMalloc(sizeof(struct methodtable)

      + (mslot - 1)* sizeof(struct methodblock *)

      + FLAG_MASK);

      ...
      new_table = (struct methodtable *)((((long)ptr) +
      FLAG_MASK) & LENGTH_MASK);


      should be in a platform specific file since FLAG_MASK and
              LENGTH_MASK is attempting to ensure the two least significant
              bits are 0 and this code does not work on our machine with 6
              bytes per word.

            sliangsunw Sheng Liang (Inactive)
            jbenoit Jonathan Benoit (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: