This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[BC] Patch: Cached class map
- From: Andrew Haley <aph at redhat dot com>
- To: java-patches at gcc dot gnu dot org, Tom Tromey <tromey at redhat dot com>
- Date: Fri, 5 Nov 2004 13:17:12 +0000
- Subject: [BC] Patch: Cached class map
- References: <m3oeioduic.fsf@localhost.localdomain><16767.62665.881475.791718@cuddles.cambridge.redhat.com><16767.63050.12354.298557@cuddles.cambridge.redhat.com><m3fz3zddat.fsf@localhost.localdomain><16769.12680.465178.29779@cuddles.cambridge.redhat.com>
tromey found that the default database size wasn't big enough. The
default size of 32k entries remains, but this allows the suer to set
the size at creation time.
Andrew.
2004-11-05 Andrew Haley <aph@redhat.com>
* jv_dbtool.java (main): Allow the user to specify the size of the
database. Display the capacity and the size.
(usage): Show the new option.
Index: jv_dbtool.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Attic/jv_dbtool.java,v
retrieving revision 1.1.2.1
diff -c -2 -p -r1.1.2.1 jv_dbtool.java
*** jv_dbtool.java 28 Oct 2004 18:08:24 -0000 1.1.2.1
--- jv_dbtool.java 5 Nov 2004 13:11:17 -0000
*************** import java.util.*;
*** 13,16 ****
--- 13,17 ----
import java.util.jar.*;
import java.security.MessageDigest;
+ import java.math.BigInteger;
public class jv_dbtool
*************** public class jv_dbtool
*** 35,43 ****
if (s[0].equals("-n"))
{
! insist (s.length == 2);
try
{
PersistentByteMap b
! = PersistentByteMap.emptyPersistentByteMap (s[1], 32749, 2000000);
}
catch (Exception e)
--- 36,71 ----
if (s[0].equals("-n"))
{
! insist (s.length >= 2 && s.length <= 3);
!
! int capacity = 32749;
!
! if (s.length == 3)
! {
! // The user has explicitly provided a size for the table.
! // We're going to make that size prime. This isn't
! // strictly necessary but it can't hurt.
!
! BigInteger size = new BigInteger(s[2], 10);
! BigInteger two = BigInteger.ONE.add(BigInteger.ONE);
!
! if (size.getLowestSetBit() != 0) // A hard way to say isEven()
! size = size.add(BigInteger.ONE);
!
! while (! size.isProbablePrime(10))
! size = size.add(two);
!
! capacity = size.intValue();
!
! if (capacity <= 2)
! {
! usage();
! System.exit(1);
! }
! }
!
try
{
PersistentByteMap b
! = PersistentByteMap.emptyPersistentByteMap (s[1], capacity, capacity*64);
}
catch (Exception e)
*************** public class jv_dbtool
*** 116,119 ****
--- 144,153 ----
= new PersistentByteMap(new File(s[1]),
PersistentByteMap.AccessMode.READ_ONLY);
+
+ System.out.println ("Capacity: " + b.capacity());
+ System.out.println ("Size: " + b.size());
+ System.out.println ();
+
+ System.out.println ("Elements: ");
Iterator iterator = b.iterator(PersistentByteMap.ENTRIES);
*************** public class jv_dbtool
*** 183,187 ****
+ "\n"
+ " Usage: \n"
! + " jv-dbtool -n file.gcjdb - Create a new gcj map database\n"
+ " jv-dbtool -a file.gcjdb file.jar file.so\n"
+ " - Add the contents of file.jar to the database\n"
--- 217,221 ----
+ "\n"
+ " Usage: \n"
! + " jv-dbtool -n file.gcjdb [size] - Create a new gcj map database\n"
+ " jv-dbtool -a file.gcjdb file.jar file.so\n"
+ " - Add the contents of file.jar to the database\n"
*************** public class jv_dbtool
*** 234,236 ****
}
}
!
\ No newline at end of file
--- 268,270 ----
}
}
!