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

Shigeru Chiba chiba at is.titech.ac.jp
Thu Jul 3 03:56:24 EDT 2008


  User: chiba   
  Date: 08/07/03 03:56:24

  Modified:    src/main/javassist    CtClassType.java CtClass.java
                        CtBehavior.java
  Log:
  fixed a performance bug caused by many calls to CtBehavior#setBody()
  
  Revision  Changes    Path
  1.63      +9 -7      javassist/src/main/javassist/CtClassType.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CtClassType.java
  ===================================================================
  RCS file: /cvsroot/jboss/javassist/src/main/javassist/CtClassType.java,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -b -r1.62 -r1.63
  --- CtClassType.java	20 Oct 2007 16:47:00 -0000	1.62
  +++ CtClassType.java	3 Jul 2008 07:56:24 -0000	1.63
  @@ -60,7 +60,7 @@
       boolean wasChanged;
       private boolean wasFrozen;
       boolean wasPruned;
  -    boolean memberRemoved;
  +    boolean gcConstPool;    // if true, the constant pool entries will be garbage collected. 
       ClassFile classfile;
       byte[] rawClassfile;    // backup storage
   
  @@ -78,7 +78,7 @@
       CtClassType(String name, ClassPool cp) {
           super(name);
           classPool = cp;
  -        wasChanged = wasFrozen = wasPruned = memberRemoved = false;
  +        wasChanged = wasFrozen = wasPruned = gcConstPool = false;
           classfile = null;
           rawClassfile = null;
           memberCache = null;
  @@ -1183,7 +1183,7 @@
           ClassFile cf = getClassFile2();
           if (cf.getFields().remove(fi)) {
               getMembers().remove(f);
  -            memberRemoved = true;
  +            gcConstPool = true;
           }
           else
               throw new NotFoundException(f.toString());
  @@ -1220,7 +1220,7 @@
           ClassFile cf = getClassFile2();
           if (cf.getMethods().remove(mi)) {
               getMembers().remove(m);
  -            memberRemoved = true;
  +            gcConstPool = true;
           }
           else
               throw new NotFoundException(m.toString());
  @@ -1243,7 +1243,7 @@
           ClassFile cf = getClassFile2();
           if (cf.getMethods().remove(mi)) {
               getMembers().remove(m);
  -            memberRemoved = true;
  +            gcConstPool = true;
           }
           else
               throw new NotFoundException(m.toString());
  @@ -1302,6 +1302,8 @@
           getClassFile2().prune();
       }
   
  +    public void rebuildClassFile() { gcConstPool = true; }
  +
       public void toBytecode(DataOutputStream out)
           throws CannotCompileException, IOException
       {
  @@ -1309,9 +1311,9 @@
               if (isModified()) {
                   checkPruned("toBytecode");
                   ClassFile cf = getClassFile2();
  -                if (memberRemoved) {
  +                if (gcConstPool) {
                       cf.compact();
  -                    memberRemoved = false;
  +                    gcConstPool = false;
                   }
   
                   modifyClassConstructor(cf);
  
  
  
  1.99      +16 -1     javassist/src/main/javassist/CtClass.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CtClass.java
  ===================================================================
  RCS file: /cvsroot/jboss/javassist/src/main/javassist/CtClass.java,v
  retrieving revision 1.98
  retrieving revision 1.99
  diff -u -b -r1.98 -r1.99
  --- CtClass.java	13 Jun 2008 10:32:01 -0000	1.98
  +++ CtClass.java	3 Jul 2008 07:56:24 -0000	1.99
  @@ -1155,7 +1155,7 @@
       public boolean stopPruning(boolean stop) { return true; }
   
       /**
  -     * Discards unnecessary attributes, in particuar,
  +     * Discards unnecessary attributes, in particular,
        * <code>CodeAttribute</code>s (method bodies) of the class,
        * to minimize the memory footprint.
        * After calling this method, the class is read only.
  @@ -1192,6 +1192,21 @@
       void incGetCounter() {}
   
       /**
  +     * If this method is called, the class file will be
  +     * rebuilt when it is finally generated by
  +     * <code>toBytecode()</code> and <code>writeFile()</code>.
  +     * For a performance reason, the symbol table of the
  +     * class file may contain unused entries, for example,
  +     * after a method or a filed is deleted.
  +     * This method
  +     * removes those unused entries.  This removal will
  +     * minimize the size of the class file.
  +     *
  +     * @since 3.8.1
  +     */
  +    public void rebuildClassFile() {}
  +
  +    /**
        * Converts this class to a class file.
        * Once this method is called, further modifications are not
        * possible any more.
  
  
  
  1.42      +2 -0      javassist/src/main/javassist/CtBehavior.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CtBehavior.java
  ===================================================================
  RCS file: /cvsroot/jboss/javassist/src/main/javassist/CtBehavior.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -b -r1.41 -r1.42
  --- CtBehavior.java	3 Jun 2008 08:46:36 -0000	1.41
  +++ CtBehavior.java	3 Jul 2008 07:56:24 -0000	1.42
  @@ -362,6 +362,7 @@
               methodInfo.setAccessFlags(methodInfo.getAccessFlags()
                                         & ~AccessFlag.ABSTRACT);
               methodInfo.rebuildStackMapIf6(cc.getClassPool(), cc.getClassFile2());
  +            declaringClass.rebuildClassFile();
           }
           catch (CompileError e) {
               throw new CannotCompileException(e);
  @@ -396,6 +397,7 @@
   
           destInfo.setAccessFlags(destInfo.getAccessFlags()
                                   & ~AccessFlag.ABSTRACT);
  +        destClass.rebuildClassFile();
       }
   
       /**
  
  
  



More information about the jboss-cvs-commits mailing list