[condy-folding] Condy CP entries deduplication?
Remi Forax
forax at univ-mlv.fr
Tue Oct 17 17:39:54 UTC 2017
The compiler backend should use ASM :)
Rémi
----- Mail original -----
> De: "Brian Goetz" <brian.goetz at oracle.com>
> À: "Tagir Valeev" <amaembo at gmail.com>, "amber-dev" <amber-dev at openjdk.java.net>
> Envoyé: Mardi 17 Octobre 2017 19:31:54
> Objet: Re: [condy-folding] Condy CP entries deduplication?
> This is an implementation bug; these should be merged in Gen when we are
> writing out the constant pool.
>
> On 10/16/2017 6:33 AM, Tagir Valeev wrote:
>> Hello!
>>
>> Still playing with condy. Very simple program:
>>
>> import java.lang.invoke.*;
>>
>> public class Condy {
>> public static void main(String[] args) {
>> Object o1 = Intrinsics.ldc(ConstantRef.ofNull());
>> Object o2 = Intrinsics.ldc(ConstantRef.ofNull());
>> }
>> }
>>
>> I thought that only one CP entry will be created for both dynamic
>> constants, however in fact two separate entries are created, despite
>> they refer to the same NameAndType and the same BSM:
>>
>> $ javac -XDdoConstantFold Condy.java
>> $ javap -v Condy
>> ...
>> public class Condy
>> ...
>> Constant pool:
>> #1 = Methodref #5.#14 // java/lang/Object."<init>":()V
>> #2 = ConstantDynamic #0:#17 // #0:_:Ljava/lang/Object;
>> #3 = ConstantDynamic #0:#17 // #0:_:Ljava/lang/Object;
>> ...
>> {
>> ...
>> public static void main(java.lang.String[]);
>> descriptor: ([Ljava/lang/String;)V
>> flags: (0x0009) ACC_PUBLIC, ACC_STATIC
>> Code:
>> stack=1, locals=3, args_size=1
>> 0: ldc #2 // ConstantDynamic
>> #0:_:Ljava/lang/Object;
>> 2: astore_1
>> 3: ldc #3 // ConstantDynamic
>> #0:_:Ljava/lang/Object;
>> 5: astore_2
>> 6: return
>> LineNumberTable:
>> line 5: 0
>> line 6: 3
>> line 7: 6
>> }
>> ...
>> BootstrapMethods:
>> 0: #16 REF_invokeStatic
>> java/lang/invoke/Bootstraps.defaultValue:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;
>> Method arguments:
>>
>> Is this intended behavior or implementation bug? If I remember
>> correctly, discussions regarding this topic ended in merging equal CP
>> entries, but probably I'm missing something.
>>
>> Thanks,
> > Tagir Valeev.
More information about the amber-dev
mailing list