RFR 8218142 [lworld] C1 support for array covariance for aaload

Ioi Lam ioi.lam at oracle.com
Thu Jan 31 12:52:44 UTC 2019


When loading from an array declared as Object[], now the C1 code checks 
if the array is flattened. If so, the loading is done via a runtime call.

Here's an example of the generated code

       mov    0x8(%rsi),%eax      ; rsi = array
       mov    $0x800000000,%r12
       add    %r12,%rax           ; rax = array klass
       xor    %r12,%r12           ; why is this here??
       mov    0xc(%rax),%eax      ; layout_helper
       sar    $0x1d,%eax
       cmp    $0xfffffffd,%eax    ; check for Klass::_lh_array_tag_vt_value
       je      L_3                ; slow case

L_1   movslq %edx,%rdx           ; non-flattened load
       mov    0x10(%rsi,%rdx,4),%eax
       shl    $0x3,%rax
L_2   ....

L_3   mov    %rsi,0x8(%rsp)      ; LoadFlattenedArrayStub slow case
       mov    %rdx,(%rsp)
       callq  0x00007fe6489c8840  ; runtime_call load_flattened_array
       jmpq    L_2

The code is pretty big and sub-optimal. My plan is to also get aastore 
working first, and then optimize.

One possibility is to check if the array is actually an Object[] array. 
That should help with the erased generic types.

       mov    0x8(%rsi),%eax      ; rsi = array
+     cmp    $0x00001234, %eax   ; compressed klass for [Ljava/lang/Object;
+     je     L_1                 ; go to non-flattened load
       mov    $0x800000000,%r12

- Ioi

More information about the valhalla-dev mailing list