(Condy) Folded of local variables are still considered when calculating the max number of local vars of a method

Vicente Romero vicente.romero at oracle.com
Wed Sep 5 20:11:06 UTC 2018



On 09/05/2018 03:58 PM, Maurizio Cimadamore wrote:
> The fix looks good - I guess we could also push it back to 12 - since 
> it probably fixes the same issues with string constants?

I agree, I will accept this as a review without sending it to 
compiler-dev, just joking ;)
>
> Cheers
> Maurizio

Vicente

>
>
> On 05/09/18 19:04, Vicente Romero wrote:
>> Hi Remi,
>>
>> Very good catch! I have pushed [1] which fixes the issue you found,
>>
>> Thanks,
>> Vicente
>>
>> [1] http://hg.openjdk.java.net/amber/amber/rev/7bb7ac4f13d7
>>
>> On 09/02/2018 01:58 PM, Remi Forax wrote:
>>> Hi all,
>>> while trying to reproduce a bug in ASM using the constant API + 
>>> Intrinsics.ldc, i've spot a discrepancy,
>>> using the follwing example,
>>>
>>> package jdk12;
>>>
>>> import java.lang.constant.ClassDesc;
>>> import java.lang.constant.DirectMethodHandleDesc.Kind;
>>> import java.lang.constant.DynamicConstantDesc;
>>> import java.lang.constant.MethodHandleDesc;
>>> import java.lang.constant.MethodTypeDesc;
>>> import java.lang.invoke.Intrinsics;
>>> import java.lang.invoke.MethodHandles.Lookup;
>>>
>>> public class ConstantDynamicExample {
>>>    public static long primitiveExample() {
>>>      MethodTypeDesc methodDescriptor = 
>>> MethodTypeDesc.ofDescriptor("(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)J");
>>>      DynamicConstantDesc<Long> dynamicConstant = 
>>> DynamicConstantDesc.of(
>>>          MethodHandleDesc.of(Kind.STATIC, 
>>> ClassDesc.of("jdk12.ConstantDynamicExample"), "bsm", 
>>> methodDescriptor));
>>>      return Intrinsics.ldc(dynamicConstant);
>>>    }
>>>
>>>    private static long bsm(Lookup lookup, String name, Class<?> type) {
>>>      return 3L;
>>>    }
>>>       public static void main(String[] args) {
>>>      System.out.println(primitiveExample());
>>>    }
>>> }
>>>
>>>
>>> Using javap, you can see that the dynamicConstant is folded but the 
>>> number of local variable (locals=2) still count the variables that 
>>> doesn't exist anymore
>>>
>>>   public static long primitiveExample();
>>>      descriptor: ()J
>>>      flags: (0x0009) ACC_PUBLIC, ACC_STATIC
>>>      Code:
>>>        stack=2, locals=2, args_size=0
>>>           0: ldc2_w        #2                  // Dynamic #0:_:J
>>>           3: lreturn
>>>        LineNumberTable:
>>>          line 43: 0
>>>
>>> regards,
>>> Rémi
>>
>



More information about the amber-dev mailing list