Quantcast

[10] RFR: 8178384: Reduce work in java.lang.invoke initializers

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[10] RFR: 8178384: Reduce work in java.lang.invoke initializers

Claes Redestad
Hi,

profiling initializers in java.lang.invoke shows we're still doing
various things during
class initialization which could be done lazily or not at all. The
proposed patch
reduce bytecode executed, memory churn and retained heap footprint when
initializing java.lang.invoke:

Webrev: http://cr.openjdk.java.net/~redestad/8178384/jdk.01/
Bug: https://bugs.openjdk.java.net/browse/JDK-8178384

Testing: java.lang.invoke jtreg tests, sanity performance testing

Thanks!

/Claes
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [10] RFR: 8178384: Reduce work in java.lang.invoke initializers

Vladimir Ivanov
Looks good.

One small suggestion [1]

Best regards,
Vladimir Ivanov

[1] diff --git
a/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
b/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
--- a/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
+++ b/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
@@ -456,6 +456,7 @@
          static final String MH       = "java/lang/invoke/MethodHandle";
          static final String MH_SIG   = "L"+MH+";";
          static final String BMH      =
"java/lang/invoke/BoundMethodHandle";
+        static final String BMH_NAME =
"java.lang.invoke.BoundMethodHandle";
          static final String BMH_SIG  = "L"+BMH+";";
          static final String SPECIES_DATA     =
"java/lang/invoke/BoundMethodHandle$SpeciesData";
          static final String SPECIES_DATA_SIG = "L"+SPECIES_DATA+";";
@@ -463,7 +464,7 @@

          static final String SPECIES_PREFIX_NAME = "Species_";
          static final String SPECIES_PREFIX_PATH = BMH + "$" +
SPECIES_PREFIX_NAME;
-        static final String SPECIES_CLASS_PREFIX =
SPECIES_PREFIX_PATH.replace('/', '.');
+        static final String SPECIES_CLASS_PREFIX = BMH_NAME + "$" +
SPECIES_PREFIX_NAME;

          static final String BMHSPECIES_DATA_EWI_SIG = "(B)" +
SPECIES_DATA_SIG;
          static final String BMHSPECIES_DATA_GFC_SIG = "(" + JLS_SIG +
JLC_SIG + ")" + SPECIES_DATA_SIG;


On 4/10/17 5:09 PM, Claes Redestad wrote:

> Hi,
>
> profiling initializers in java.lang.invoke shows we're still doing
> various things during
> class initialization which could be done lazily or not at all. The
> proposed patch
> reduce bytecode executed, memory churn and retained heap footprint when
> initializing java.lang.invoke:
>
> Webrev: http://cr.openjdk.java.net/~redestad/8178384/jdk.01/
> Bug: https://bugs.openjdk.java.net/browse/JDK-8178384
>
> Testing: java.lang.invoke jtreg tests, sanity performance testing
>
> Thanks!
>
> /Claes
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [10] RFR: 8178384: Reduce work in java.lang.invoke initializers

Claes Redestad

On 04/10/2017 05:19 PM, Vladimir Ivanov wrote:
> Looks good.

Thanks for reviewing!

>
> One small suggestion [1]

Sure, updated in-place.

/Claes

>
> Best regards,
> Vladimir Ivanov
>
> [1] diff --git
> a/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
> b/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
> --- a/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
> +++ b/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
> @@ -456,6 +456,7 @@
>          static final String MH       = "java/lang/invoke/MethodHandle";
>          static final String MH_SIG   = "L"+MH+";";
>          static final String BMH      =
> "java/lang/invoke/BoundMethodHandle";
> +        static final String BMH_NAME =
> "java.lang.invoke.BoundMethodHandle";
>          static final String BMH_SIG  = "L"+BMH+";";
>          static final String SPECIES_DATA     =
> "java/lang/invoke/BoundMethodHandle$SpeciesData";
>          static final String SPECIES_DATA_SIG = "L"+SPECIES_DATA+";";
> @@ -463,7 +464,7 @@
>
>          static final String SPECIES_PREFIX_NAME = "Species_";
>          static final String SPECIES_PREFIX_PATH = BMH + "$" +
> SPECIES_PREFIX_NAME;
> -        static final String SPECIES_CLASS_PREFIX =
> SPECIES_PREFIX_PATH.replace('/', '.');
> +        static final String SPECIES_CLASS_PREFIX = BMH_NAME + "$" +
> SPECIES_PREFIX_NAME;
>
>          static final String BMHSPECIES_DATA_EWI_SIG = "(B)" +
> SPECIES_DATA_SIG;
>          static final String BMHSPECIES_DATA_GFC_SIG = "(" + JLS_SIG +
> JLC_SIG + ")" + SPECIES_DATA_SIG;
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [10] RFR: 8178384: Reduce work in java.lang.invoke initializers

Paul Sandoz
In reply to this post by Claes Redestad
+1

These named functions really wanna be LDC’ed but i suspect using constant dynamic + representation in source (when available) might result in it’s own bootstrap issues, still it would be interesting to try when available.

Paul.

> On 10 Apr 2017, at 07:09, Claes Redestad <[hidden email]> wrote:
>
> Hi,
>
> profiling initializers in java.lang.invoke shows we're still doing various things during
> class initialization which could be done lazily or not at all. The proposed patch
> reduce bytecode executed, memory churn and retained heap footprint when
> initializing java.lang.invoke:
>
> Webrev: http://cr.openjdk.java.net/~redestad/8178384/jdk.01/
> Bug: https://bugs.openjdk.java.net/browse/JDK-8178384
>
> Testing: java.lang.invoke jtreg tests, sanity performance testing
>
> Thanks!
>
> /Claes

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [10] RFR: 8178384: Reduce work in java.lang.invoke initializers

Remi Forax
Currently playing with a pattern matching representation for Amber, if think we need a form of array constant that does not require a bootstrap method.
Afaik, an array of any existing constants does not need a Java code to construct itself.

Rémi


On April 10, 2017 6:18:07 PM GMT+02:00, Paul Sandoz <[hidden email]> wrote:

>+1
>
>These named functions really wanna be LDC’ed but i suspect using
>constant dynamic + representation in source (when available) might
>result in it’s own bootstrap issues, still it would be interesting to
>try when available.
>
>Paul.
>
>> On 10 Apr 2017, at 07:09, Claes Redestad <[hidden email]>
>wrote:
>>
>> Hi,
>>
>> profiling initializers in java.lang.invoke shows we're still doing
>various things during
>> class initialization which could be done lazily or not at all. The
>proposed patch
>> reduce bytecode executed, memory churn and retained heap footprint
>when
>> initializing java.lang.invoke:
>>
>> Webrev: http://cr.openjdk.java.net/~redestad/8178384/jdk.01/
>> Bug: https://bugs.openjdk.java.net/browse/JDK-8178384
>>
>> Testing: java.lang.invoke jtreg tests, sanity performance testing
>>
>> Thanks!
>>
>> /Claes

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [10] RFR: 8178384: Reduce work in java.lang.invoke initializers

Claes Redestad
Sounds like you want https://bugs.openjdk.java.net/browse/JDK-8061402 -
which was originally filed back in 2002 but was closed since it got
filed on the wrong component or something... ¯\_(ツ)_/¯

There's still a number of char[] foo = "FOO".toCharArray() in the JDK
since this allows for a more compact representation in bytecode (but is
likely a bit slower during startup, especially since compact strings).

/Claes

On 04/10/2017 06:32 PM, Remi Forax wrote:

> Currently playing with a pattern matching representation for Amber, if
> think we need a form of array constant that does not require a
> bootstrap method.
> Afaik, an array of any existing constants does not need a Java code to
> construct itself.
>
> Rémi
>
>
> On April 10, 2017 6:18:07 PM GMT+02:00, Paul Sandoz
> <[hidden email]> wrote:
>
>     +1
>
>     These named functions really wanna be LDC’ed but i suspect using constant dynamic + representation in source (when available) might result in it’s own bootstrap issues, still it would be interesting to try when available.
>
>     Paul.
>
>         On 10 Apr 2017, at 07:09, Claes Redestad
>         <[hidden email]> wrote: Hi, profiling initializers
>         in java.lang.invoke shows we're still doing various things
>         during class initialization which could be done lazily or not
>         at all. The proposed patch reduce bytecode executed, memory
>         churn and retained heap footprint when initializing
>         java.lang.invoke: Webrev:
>         http://cr.openjdk.java.net/~redestad/8178384/jdk.01
>         <http://cr.openjdk.java.net/%7Eredestad/8178384/jdk.01>/ Bug:
>         https://bugs.openjdk.java.net/browse/JDK-8178384 Testing:
>         java.lang.invoke jtreg tests, sanity performance testing
>         Thanks! /Claes
>
>
>
>
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [10] RFR: 8178384: Reduce work in java.lang.invoke initializers

Claes Redestad
In reply to this post by Claes Redestad


On 04/10/2017 05:20 PM, Claes Redestad wrote:

>
> On 04/10/2017 05:19 PM, Vladimir Ivanov wrote:
>> Looks good.
>
> Thanks for reviewing!
>
>>
>> One small suggestion [1]
>
> Sure, updated in-place.

Taking a second look at these constants, it turned out that a few of
them were unused, but since they
weren't private this wasn't called out in my IDE.  Mind if I clean this
up (add private modifier, remove
unused JLS_SIG, JLC_SIG, BMHSPECIES_DATA_GFC_SIG, VOID_SIG) as part of
this patch?

I've verified none of the remaining constants are used anywhere outside
the class, i.e., no synthetic
accessor methods are added by this refactoring.

Thanks!

/Claes

diff -r 524eb921da04
src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
---
a/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
Tue Apr 11 10:51:05 2017 +0200
+++
b/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
Tue Apr 11 11:01:22 2017 +0200
@@ -450,33 +450,29 @@
       */
      static class Factory {

-        static final String JLO_SIG  = "Ljava/lang/Object;";
-        static final String JLS_SIG  = "Ljava/lang/String;";
-        static final String JLC_SIG  = "Ljava/lang/Class;";
-        static final String MH       = "java/lang/invoke/MethodHandle";
-        static final String MH_SIG   = "L"+MH+";";
-        static final String BMH      =
"java/lang/invoke/BoundMethodHandle";
-        static final String BMH_NAME =
"java.lang.invoke.BoundMethodHandle";
-        static final String BMH_SIG  = "L"+BMH+";";
-        static final String SPECIES_DATA     =
"java/lang/invoke/BoundMethodHandle$SpeciesData";
-        static final String SPECIES_DATA_SIG = "L"+SPECIES_DATA+";";
-        static final String STABLE_SIG       =
"Ljdk/internal/vm/annotation/Stable;";
+        private static final String JLO_SIG  = "Ljava/lang/Object;";
+        private static final String MH       =
"java/lang/invoke/MethodHandle";
+        private static final String MH_SIG   = "L"+MH+";";
+        private static final String BMH      =
"java/lang/invoke/BoundMethodHandle";
+        private static final String BMH_NAME =
"java.lang.invoke.BoundMethodHandle";
+        private static final String BMH_SIG  = "L"+BMH+";";
+        private static final String SPECIES_DATA     =
"java/lang/invoke/BoundMethodHandle$SpeciesData";
+        private static final String SPECIES_DATA_SIG =
"L"+SPECIES_DATA+";";
+        private static final String STABLE_SIG       =
"Ljdk/internal/vm/annotation/Stable;";

-        static final String SPECIES_PREFIX_NAME = "Species_";
-        static final String SPECIES_PREFIX_PATH = BMH + "$" +
SPECIES_PREFIX_NAME;
-        static final String SPECIES_CLASS_PREFIX = BMH_NAME + "$" +
SPECIES_PREFIX_NAME;
+        private static final String SPECIES_PREFIX_NAME = "Species_";
+        private static final String SPECIES_PREFIX_PATH = BMH + "$" +
SPECIES_PREFIX_NAME;
+        private static final String SPECIES_CLASS_PREFIX = BMH_NAME +
"$" + SPECIES_PREFIX_NAME;

-        static final String BMHSPECIES_DATA_EWI_SIG = "(B)" +
SPECIES_DATA_SIG;
-        static final String BMHSPECIES_DATA_GFC_SIG = "(" + JLS_SIG +
JLC_SIG + ")" + SPECIES_DATA_SIG;
-        static final String MYSPECIES_DATA_SIG = "()" + SPECIES_DATA_SIG;
-        static final String VOID_SIG   = "()V";
-        static final String INT_SIG    = "()I";
+        private static final String BMHSPECIES_DATA_EWI_SIG = "(B)" +
SPECIES_DATA_SIG;
+        private static final String MYSPECIES_DATA_SIG = "()" +
SPECIES_DATA_SIG;
+        private static final String INT_SIG    = "()I";

-        static final String SIG_INCIPIT =
"(Ljava/lang/invoke/MethodType;Ljava/lang/invoke/LambdaForm;";
+        private static final String SIG_INCIPIT =
"(Ljava/lang/invoke/MethodType;Ljava/lang/invoke/LambdaForm;";

-        static final String[] E_THROWABLE = new String[] {
"java/lang/Throwable" };
+        private static final String[] E_THROWABLE = new String[] {
"java/lang/Throwable" };

-        static final ConcurrentMap<String, Class<? extends
BoundMethodHandle>> CLASS_CACHE = new ConcurrentHashMap<>();
+        private static final ConcurrentMap<String, Class<? extends
BoundMethodHandle>> CLASS_CACHE = new ConcurrentHashMap<>();

          /**
           * Get a concrete subclass of BMH for a given combination of
bound types.


>
> /Claes

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [10] RFR: 8178384: Reduce work in java.lang.invoke initializers

Vladimir Ivanov
Reviewed.

Best regards,
Vladimir Ivanov

On 4/11/17 12:06 PM, Claes Redestad wrote:

>
>
> On 04/10/2017 05:20 PM, Claes Redestad wrote:
>>
>> On 04/10/2017 05:19 PM, Vladimir Ivanov wrote:
>>> Looks good.
>>
>> Thanks for reviewing!
>>
>>>
>>> One small suggestion [1]
>>
>> Sure, updated in-place.
>
> Taking a second look at these constants, it turned out that a few of
> them were unused, but since they
> weren't private this wasn't called out in my IDE.  Mind if I clean this
> up (add private modifier, remove
> unused JLS_SIG, JLC_SIG, BMHSPECIES_DATA_GFC_SIG, VOID_SIG) as part of
> this patch?
>
> I've verified none of the remaining constants are used anywhere outside
> the class, i.e., no synthetic
> accessor methods are added by this refactoring.
>
> Thanks!
>
> /Claes
>
> diff -r 524eb921da04
> src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
> ---
> a/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
> Tue Apr 11 10:51:05 2017 +0200
> +++
> b/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
> Tue Apr 11 11:01:22 2017 +0200
> @@ -450,33 +450,29 @@
>       */
>      static class Factory {
>
> -        static final String JLO_SIG  = "Ljava/lang/Object;";
> -        static final String JLS_SIG  = "Ljava/lang/String;";
> -        static final String JLC_SIG  = "Ljava/lang/Class;";
> -        static final String MH       = "java/lang/invoke/MethodHandle";
> -        static final String MH_SIG   = "L"+MH+";";
> -        static final String BMH      =
> "java/lang/invoke/BoundMethodHandle";
> -        static final String BMH_NAME =
> "java.lang.invoke.BoundMethodHandle";
> -        static final String BMH_SIG  = "L"+BMH+";";
> -        static final String SPECIES_DATA     =
> "java/lang/invoke/BoundMethodHandle$SpeciesData";
> -        static final String SPECIES_DATA_SIG = "L"+SPECIES_DATA+";";
> -        static final String STABLE_SIG       =
> "Ljdk/internal/vm/annotation/Stable;";
> +        private static final String JLO_SIG  = "Ljava/lang/Object;";
> +        private static final String MH       =
> "java/lang/invoke/MethodHandle";
> +        private static final String MH_SIG   = "L"+MH+";";
> +        private static final String BMH      =
> "java/lang/invoke/BoundMethodHandle";
> +        private static final String BMH_NAME =
> "java.lang.invoke.BoundMethodHandle";
> +        private static final String BMH_SIG  = "L"+BMH+";";
> +        private static final String SPECIES_DATA     =
> "java/lang/invoke/BoundMethodHandle$SpeciesData";
> +        private static final String SPECIES_DATA_SIG =
> "L"+SPECIES_DATA+";";
> +        private static final String STABLE_SIG       =
> "Ljdk/internal/vm/annotation/Stable;";
>
> -        static final String SPECIES_PREFIX_NAME = "Species_";
> -        static final String SPECIES_PREFIX_PATH = BMH + "$" +
> SPECIES_PREFIX_NAME;
> -        static final String SPECIES_CLASS_PREFIX = BMH_NAME + "$" +
> SPECIES_PREFIX_NAME;
> +        private static final String SPECIES_PREFIX_NAME = "Species_";
> +        private static final String SPECIES_PREFIX_PATH = BMH + "$" +
> SPECIES_PREFIX_NAME;
> +        private static final String SPECIES_CLASS_PREFIX = BMH_NAME +
> "$" + SPECIES_PREFIX_NAME;
>
> -        static final String BMHSPECIES_DATA_EWI_SIG = "(B)" +
> SPECIES_DATA_SIG;
> -        static final String BMHSPECIES_DATA_GFC_SIG = "(" + JLS_SIG +
> JLC_SIG + ")" + SPECIES_DATA_SIG;
> -        static final String MYSPECIES_DATA_SIG = "()" + SPECIES_DATA_SIG;
> -        static final String VOID_SIG   = "()V";
> -        static final String INT_SIG    = "()I";
> +        private static final String BMHSPECIES_DATA_EWI_SIG = "(B)" +
> SPECIES_DATA_SIG;
> +        private static final String MYSPECIES_DATA_SIG = "()" +
> SPECIES_DATA_SIG;
> +        private static final String INT_SIG    = "()I";
>
> -        static final String SIG_INCIPIT =
> "(Ljava/lang/invoke/MethodType;Ljava/lang/invoke/LambdaForm;";
> +        private static final String SIG_INCIPIT =
> "(Ljava/lang/invoke/MethodType;Ljava/lang/invoke/LambdaForm;";
>
> -        static final String[] E_THROWABLE = new String[] {
> "java/lang/Throwable" };
> +        private static final String[] E_THROWABLE = new String[] {
> "java/lang/Throwable" };
>
> -        static final ConcurrentMap<String, Class<? extends
> BoundMethodHandle>> CLASS_CACHE = new ConcurrentHashMap<>();
> +        private static final ConcurrentMap<String, Class<? extends
> BoundMethodHandle>> CLASS_CACHE = new ConcurrentHashMap<>();
>
>          /**
>           * Get a concrete subclass of BMH for a given combination of
> bound types.
>
>
>>
>> /Claes
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [10] RFR: 8178384: Reduce work in java.lang.invoke initializers

Claes Redestad
Thanks! Pushed.

/Claes

On 04/11/2017 11:16 AM, Vladimir Ivanov wrote:
> Reviewed.
>
> Best regards,
> Vladimir Ivanov

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [10] RFR: 8178384: Reduce work in java.lang.invoke initializers

Remi Forax
In reply to this post by Claes Redestad
Hi Claes,
yes !

We use something equivalent to "FOO".toCharArray() at several place in ASM because there is no constant pool constant arrays [1].

Terence Parr also mentions that issue at the JVM Summit 2009 [2].

Rémi
[1] http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/645c0d3e3977/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassWriter.java#l556 
[2] http://parrt.cs.usfca.edu/doc/impl-parsers-in-java.pdf


----- Mail original -----
> De: "Claes Redestad" <[hidden email]>
> À: "Remi Forax" <[hidden email]>, [hidden email], "Paul Sandoz" <[hidden email]>
> Envoyé: Mardi 11 Avril 2017 10:37:45
> Objet: Re: [10] RFR: 8178384: Reduce work in java.lang.invoke initializers

> Sounds like you want https://bugs.openjdk.java.net/browse/JDK-8061402 -
> which was originally filed back in 2002 but was closed since it got
> filed on the wrong component or something... ¯\_(ツ)_/¯
>
> There's still a number of char[] foo = "FOO".toCharArray() in the JDK
> since this allows for a more compact representation in bytecode (but is
> likely a bit slower during startup, especially since compact strings).
>
> /Claes
>
> On 04/10/2017 06:32 PM, Remi Forax wrote:
>> Currently playing with a pattern matching representation for Amber, if
>> think we need a form of array constant that does not require a
>> bootstrap method.
>> Afaik, an array of any existing constants does not need a Java code to
>> construct itself.
>>
>> Rémi
>>
>>
>> On April 10, 2017 6:18:07 PM GMT+02:00, Paul Sandoz
>> <[hidden email]> wrote:
>>
>>     +1
>>
>>     These named functions really wanna be LDC’ed but i suspect using constant
>>     dynamic + representation in source (when available) might result in it’s own
>>     bootstrap issues, still it would be interesting to try when available.
>>
>>     Paul.
>>
>>         On 10 Apr 2017, at 07:09, Claes Redestad
>>         <[hidden email]> wrote: Hi, profiling initializers
>>         in java.lang.invoke shows we're still doing various things
>>         during class initialization which could be done lazily or not
>>         at all. The proposed patch reduce bytecode executed, memory
>>         churn and retained heap footprint when initializing
>>         java.lang.invoke: Webrev:
>>         http://cr.openjdk.java.net/~redestad/8178384/jdk.01
>>         <http://cr.openjdk.java.net/%7Eredestad/8178384/jdk.01>/ Bug:
>>         https://bugs.openjdk.java.net/browse/JDK-8178384 Testing:
>>         java.lang.invoke jtreg tests, sanity performance testing
>>         Thanks! /Claes
>>
>>
>>
>>
>> --
> > Sent from my Android device with K-9 Mail. Please excuse my brevity.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [10] RFR: 8178384: Reduce work in java.lang.invoke initializers

Claes Redestad
Yes, I've seen some of these dirty hacks in the ASM code, as they show
up here and there in
my startup graphs when I add some lambdas to the mix[1]... ;-)

I hadn't considered the 64K bytecode per method limitation, which means
you couldn't even
generate a fraction of that number of elements in an array statically in
a single method, so in
those cases the "FOO".toCharArray() hack makes more sense.

I think constant pool arrays could be a welcome bonus if it can be
shaken out of the other
things we're doing for amber and valhalla...

Thanks!

/Claes

[1] Since Compact Strings the cost of String.charAt-loops and
String.toCharArray has jumped
somewhat during startup, but will of course get compiled away and most
often outperform
after warmup.

On 2017-04-11 20:20, [hidden email] wrote:

> Hi Claes,
> yes !
>
> We use something equivalent to "FOO".toCharArray() at several place in ASM because there is no constant pool constant arrays [1].
>
> Terence Parr also mentions that issue at the JVM Summit 2009 [2].
>
> Rémi
> [1] http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/645c0d3e3977/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassWriter.java#l556
> [2] http://parrt.cs.usfca.edu/doc/impl-parsers-in-java.pdf
>
>
> ----- Mail original -----
>> De: "Claes Redestad" <[hidden email]>
>> À: "Remi Forax" <[hidden email]>, [hidden email], "Paul Sandoz" <[hidden email]>
>> Envoyé: Mardi 11 Avril 2017 10:37:45
>> Objet: Re: [10] RFR: 8178384: Reduce work in java.lang.invoke initializers
>> Sounds like you want https://bugs.openjdk.java.net/browse/JDK-8061402 -
>> which was originally filed back in 2002 but was closed since it got
>> filed on the wrong component or something... ¯\_(ツ)_/¯
>>
>> There's still a number of char[] foo = "FOO".toCharArray() in the JDK
>> since this allows for a more compact representation in bytecode (but is
>> likely a bit slower during startup, especially since compact strings).
>>
>> /Claes
>>
>> On 04/10/2017 06:32 PM, Remi Forax wrote:
>>> Currently playing with a pattern matching representation for Amber, if
>>> think we need a form of array constant that does not require a
>>> bootstrap method.
>>> Afaik, an array of any existing constants does not need a Java code to
>>> construct itself.
>>>
>>> Rémi
>>>
>>>
>>> On April 10, 2017 6:18:07 PM GMT+02:00, Paul Sandoz
>>> <[hidden email]> wrote:
>>>
>>>      +1
>>>
>>>      These named functions really wanna be LDC’ed but i suspect using constant
>>>      dynamic + representation in source (when available) might result in it’s own
>>>      bootstrap issues, still it would be interesting to try when available.
>>>
>>>      Paul.
>>>
>>>          On 10 Apr 2017, at 07:09, Claes Redestad
>>>          <[hidden email]> wrote: Hi, profiling initializers
>>>          in java.lang.invoke shows we're still doing various things
>>>          during class initialization which could be done lazily or not
>>>          at all. The proposed patch reduce bytecode executed, memory
>>>          churn and retained heap footprint when initializing
>>>          java.lang.invoke: Webrev:
>>>          http://cr.openjdk.java.net/~redestad/8178384/jdk.01
>>>          <http://cr.openjdk.java.net/%7Eredestad/8178384/jdk.01>/ Bug:
>>>          https://bugs.openjdk.java.net/browse/JDK-8178384 Testing:
>>>          java.lang.invoke jtreg tests, sanity performance testing
>>>          Thanks! /Claes
>>>
>>>
>>>
>>>
>>> --
>>> Sent from my Android device with K-9 Mail. Please excuse my brevity.

Loading...