changeset 59307:a08f267427c4

8245094: Reduce overhead of initializing the default StringConcatFactory strategy Reviewed-by: psandoz, jlaskey
author redestad
date Fri, 15 May 2020 18:37:08 +0200
parents adab8762e00f
children db36e8fd2e02
files src/java.base/share/classes/java/lang/System.java src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java
diffstat 3 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/System.java	Fri May 15 18:14:58 2020 +0200
+++ b/src/java.base/share/classes/java/lang/System.java	Fri May 15 18:37:08 2020 +0200
@@ -2283,6 +2283,10 @@
                 return StringConcatHelper.lookupStatic(name, methodType);
             }
 
+            public long stringConcatInitialCoder() {
+                return StringConcatHelper.initialCoder();
+            }
+
             public Object classData(Class<?> c) {
                 return c.getClassData();
             }
--- a/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java	Fri May 15 18:14:58 2020 +0200
+++ b/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java	Fri May 15 18:37:08 2020 +0200
@@ -1724,12 +1724,7 @@
         private static final long INITIAL_CODER;
 
         static {
-            try {
-                MethodHandle initCoder = JLA.stringConcatHelper("initialCoder", methodType(long.class));
-                INITIAL_CODER = (long) initCoder.invoke();
-            } catch (Throwable e) {
-                throw new AssertionError(e);
-            }
+            INITIAL_CODER = JLA.stringConcatInitialCoder();
 
             PREPENDERS = new ConcurrentHashMap<>();
             MIXERS = new ConcurrentHashMap<>();
--- a/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java	Fri May 15 18:14:58 2020 +0200
+++ b/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java	Fri May 15 18:37:08 2020 +0200
@@ -333,6 +333,11 @@
      */
     MethodHandle stringConcatHelper(String name, MethodType methodType);
 
+    /**
+     * Get the string concat initial coder
+     */
+    long stringConcatInitialCoder();
+
     /*
      * Get the class data associated with the given class.
      * @param c the class