changeset 12482:f8c99c2bbb37

Binary Graphs: use 16bits for pool indices
author Gilles Duboscq <duboscq@ssw.jku.at>
date Thu, 17 Oct 2013 18:23:20 +0200
parents 45daf0d65522
children 134671fbf973
files graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinter.java src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java
diffstat 2 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinter.java	Thu Oct 17 18:18:05 2013 +0200
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinter.java	Thu Oct 17 18:23:20 2013 +0200
@@ -71,10 +71,10 @@
     private static final int KLASS = 0x00;
     private static final int ENUM_KLASS = 0x01;
 
-    private static final class ConstantPool extends LinkedHashMap<Object, Integer> {
+    private static final class ConstantPool extends LinkedHashMap<Object, Character> {
 
-        private final LinkedList<Integer> availableIds;
-        private int nextId;
+        private final LinkedList<Character> availableIds;
+        private char nextId;
         private static final long serialVersionUID = -2676889957907285681L;
 
         public ConstantPool() {
@@ -83,7 +83,7 @@
         }
 
         @Override
-        protected boolean removeEldestEntry(java.util.Map.Entry<Object, Integer> eldest) {
+        protected boolean removeEldestEntry(java.util.Map.Entry<Object, Character> eldest) {
             if (size() > CONSTANT_POOL_MAX_SIZE) {
                 availableIds.addFirst(eldest.getValue());
                 return true;
@@ -91,15 +91,15 @@
             return false;
         }
 
-        private Integer nextAvailableId() {
+        private Character nextAvailableId() {
             if (!availableIds.isEmpty()) {
                 return availableIds.removeFirst();
             }
             return nextId++;
         }
 
-        public int add(Object obj) {
-            Integer id = nextAvailableId();
+        public char add(Object obj) {
+            Character id = nextAvailableId();
             put(obj, id);
             return id;
         }
@@ -232,7 +232,7 @@
             writeByte(POOL_NULL);
             return;
         }
-        Integer id = constantPool.get(object);
+        Character id = constantPool.get(object);
         if (id == null) {
             addPoolEntry(object);
         } else {
@@ -251,7 +251,7 @@
             } else {
                 writeByte(POOL_STRING);
             }
-            writeInt(id.intValue());
+            writeShort(id.charValue());
         }
     }
 
@@ -263,9 +263,9 @@
     }
 
     private void addPoolEntry(Object object) throws IOException {
-        int index = constantPool.add(object);
+        char index = constantPool.add(object);
         writeByte(POOL_NEW);
-        writeInt(index);
+        writeShort(index);
         if (object instanceof Class<?>) {
             Class<?> klass = (Class<?>) object;
             writeByte(POOL_CLASS);
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java	Thu Oct 17 18:18:05 2013 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java	Thu Oct 17 18:23:20 2013 +0200
@@ -376,7 +376,7 @@
             return (T) addPoolEntry(klass);
         }
         assert assertObjectType(klass, type);
-        int index = readInt();
+        char index = readShort();
         if (index < 0 || index >= constantPool.size()) {
             throw new IOException("Invalid constant pool index : " + index);
         }
@@ -408,7 +408,7 @@
     }
 
     private Object addPoolEntry(Class<?> klass) throws IOException {
-        int index = readInt();
+        char index = readShort();
         int type = readByte();
         assert assertObjectType(klass, type) : "Wrong object type : " + klass + " != " + type;
         Object obj;