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

Make C2 more robust in the face of hash collisions during GVN

XMLWordPrintable

      Working on JDK-8321204, I noticed that there are issues in C2 when Node::hash returns 0 == Node::NO_HASH, which can happen in extremely rare cases but should be harmless:
      https://github.com/openjdk/jdk/blob/f26e4308992d989d71e7fbfaa3feb95f0ea17c06/src/hotspot/share/opto/node.hpp#L1114-L1118

      [~dlong] suggested to adjust the hash method to never return 0: https://github.com/openjdk/jdk/pull/18647#issuecomment-2040642019

      We should investigate that.

      Running some testing with attached patch that always returns 0 triggers massive failures. Although some of them are surely false positives since the patch basically disables GVN, we should investigate if there are real issues. Failures include but are not limited to:

      # Internal Error (/workspace/open/src/hotspot/share/opto/escape.cpp:2113), pid=34319, tid=34737
      # assert(base == null_obj) failed: only null ptr base expected here

      Stack: [0x00007f8a051f2000,0x00007f8a052f2000], sp=0x00007f8a052ecb50, free space=1002k
      Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
      V [libjvm.so+0xbb4df4] ConnectionGraph::find_field_value(FieldNode*)+0x114 (escape.cpp:2113)
      V [libjvm.so+0xbc477d] ConnectionGraph::complete_connection_graph(GrowableArray<PointsToNode*>&, GrowableArray<JavaObjectNode*>&, GrowableArray<JavaObjectNode*>&, GrowableArray<FieldNode*>&)+0x19d (escape.cpp:1812)
      V [libjvm.so+0xbc7255] ConnectionGraph::compute_escape()+0x1e85 (escape.cpp:283)
      V [libjvm.so+0xbc7f91] ConnectionGraph::do_analysis(Compile*, PhaseIterGVN*)+0xf1 (escape.cpp:117)
      V [libjvm.so+0x9e9c7a] Compile::Optimize()+0x63a (compile.cpp:2342)
      V [libjvm.so+0x9edad0] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1b50 (compile.cpp:861)
      V [libjvm.so+0x841a45] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x1d5 (c2compiler.cpp:142)
      V [libjvm.so+0x9f98d8] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x928 (compileBroker.cpp:2310)
      V [libjvm.so+0x9fa568] CompileBroker::compiler_thread_loop()+0x478 (compileBroker.cpp:1969)
      V [libjvm.so+0xeab86c] JavaThread::thread_main_inner()+0xcc (javaThread.cpp:759)
      V [libjvm.so+0x17ab836] Thread::call_run()+0xb6 (thread.cpp:221)
      V [libjvm.so+0x14b0867] thread_native_entry(Thread*)+0x127 (os_linux.cpp:853)

      # Internal Error (/workspace/open/src/hotspot/share/opto/node.hpp:412), pid=2893220, tid=2893234
      # assert(_outcnt==1) failed: not unique

      Stack: [0x00007f4a23cfe000,0x00007f4a23dfe000], sp=0x00007f4a23df9230, free space=1004k
      Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
      V [libjvm.so+0x12d67aa] PhaseMacroExpand::expand_subtypecheck_node(SubTypeCheckNode*)+0xa9a (node.hpp:412)
      V [libjvm.so+0x12dca83] PhaseMacroExpand::expand_macro_nodes()+0xa83 (macro.cpp:2588)
      V [libjvm.so+0x9ea548] Compile::Optimize()+0xf08 (compile.cpp:2456)
      V [libjvm.so+0x9edad0] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1b50 (compile.cpp:861)
      V [libjvm.so+0x841a45] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x1d5 (c2compiler.cpp:142)
      V [libjvm.so+0x9f98d8] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x928 (compileBroker.cpp:2310)
      V [libjvm.so+0x9fa568] CompileBroker::compiler_thread_loop()+0x478 (compileBroker.cpp:1969)
      V [libjvm.so+0xeab86c] JavaThread::thread_main_inner()+0xcc (javaThread.cpp:759)
      V [libjvm.so+0x17ab836] Thread::call_run()+0xb6 (thread.cpp:221)
      V [libjvm.so+0x14b0867] thread_native_entry(Thread*)+0x127 (os_linux.cpp:853)

      # Internal Error (/workspace/open/src/hotspot/share/opto/compile.cpp:3326), pid=3376095, tid=3376135
      # assert(!addp->is_AddP() || addp->in(AddPNode::Base)->is_top() || addp->in(AddPNode::Base) == n->in(AddPNode::Base)) failed: Base pointers must match (addp 932)

      Stack: [0x00007f501d010000,0x00007f501d110000], sp=0x00007f501d10ade0, free space=1003k
      Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
      V [libjvm.so+0x9db841] Compile::final_graph_reshaping_main_switch(Node*, Final_Reshape_Counts&, unsigned int, Unique_Node_List&)+0x1531 (compile.cpp:3326)
      V [libjvm.so+0x9dc6ef] Compile::final_graph_reshaping_impl(Node*, Final_Reshape_Counts&, Unique_Node_List&) [clone .part.0]+0x15f (compile.cpp:3172)
      V [libjvm.so+0x9dd004] Compile::final_graph_reshaping_walk(Node_Stack&, Node*, Final_Reshape_Counts&, Unique_Node_List&)+0x174 (compile.cpp:3121)
      V [libjvm.so+0x9e888d] Compile::final_graph_reshaping()+0x54d (compile.cpp:4030)
      V [libjvm.so+0x9ea6fd] Compile::Optimize()+0x10bd (compile.cpp:2503)
      V [libjvm.so+0x9edad0] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1b50 (compile.cpp:861)
      V [libjvm.so+0x841a45] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x1d5 (c2compiler.cpp:142)
      V [libjvm.so+0x9f98d8] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x928 (compileBroker.cpp:2310)
      V [libjvm.so+0x9fa568] CompileBroker::compiler_thread_loop()+0x478 (compileBroker.cpp:1969)
      V [libjvm.so+0xeab86c] JavaThread::thread_main_inner()+0xcc (javaThread.cpp:759)
      V [libjvm.so+0x17ab836] Thread::call_run()+0xb6 (thread.cpp:221)
      V [libjvm.so+0x14b0867] thread_native_entry(Thread*)+0x127 (os_linux.cpp:853)

      # Internal Error (/workspace/open/src/hotspot/share/compiler/compileBroker.cpp:2118), pid=524626, tid=524650
      # fatal error: Not compilable at tier 4: failed spill-split-recycle sanity check

      Stack: [0x00007fb2b37f9000,0x00007fb2b38f9000], sp=0x00007fb2b38f7470, free space=1017k
      Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
      V [libjvm.so+0x9f4aab] CompileBroker::handle_compile_error(CompilerThread*, CompileTask*, ciEnv*, int, char const*)+0x6b (compileBroker.cpp:2118)
      V [libjvm.so+0x9f92bb] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x30b (compileBroker.cpp:2344)
      V [libjvm.so+0x9fa568] CompileBroker::compiler_thread_loop()+0x478 (compileBroker.cpp:1969)
      V [libjvm.so+0xeab86c] JavaThread::thread_main_inner()+0xcc (javaThread.cpp:759)
      V [libjvm.so+0x17ab836] Thread::call_run()+0xb6 (thread.cpp:221)
      V [libjvm.so+0x14b0867] thread_native_entry(Thread*)+0x127 (os_linux.cpp:853)

      # Internal Error (/workspace/open/src/hotspot/cpu/x86/assembler_x86.cpp:11719), pid=24569, tid=24587
      # assert(((!attributes->uses_vl()) || (attributes->get_vector_len() == AVX_512bit) || (!_legacy_mode_vl) || (attributes->is_legacy_mode()))) failed: XMM register should be 0-15

      Stack: [0x00007f5e24cc8000,0x00007f5e24dc8000], sp=0x00007f5e24dc3840, free space=1006k
      Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
      V [libjvm.so+0x645c6b] Assembler::vex_prefix_and_encode(int, int, int, Assembler::VexSimdPrefix, Assembler::VexOpcode, InstructionAttr*)+0x28b (assembler_x86.cpp:11719)
      V [libjvm.so+0x65d093] Assembler::simd_prefix_and_encode(XMMRegister, XMMRegister, XMMRegister, Assembler::VexSimdPrefix, Assembler::VexOpcode, InstructionAttr*) [clone .constprop.0]+0x113 (assembler_x86.cpp:11766)
      V [libjvm.so+0x661157] Assembler::vpmovsxbd(XMMRegister, XMMRegister, int)+0x77 (assembler_x86.cpp:5024)
      V [libjvm.so+0x828854] C2_MacroAssembler::vconvert_b2x(BasicType, XMMRegister, XMMRegister, int)+0x84 (c2_MacroAssembler_x86.cpp:2809)
      V [libjvm.so+0x40f84b] vcastBtoXNode::emit(CodeBuffer&, PhaseRegAlloc*) const+0x10b (x86.ad:7003)
      V [libjvm.so+0x14d1336] PhaseOutput::scratch_emit_size(Node const*)+0x376 (output.cpp:3366)
      V [libjvm.so+0x14c9a7a] PhaseOutput::shorten_branches(unsigned int*)+0x34a (output.cpp:544)
      V [libjvm.so+0x14db3ca] PhaseOutput::Output()+0xa1a (output.cpp:345)
      V [libjvm.so+0x9eb03c] Compile::Code_Gen()+0x4ac (compile.cpp:3031)
      V [libjvm.so+0x9edbb6] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1c36 (compile.cpp:894)
      V [libjvm.so+0x841a45] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x1d5 (c2compiler.cpp:142)
      V [libjvm.so+0x9f98d8] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x928 (compileBroker.cpp:2310)
      V [libjvm.so+0x9fa568] CompileBroker::compiler_thread_loop()+0x478 (compileBroker.cpp:1969)
      V [libjvm.so+0xeab86c] JavaThread::thread_main_inner()+0xcc (javaThread.cpp:759)
      V [libjvm.so+0x17ab836] Thread::call_run()+0xb6 (thread.cpp:221)
      V [libjvm.so+0x14b0867] thread_native_entry(Thread*)+0x127 (os_linux.cpp:853)

      We might want to add a stress flag to trigger this and similar hash collisions more often.

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

              Created:
              Updated: