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

[lworld] C2: Calling clone() on non-allocated inline types fails with "Should have been buffered"

XMLWordPrintable

      JDK-8332243 enables value type classes to implement Clonable. We currently miss to handle the case when we call clone() on a non-allocated inline type. We set up a call to arraycopy and then fail with an assertion because we pass a non-allocated InlineTypeNode while it should be buffered.

      The fix is to simply return the identity-less inline type since cloning should be a nop.

      To reproduce:
      Run runtime/valhalla/inlinetypes/TestCloneableValue.java with -Xcomp -XX:CompileOnly=runtime*::clone

      #
      # A fatal error has been detected by the Java Runtime Environment:
      #
      # Internal Error (/opt/mach5/mesos/work_dir/slaves/a4a7850a-7c35-410a-b879-d77fbb2f6087-S14922/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/2c7d7894-3d91-4fe6-a01b-942a6c58fa90/runs/8aea6d57-6802-4580-bb44-112862370d80/workspace/open/src/hotspot/share/opto/compile.cpp:2074), pid=2254611, tid=2254627
      # assert(false) failed: Should have been buffered
      #
      # JRE version: Java(TM) SE Runtime Environment (23.0+1) (fastdebug build 23-valhalla+1-53)
      # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 23-valhalla+1-53, compiled mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
      # Problematic frame:
      # V [libjvm.so+0xa1efa1] Compile::process_inline_types(PhaseIterGVN&, bool)+0x751
      ...........
      Current CompileTask:
      C2:205 68 b 4 runtime.valhalla.inlinetypes.TestCloneableValue$SimpleValue::clone (5 bytes)

      Stack: [0x00007aa250061000,0x00007aa250161000], sp=0x00007aa25015c1b0, free space=1004k
      Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
      V [libjvm.so+0xa1efa1] Compile::process_inline_types(PhaseIterGVN&, bool)+0x751 (compile.cpp:2074)
      V [libjvm.so+0xa37163] Compile::Optimize()+0x1153
      V [libjvm.so+0xa3a834] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1cc4
      V [libjvm.so+0x878ae2] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x1f2
      V [libjvm.so+0xa4669c] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x92c
      V [libjvm.so+0xa47318] CompileBroker::compiler_thread_loop()+0x458
      V [libjvm.so+0xf4903c] JavaThread::thread_main_inner()+0xcc
      V [libjvm.so+0x1874d36] Thread::call_run()+0xb6
      V [libjvm.so+0x155f127] thread_native_entry(Thread*)+0x127

            chagedorn Christian Hagedorn
            chagedorn Christian Hagedorn
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: