Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8207219

[lworld] C2 should not invoke a method if its signature has inconsistent use of ValueType

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Not an Issue
    • Affects Version/s: repo-valhalla
    • Fix Version/s: repo-valhalla
    • Component/s: hotspot
    • Labels:

      Description

      Let's assume:

      Class X has Point in its ValueTypes attribute.
      Class Y does NOT have Point in its ValueTypes attribute.
      X.x calls Y.y

      If C2 decides to inline Y.y (directly or indirectly) into X.x, it must check that if Y.y invokes any method, the signature of the callee method must have consistent use of ValueType as the class X.

      For an example, see http://cr.openjdk.java.net/~iklam/valhalla/tests/8207219/

      [1] Update valhalla repo to http://hg.openjdk.java.net/valhalla/valhalla/rev/208e3da0bbc5
      [2] Apply this patch http://cr.openjdk.java.net/~iklam/valhalla/8206140_lworld_null_check_in_callee.v04/
      [3] Run the above test case with a fastdebug VM

          make JAVA=... JAVAC=... run

      With the 8206140 patch, C2 assumes that no callee method can return a NULL ValueType into a compiled caller method. Thus, when the compiled method calls Bar.bar(), it assumes that the returned value is non-NULL.

      However, as far as Bar.bar is concerned, it is not returning a ValueType, so it does not deoptimize its caller frame when NULL is returned.

      As a result, we crash here:

      # A fatal error has been detected by the Java Runtime Environment:
      #
      # Internal Error (/home/iklam/jdk/valhalla/open/src/hotspot/cpu/x86/macroAssembler_x86.cpp:891), pid=16292, tid=16293
      # assert(false) failed: DEBUG MESSAGE: null oop passed to encode_heap_oop_not_null2
      #


       0x00007fcd54d5962f: callq 0x00007fcd54c52ea0 ; ImmutableOopMap{}
                                                      ;*invokestatic bar {reexecute=0 rethrow=0 return_oop=1 return_vt=0}
                                                      ; - Foo::foo@0 (line 6)
                                                      ; - VT::crasher@0 (line 19)
                                                      ; {static_call}
       ;; B2: # B12 B3 <- B1 Freq: 0.99998

        0x00007fcd54d59634: mov %rax,%rbx
        0x00007fcd54d59637: mov $0x451099210,%rbp ; {oop(a 'java/lang/Class'{0x0000000451099210} = 'Foo')}
        0x00007fcd54d59641: cmpb $0x0,0x30(%r15)
        0x00007fcd54d59646: jne 0x00007fcd54d5987b
       ;; B3: # B11 B4 <- B15 B14 B12 B2 Freq: 0.99998

        0x00007fcd54d5964c: mov %rbp,%r10
        0x00007fcd54d5964f: push %r10
        0x00007fcd54d59651: cmp 0x13913df0(%rip),%r12 # 0x00007fcd6866d448
                                                      ; {external_word}
        0x00007fcd54d59658: je 0x00007fcd54d596d5
       ;; MacroAssembler::encode_heap_oop_not_null2: heap base corrupted? <<<<< HERE
        0x00007fcd54d5965e: mov %rsp,-0x28(%rsp)
        0x00007fcd54d59663: sub $0x80,%rsp
        0x00007fcd54d5966a: mov %rax,0x78(%rsp)
        0x00007fcd54d5966f: mov %rcx,0x70(%rsp)
        0x00007fcd54d59674: mov %rdx,0x68(%rsp)
        0x00007fcd54d59679: mov %rbx,0x60(%rsp)
        0x00007fcd54d5967e: mov %rbp,0x50(%rsp)
        0x00007fcd54d59683: mov %rsi,0x48(%rsp)
        0x00007fcd54d59688: mov %rdi,0x40(%rsp)
        0x00007fcd54d5968d: mov %r8,0x38(%rsp)
        0x00007fcd54d59692: mov %r9,0x30(%rsp)
        0x00007fcd54d59697: mov %r10,0x28(%rsp)
        0x00007fcd54d5969c: mov %r11,0x20(%rsp)
        0x00007fcd54d596a1: mov %r12,0x18(%rsp)
        0x00007fcd54d596a6: mov %r13,0x10(%rsp)
        0x00007fcd54d596ab: mov %r14,0x8(%rsp)
        0x00007fcd54d596b0: mov %r15,(%rsp)
        0x00007fcd54d596b4: mov $0x7fcd68112020,%rdi ; {external_word}
        0x00007fcd54d596be: mov $0x7fcd54d5965e,%rsi ; {internal_word}
        0x00007fcd54d596c8: mov %rsp,%rdx
        0x00007fcd54d596cb: and $0xfffffffffffffff0,%rsp
        0x00007fcd54d596cf: callq 0x00007fcd679aa090 ; {runtime_call MacroAssembler::debug64(char*, long, long*)}
        0x00007fcd54d596d4: hlt

        Attachments

        1. NonVT.java
          0.2 kB
        2. VT.java
          0.6 kB

          Issue Links

            Activity

              People

              • Assignee:
                iklam Ioi Lam
                Reporter:
                iklam Ioi Lam
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: