Enable constant pool caching JEP-349-branch
authoregahlin
Thu, 11 Jul 2019 02:21:18 +0200
branchJEP-349-branch
changeset 57467 de154169948b
parent 57466 faf3a3b0bab6
child 57470 025c9b8eaefd
Enable constant pool caching
src/jdk.jfr/share/classes/jdk/jfr/consumer/ChunkParser.java
src/jdk.jfr/share/classes/jdk/jfr/consumer/ConstantLookup.java
src/jdk.jfr/share/classes/jdk/jfr/consumer/ConstantMap.java
--- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/ChunkParser.java	Thu Jul 11 02:18:31 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/ChunkParser.java	Thu Jul 11 02:21:18 2019 +0200
@@ -256,17 +256,16 @@
                     }
                     for (int j = 0; j < count; j++) {
                         long key = input.readLong();
-//                      Object resolved = lookup.getCurrent(key);
-// Disable cache        Object resolved = lookup.getResolved(key);
-//                      if (resolved == null) {
+                      Object resolved = lookup.getPreviousResolved(key);
+                      if (resolved == null) {
                             Object v = parser.parse(input);
                             logConstant(key, v, false);
                             lookup.getLatestPool().put(key, v);
-//                        } else {
-//                            parser.skip(input);
-//                            logConstant(key, resolved, true);
-// Disable cache            lookup.getLatestPool().putResolved(key, resolved);
-//                        }
+                        } else {
+                            parser.skip(input);
+                            logConstant(key, resolved, true);
+                            lookup.getLatestPool().putResolved(key, resolved);
+                        }
                     }
                 } catch (Exception e) {
                     throw new IOException("Error parsing constant pool type " + getName(id) + " at position " + input.position() + " at check point between [" + lastCP + ", " + lastCP + size + "]",
--- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/ConstantLookup.java	Thu Jul 11 02:18:31 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/ConstantLookup.java	Thu Jul 11 02:21:18 2019 +0200
@@ -22,7 +22,7 @@
     }
 
     public void newPool() {
-     //   previous = current;
+        previous = current;
         current = new ConstantMap(current.factory, current.name);
      //   previous =  new ConstantMap(); // disable cache
     }
--- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/ConstantMap.java	Thu Jul 11 02:18:31 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/ConstantMap.java	Thu Jul 11 02:21:18 2019 +0200
@@ -174,8 +174,8 @@
     }
 
     public void putResolved(long id, Object object) {
+        objects.put(id, object);
         objects.setId(id, RESOLUTION_FINISHED);
-        objects.put(id, object);
     }
 
     public void setAllResolved(boolean allResolved) {