[jboss-cvs] javassist/src/main/javassist/bytecode ...

Shigeru Chiba chiba at is.titech.ac.jp
Thu Mar 26 07:51:07 EDT 2009


  User: chiba   
  Date: 09/03/26 07:51:07

  Modified:    src/main/javassist/bytecode  CodeIterator.java
  Log:
  the previous revision was wrong again.  this should be a right fix for JASSIST-74
  
  Revision  Changes    Path
  1.19      +24 -10    javassist/src/main/javassist/bytecode/CodeIterator.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CodeIterator.java
  ===================================================================
  RCS file: /cvsroot/jboss/javassist/src/main/javassist/bytecode/CodeIterator.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -b -r1.18 -r1.19
  --- CodeIterator.java	18 Mar 2009 12:49:41 -0000	1.18
  +++ CodeIterator.java	26 Mar 2009 11:51:07 -0000	1.19
  @@ -716,15 +716,14 @@
                   if (i != j && (gapLength & 3) != 0)
                       throw new AlignmentException();
   
  -                int i0 = i;
                   int i2 = (i & ~3) + 4;  // 0-3 byte padding
                   // IBM JVM 1.4.2 cannot run the following code:
  +                // int i0 = i;
                   // while (i0 < i2)
                   //    newcode[j++] = code[i0++];
  +                // So extracting this code into an external method.
                   // see JIRA JASSIST-74.
  -                newcode[j++] = (byte)TABLESWITCH;
  -                while (++i0 < i2)
  -                    newcode[j++] = 0;
  +                j = copyGapBytes(newcode, j, code, i, i2);
   
                   int defaultbyte = newOffset(i, ByteArray.read32bit(code, i2),
                                               where, gapLength, exclusive);
  @@ -734,7 +733,7 @@
                   int highbyte = ByteArray.read32bit(code, i2 + 8);
                   ByteArray.write32bit(highbyte, newcode, j + 8);
                   j += 12;
  -                i0 = i2 + 12;
  +                int i0 = i2 + 12;
                   i2 = i0 + (highbyte - lowbyte + 1) * 4;
                   while (i0 < i2) {
                       int offset = newOffset(i, ByteArray.read32bit(code, i0),
  @@ -748,16 +747,15 @@
                   if (i != j && (gapLength & 3) != 0)
                       throw new AlignmentException();
   
  -                int i0 = i;
                   int i2 = (i & ~3) + 4;  // 0-3 byte padding
   
                   // IBM JVM 1.4.2 cannot run the following code:
  +                // int i0 = i;
                   // while (i0 < i2)
                   //    newcode[j++] = code[i0++];
  +                // So extracting this code into an external method.
                   // see JIRA JASSIST-74.
  -                newcode[j++] = (byte)LOOKUPSWITCH;
  -                while (++i0 < i2)
  -                    newcode[j++] = 0;
  +                j = copyGapBytes(newcode, j, code, i, i2);
   
                   int defaultbyte = newOffset(i, ByteArray.read32bit(code, i2),
                                               where, gapLength, exclusive);
  @@ -765,7 +763,7 @@
                   int npairs = ByteArray.read32bit(code, i2 + 4);
                   ByteArray.write32bit(npairs, newcode, j + 4);
                   j += 8;
  -                i0 = i2 + 8;
  +                int i0 = i2 + 8;
                   i2 = i0 + npairs * 8;
                   while (i0 < i2) {
                       ByteArray.copy32bit(code, i0, newcode, j);
  @@ -783,6 +781,22 @@
               }
       }
   
  +    private static int copyGapBytes(byte[] newcode, int j, byte[] code, int i, int iEnd) {
  +        switch (iEnd - i) {
  +        case 4:
  +            newcode[j++] = code[i++];
  +        case 3:
  +            newcode[j++] = code[i++];
  +        case 2:
  +            newcode[j++] = code[i++];
  +        case 1:
  +            newcode[j++] = code[i++];
  +        default:
  +        }
  +
  +        return j;
  +    }
  +
       private static int newOffset(int i, int offset, int where,
                                    int gapLength, boolean exclusive) {
           int target = i + offset;
  
  
  



More information about the jboss-cvs-commits mailing list