harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r634333 - /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java
Date Thu, 06 Mar 2008 16:20:23 GMT
Author: sjanuary
Date: Thu Mar  6 08:20:22 2008
New Revision: 634333

URL: http://svn.apache.org/viewvc?rev=634333&view=rev
Log:
Apply patch for HARMONY-5575 ([classlib][pack200] Pack200 is slow adding to classpool)

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java?rev=634333&r1=634332&r2=634333&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/ClassConstantPool.java
Thu Mar  6 08:20:22 2008
@@ -43,67 +43,72 @@
 
 //    protected SortedSet sortedEntries = new TreeSet(new PoolComparator());
     protected ClassPoolSet classPoolSet = new ClassPoolSet();
-	public String toString() {
-		return entries.toString();
-	}
-	private List others = new ArrayList();
-
-	private List entries = new ArrayList();
-
-	private boolean resolved;
-
-	public ClassFileEntry add(ClassFileEntry entry) {
-		// We don't want duplicates.
-		// Only add in constant pools, but resolve all types since they may
-		// introduce new constant pool entries
+    public String toString() {
+        return entries.toString();
+    }
+    private List others = new ArrayList();
+
+    private List entries = new ArrayList();
+
+    private boolean resolved;
+
+    public ClassFileEntry add(ClassFileEntry entry) {
+        // We don't want duplicates.
+        // Only add in constant pools, but resolve all types since they may
+        // introduce new constant pool entries
 // This is a handy way to see what's adding a ClassFileEntry - set a breakpoint on the print
-//	    if(entry instanceof CPFieldRef) {
-//	        SegmentUtils.debug("AAH:" + ((CPFieldRef)entry).comparisonString());
-//	        if (((CPUTF8)entry).underlyingString().matches("Code")) {
-//	            SegmentUtils.debug("Adding");
-//	        }
-//	    }
-		if (entry instanceof ConstantPoolEntry) {
-            classPoolSet.add(entry);
-			if (!entries.contains(entry)) {
-				entries.add(entry);
-				if (entry instanceof CPLong ||entry instanceof CPDouble)
-					entries.add(entry); //these get 2 slots because of their size
-			}
-		} else {
-			if (!others.contains(entry))
-				others.add(entry);
-		}
-		ClassFileEntry[] nestedEntries = entry.getNestedClassFileEntries();
-		for (int i = 0; i < nestedEntries.length; i++) {
-			add(nestedEntries[i]);
-		}
-		return entry;
-	}
-
-	public int indexOf(ClassFileEntry entry) {
-		if (!resolved)
-			throw new IllegalStateException("Constant pool is not yet resolved; this does not make
any sense");
-		int entryIndex = entries.indexOf(entry);
-		// If the entry isn't found, answer -1. Otherwise answer the entry.
-		if(entryIndex != -1) {
-		    return entryIndex + 1;
-		}
-		return -1;
-	}
-
-	public int size() {
-		return entries.size();
-	}
-
-	public ClassFileEntry get(int i) {
-		if (!resolved)
-			throw new IllegalStateException("Constant pool is not yet resolved; this does not make
any sense");
-		return (ClassFileEntry) entries.get(--i);
-	}
+//      if(entry instanceof CPFieldRef) {
+//          SegmentUtils.debug("AAH:" + ((CPFieldRef)entry).comparisonString());
+//          if (((CPUTF8)entry).underlyingString().matches("Code")) {
+//              SegmentUtils.debug("Adding");
+//          }
+//      }
+        if (entry instanceof ConstantPoolEntry) {
+//            classPoolSet.add(entry);
+            if (!entries.contains(entry)) {
+                entries.add(entry);
+                if (entry instanceof CPLong ||entry instanceof CPDouble)
+                    entries.add(entry); //these get 2 slots because of their size
+            }
+        } else {
+            if (!others.contains(entry))
+                others.add(entry);
+        }
+        ClassFileEntry[] nestedEntries = entry.getNestedClassFileEntries();
+        for (int i = 0; i < nestedEntries.length; i++) {
+            add(nestedEntries[i]);
+        }
+        return entry;
+    }
 
-	public void resolve(Segment segment) {
-	    entries = new ArrayList();
+    public int indexOf(ClassFileEntry entry) {
+        if (!resolved)
+            throw new IllegalStateException("Constant pool is not yet resolved; this does
not make any sense");
+        int entryIndex = entries.indexOf(entry);
+        // If the entry isn't found, answer -1. Otherwise answer the entry.
+        if(entryIndex != -1) {
+            return entryIndex + 1;
+        }
+        return -1;
+    }
+
+    public int size() {
+        return entries.size();
+    }
+
+    public ClassFileEntry get(int i) {
+        if (!resolved)
+            throw new IllegalStateException("Constant pool is not yet resolved; this does
not make any sense");
+        return (ClassFileEntry) entries.get(--i);
+    }
+
+    public void resolve(Segment segment) {
+        classPoolSet = new ClassPoolSet();
+        Iterator it = entries.iterator();
+        while(it.hasNext()) {
+            classPoolSet.add((ClassFileEntry)it.next());
+        }
+        entries = new ArrayList();
       Iterator sortedIterator = classPoolSet.iterator();
       while(sortedIterator.hasNext()) {
           ConstantPoolEntry entry = (ConstantPoolEntry)sortedIterator.next();
@@ -113,43 +118,43 @@
           if (entry instanceof CPLong ||entry instanceof CPDouble)
               entries.add(entry); //these get 2 slots because of their size
       }
-		resolve();
-	}
+        resolve();
+    }
+
+    public void resolve() {
+        resolved= true;
+        Iterator it = entries.iterator();
+        while (it.hasNext()) {
+            ClassFileEntry entry = (ClassFileEntry) it.next();
+            entry.resolve(this);
+        }
+        it = others.iterator();
+        while (it.hasNext()) {
+            ClassFileEntry entry = (ClassFileEntry) it.next();
+            entry.resolve(this);
+        }
+
+        // Now that everything has been resolved, do one
+        // final sort of the class pool. This fixes up
+        // references, which are sorted by index in the
+        // class pool.
+        it = entries.iterator();
+        ClassPoolSet finalSort = new ClassPoolSet();
+        while(it.hasNext()) {
+            finalSort.add(it.next());
+        }
+        it = finalSort.iterator();
+        entries = new ArrayList();
+        while(it.hasNext()) {
+            ClassFileEntry entry = (ClassFileEntry) it.next();
+            entries.add(entry);
+            if (entry instanceof CPLong ||entry instanceof CPDouble)
+                entries.add(entry); //these get 2 slots because of their size
+        }
 
-	public void resolve() {
-		resolved= true;
-		Iterator it = entries.iterator();
-		while (it.hasNext()) {
-			ClassFileEntry entry = (ClassFileEntry) it.next();
-			entry.resolve(this);
-		}
-		it = others.iterator();
-		while (it.hasNext()) {
-			ClassFileEntry entry = (ClassFileEntry) it.next();
-			entry.resolve(this);
-		}
-
-		// Now that everything has been resolved, do one
-		// final sort of the class pool. This fixes up
-		// references, which are sorted by index in the
-		// class pool.
-		it = entries.iterator();
-		ClassPoolSet finalSort = new ClassPoolSet();
-		while(it.hasNext()) {
-		    finalSort.add(it.next());
-		}
-		it = finalSort.iterator();
-		entries = new ArrayList();
-		while(it.hasNext()) {
-		    ClassFileEntry entry = (ClassFileEntry) it.next();
-		    entries.add(entry);
-	        if (entry instanceof CPLong ||entry instanceof CPDouble)
-	            entries.add(entry); //these get 2 slots because of their size
-		}
-
-		// Now that the indices have been re-sorted, need
-		// to re-resolve to update references. This should
-		// not add any new entries this time through.
+        // Now that the indices have been re-sorted, need
+        // to re-resolve to update references. This should
+        // not add any new entries this time through.
         it = entries.iterator();
         while(it.hasNext()) {
             ClassFileEntry entry = (ClassFileEntry)it.next();
@@ -161,24 +166,24 @@
             ClassFileEntry entry = (ClassFileEntry)it.next();
             entry.resolve(this);
         }
-	}
+    }
 
-	/**
-	 * Answer the collection of CPClasses currently held
-	 * by the ClassPoolSet. This is used to calculate relevant
-	 * classes when generating the set of relevant inner
-	 * classes (ic_relevant())
-	 * @return ArrayList collection of all classes.
-	 *
-	 * NOTE: when this list is answered, the classes may not
-	 * yet be resolved.
-	 */
-	public List allClasses() {
-	    List classesList = new ArrayList();
-	    Iterator it = classPoolSet.partialIterator(DOMAIN_CLASSREF, DOMAIN_CLASSREF);
-	    while(it.hasNext()) {
-	        classesList.add(it.next());
-	    }
-	    return classesList;
-	}
+    /**
+     * Answer the collection of CPClasses currently held
+     * by the ClassPoolSet. This is used to calculate relevant
+     * classes when generating the set of relevant inner
+     * classes (ic_relevant())
+     * @return ArrayList collection of all classes.
+     *
+     * NOTE: when this list is answered, the classes may not
+     * yet be resolved.
+     */
+    public List allClasses() {
+        List classesList = new ArrayList();
+        Iterator it = classPoolSet.partialIterator(DOMAIN_CLASSREF, DOMAIN_CLASSREF);
+        while(it.hasNext()) {
+            classesList.add(it.next());
+        }
+        return classesList;
+    }
 }



Mime
View raw message