box and val (c2 crash)

Srikanth srikanth.adayapalam at oracle.com
Tue Jan 29 10:35:23 UTC 2019



On 28/01/19 9:22 PM, Srikanth wrote:
> Thanks, This got reported internally too, but this is not due to these 
> patches, but very likely
> an inadvertent side effect of array covariance related change that 
> went in last week.
>
> I am already working on it and expect to close it tomorrow. I will 
> also make sure to test with
> the snippet you have provided.

Hi Remi,

With https://bugs.openjdk.java.net/browse/JDK-8217966 and
https://bugs.openjdk.java.net/browse/JDK-8217958 resolved

I think the set of problems you had reported against valhalla javac are 
all resolved.

Thanks for confirming. If you run into any issues and if my 
understanding that all your
issues with valhalla javac are resolved is incorrect, let me know :)

Thanks for all the testing cycles you are contributing.

Thanks,
Srikanth
>
> Thanks
> Srikanth
>
> On 28/01/19 8:31 PM, Remi Forax wrote:
>> I believe those patchs (or maybe one before) has introduced a regression
>>
>> This code doesn't compile anymore:
>> public class Regression {
>>    static value class Entry<E> {
>>      private final int value;
>>
>>      public Entry(int value) {
>>        this.value = value;
>>      }
>>           public static <E> Entry<E>[] of() {
>>        return (Entry<E>[])new Entry<?>[0];
>>      }
>>    }
>>       public static void main(String[] args) {
>>      var entry = Entry.of();
>>    }
>> }
>>
>> ./src/main/java/fr.umlv.valuetype/fr/umlv/valuetype/Regression.java:12: 
>> error: incompatible types: Entry<?>[] cannot be converted to Entry<E>[]
>>        return (Entry<E>[])new Entry<?>[0];
>>                           ^
>>    where E is a type-variable:
>>      E extends Object declared in method <E>of()
>>
>> Rémi
>>
>> ----- Mail original -----
>>> De: "Srikanth" <srikanth.adayapalam at oracle.com>
>>> À: "valhalla-dev" <valhalla-dev at openjdk.java.net>
>>> Envoyé: Lundi 28 Janvier 2019 13:03:29
>>> Objet: Re: box and val (c2 crash)
>>> On 07/01/19 3:07 PM, Srikanth wrote:
>>>> Hi Remi,
>>>>
>>>> For the observation about javac, I will take a look and follow up.
>>> Hi Remi,
>>>
>>> The two issues reported in this mail are fixed via:
>>>
>>> https://bugs.openjdk.java.net/browse/JDK-8217875 and
>>> https://bugs.openjdk.java.net/browse/JDK-8217872
>>>
>>> Let me know if you continue to see any problems with these constructs.
>>>
>>> Thanks!
>>> Srikanth
>>>
>>>> Thanks!
>>>> Srikanth
>>>>
>>>> On 03/01/19 8:44 PM, Remi Forax wrote:
>>>>> Now, i've tried to play with the .box/.val trying to implement the
>>>>> clojure Cursor protocol,
>>>>> which iterate like it's an abstract linked list, so at each step
>>>>> either you return a new Cursor (a value type) or null at the end
>>>>> (which seems to be a good test for a nullable value type).
>>>>>
>>>>> The following code compiles !
>>>>> I had to had the fix method because the compier refuse to find any
>>>>> methods on Cursor.box and
>>>>>     Cursor.box boxed = ...
>>>>>     ((Cursor)boxed).next
>>>>> doesn't compile too.
>>>>>
>>>>> If you try to execute the code, it crashes the VM (in the C2 compiler
>>>>> thread it seems)
>>>>>
>>>>> Current CompileTask:
>>>>> C2:    338  119 fr.umlv.valuetype.perf.TupleLoopBenchMark::sum (46
>>>>> bytes)
>>>>>
>>>>> Stack: [0x00007ff4c0a37000,0x00007ff4c0b38000],
>>>>> sp=0x00007ff4c0b34700,  free space=1013k
>>>>> Native frames: (J=compiled Java code, A=aot compiled Java code,
>>>>> j=interpreted, Vv=VM code, C=native code)
>>>>> V  [libjvm.so+0xe19ed6]  VMError::report_and_die(int, char const*,
>>>>> char const*, __va_list_tag*, Thread*, unsigned char*, void*, void*,
>>>>> char const*, int, unsigned long)+0x186
>>>>> V  [libjvm.so+0xe1ac87]  VMError::report_and_die(Thread*, void*, char
>>>>> const*, int, char const*, char const*, __va_list_tag*)+0x47
>>>>> V  [libjvm.so+0x67a68e]  report_vm_error(char const*, int, char
>>>>> const*, char const*, ...) [clone .constprop.51]+0xee
>>>>> V  [libjvm.so+0xdbc39e]  TypePtr::xmeet_helper(Type const*) 
>>>>> const+0x5e
>>>>> V  [libjvm.so+0xdb80e0]  TypePtr::xmeet(Type const*) const+0x10
>>>>> V  [libjvm.so+0x5564c1]  PhiNode::Value(PhaseGVN*) const+0x131
>>>>> V  [libjvm.so+0xc38986] PhaseGVN::transform_no_reclaim(Node*)+0x86
>>>>> V  [libjvm.so+0xc00c2d]  Parse::do_exits()+0x4bd
>>>>> V  [libjvm.so+0xc05c16]  Parse::Parse(JVMState*, ciMethod*, 
>>>>> float)+0xab6
>>>>> V  [libjvm.so+0x53da48] ParseGenerator::generate(JVMState*)+0x88
>>>>> V  [libjvm.so+0x70f87d]  Parse::do_call()+0x2dd
>>>>> V  [libjvm.so+0xc15998]  Parse::do_one_bytecode()+0x32e8
>>>>> V  [libjvm.so+0xc03077]  Parse::do_one_block()+0x197
>>>>> V  [libjvm.so+0xc034e2]  Parse::do_all_blocks()+0x102
>>>>> V  [libjvm.so+0xc05bd0]  Parse::Parse(JVMState*, ciMethod*, 
>>>>> float)+0xa70
>>>>> V  [libjvm.so+0x53da48] ParseGenerator::generate(JVMState*)+0x88
>>>>> V  [libjvm.so+0x61bab8]  Compile::Compile(ciEnv*, C2Compiler*,
>>>>> ciMethod*, int, bool, bool, bool, DirectiveSet*)+0xe98
>>>>> V  [libjvm.so+0x53cf46] C2Compiler::compile_method(ciEnv*,
>>>>> ciMethod*, int, DirectiveSet*)+0xe6
>>>>> V  [libjvm.so+0x624182]
>>>>> CompileBroker::invoke_compiler_on_method(CompileTask*)+0x3a2
>>>>> V  [libjvm.so+0x6255c8] CompileBroker::compiler_thread_loop()+0x608
>>>>> V  [libjvm.so+0xda42f8] JavaThread::thread_main_inner()+0xf8
>>>>> V  [libjvm.so+0xda0fc1]  Thread::call_run()+0x171
>>>>> V  [libjvm.so+0xbd5598]  thread_native_entry(Thread*)+0xf8
>>>>>
>>>>>
>>>>> Rémi
>>>>>
>>>>> ---
>>>>>     static value class Tuple {
>>>>>       private final int index;
>>>>>       private final int element;
>>>>>                 private Tuple(int index, int element) {
>>>>>         this.index = index;
>>>>>         this.element = element;
>>>>>       }
>>>>>     }
>>>>>        static value class Cursor {
>>>>>       private final int[] array;
>>>>>       private final int index;
>>>>>            private Cursor(int[] array, int index) {
>>>>>         this.array = array;
>>>>>         this.index = index;
>>>>>       }
>>>>>            Tuple current() {
>>>>>         return new Tuple(index, array[index]);
>>>>>       }
>>>>>            Cursor.box next() {
>>>>>         if (index + 1 == array.length) {
>>>>>           return null;
>>>>>         }
>>>>>         return new Cursor(array, index + 1);
>>>>>       }
>>>>>     }
>>>>>        private static Cursor.box indexedElements(int[] array) {
>>>>>       if (array.length == 0) {
>>>>>         return null;
>>>>>       }
>>>>>       return new Cursor(array, 0);
>>>>>     }
>>>>>        private static Cursor fix(Cursor.box cursor) {
>>>>>       return cursor;
>>>>>     }
>>>>>        @Benchmark
>>>>>     public int sum() {
>>>>>       int sum = 0;
>>>>>       for(Cursor.box cursor = indexedElements(ARRAY); cursor != null;
>>>>> cursor = fix(cursor).next()) {
>>>>>         Tuple tuple = fix(cursor).current();
>>>>>         sum += tuple.index + tuple.element;
>>>>>       }
>>>>>       return sum;
>>>>>     }
>>>>>
>




More information about the valhalla-dev mailing list