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

[lworld] C1's delayed load indexed optimization sets incorrect type

XMLWordPrintable

      inline class MyValue1 {
          int[] array = new int[1];
      }

      class Test {

        void test1(MyValue1[] array) {
          array[0].array[0] = 0;
      /*
             2: aaload
             3: getfield
             6: iconst_0
             7: iconst_0
             8: iastore
      */
        }

        public static void main(String[] args) {
          Test t = new Test();
          MyValue1[] array = {new MyValue1()};
          for (int i = 0; i < 10_000; ++i)
            t.test1(array);
        }
      }

      The problem is that the aaload is delayed until getfield which then sets the type of the LoadIndexed to int[] but the exact_type/declared_type are not updated and still return MyValue1:
                  pending_load_indexed()->update(field, offset - field->holder()->as_inline_klass()->first_field_offset());
                  LoadIndexed* li = pending_load_indexed()->load_instr();
                  li->set_type(type);

      We assert at iastore because the type is not an array type.


      # Internal Error (/oracle/valhalla/open/src/hotspot/share/ci/ciMetadata.hpp:96), pid=1207075, tid=1207084
      # assert(is_array_klass()) failed: bad cast

      Current CompileTask:
      C1: 304 398 2 Test::test1 (10 bytes)

      Stack: [0x00007fac9f2ff000,0x00007fac9f400000], sp=0x00007fac9f3fdd80, free space=1019k
      Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
      V [libjvm.so+0x74cf6c] GraphBuilder::store_indexed(BasicType)+0x76c
      V [libjvm.so+0x75559f] GraphBuilder::iterate_bytecodes_for_block(int)+0x20ff
      V [libjvm.so+0x755959] GraphBuilder::iterate_all_blocks(bool)+0x89
      V [libjvm.so+0x756b3f] GraphBuilder::GraphBuilder(Compilation*, IRScope*)+0x52f
      V [libjvm.so+0x7673b3] IR::IR(Compilation*, ciMethod*, int)+0x663
      V [libjvm.so+0x724921] Compilation::build_hir() [clone .part.0]+0x261
      V [libjvm.so+0x72933c] Compilation::compile_java_method()+0x1bc
      V [libjvm.so+0x72a157] Compilation::compile_method()+0x1d7
      V [libjvm.so+0x72abc6] Compilation::Compilation(AbstractCompiler*, ciEnv*, ciMethod*, int, BufferBlob*, bool, DirectiveSet*)+0x3c6
      V [libjvm.so+0x72c043] Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x1a3
      V [libjvm.so+0xa61848] CompileBroker::invoke_compiler_on_method(CompileTask*)+0xe08
      V [libjvm.so+0xa62398] CompileBroker::compiler_thread_loop()+0x5a8
      V [libjvm.so+0x198e5f6] JavaThread::thread_main_inner()+0x256
      V [libjvm.so+0x1994f70] Thread::call_run()+0x100
      V [libjvm.so+0x164f8d6] thread_native_entry(Thread*)+0x116

            thartmann Tobias Hartmann
            thartmann Tobias Hartmann
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: