On 13.12.2017 11:53, forax at univ-mlv.fr wrote:
>>> ----- Mail original -----
>> De: "jan lahoda" <jan.lahoda at oracle.com>
>> À: "Remi Forax" <forax at univ-mlv.fr>
>> Cc: "amber-dev" <amber-dev at openjdk.java.net>
>> Envoyé: Mercredi 13 Décembre 2017 11:37:50
>> Objet: Re: hg: amber/amber: 8192963: Starting with switch desugaring to indy.
>>> On 13.12.2017 10:58, Remi Forax wrote:
>>> Hi Jan,
>>> putting the implementation in jdk.internal.misc may have a side effect on
>>> performance,
>>>> The issue there is (that it seems) that MethodHandles.lookup() cannot be
>> used inside j.l.invoke (see
>> MethodHandles.Lookup.checkUnprivilegedlookupClass). So I've put the impl
>> into a different package. I don't know if there's a better way do that,
>> but this all can change.
>> you can use MethodHandles.Lookup.IMPL_LOOKUP instead
Thanks! I've inline the SwitchBootstrapsImpl back to SwitchBootstraps
using IMPL_LOOKUP.
>>>>>> i believe that the VM/JIT trust final fields declared in java.lang.invoke but
>>> not the ones in jdk.internal.misc.
>>>>>> In the code of StringSwitchCallSite, i do not understand how super(targetType,
>>> HOOK); can not throw a runtime exception because the MethodType of HOOK takes a
>>> callsite as first parameter.
>>>> The initHook methods are instance methods, so that the first parameter
>> is "this"? But Brian would know more, I assume.
>> that's my point, if the first parameter of the method handle is a StringSwitchCallSite and the first parameter of invokedynamic is a String (the switch argument), how can it work ?
As far as I can tell, the HOOK is the "initHook" which only takes
"this", but is not used in the switch invocation. This method only
returns the actual method handle (pointing to stringSwitch) which takes
the String and that will be invoked for the switch.
Jan
>>>>> Jan
>> Rémi
>>>>>>>>> Note: unlike MutableCallSite where you can/have to initialize the callsite in
>>> two steps (because the methodHandle it constains has to reference the mutable
>>> callsite), so inheriting from a MutableCallSite makes sense, with a
>>> ConstantCallSite using inheritance doesn't make sense. You can create a class
>>> that doesn't inherits from ConstantCallSite, declare stringSwitch as static and
>>> instead of storing the values as field you can declare them as parameter of
>>> stringSwitch and use insertArguments to partailly applied them.
>>>>>> Rémi
>>>>>> ----- Mail original -----
>>>> De: "jan lahoda" <jan.lahoda at oracle.com>
>>>> À: "amber-dev" <amber-dev at openjdk.java.net>
>>>> Envoyé: Mardi 12 Décembre 2017 20:55:21
>>>> Objet: hg: amber/amber: 8192963: Starting with switch desugaring to indy.
>>>>>>> Changeset: bb054c3c7d3a
>>>> Author: jlahoda
>>>> Date: 2017-12-12 19:41 +0100
>>>> URL: http://hg.openjdk.java.net/amber/amber/rev/bb054c3c7d3a>>>>>>>> 8192963: Starting with switch desugaring to indy.
>>>> Contributed-by: brian.goetz at oracle.com, jan.lahoda at oracle.com>>>>>>>> + src/java.base/share/classes/java/lang/invoke/SwitchBootstraps.java
>>>> + src/java.base/share/classes/jdk/internal/misc/SwitchBootstrapsImpl.java
>>>> ! src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java
>>>> ! src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java
>>>> ! src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
>>>> ! src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java
>>>> ! src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java
>>>> + test/jdk/java/lang/invoke/TestSwitchBootstrap.java
>>>> ! test/langtools/tools/javac/switchnull/SwitchNull.java