JDK-8211232 : GraphKit::make_runtime_call() sometimes attaches wrong memory state to call
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11,12
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-09-27
  • Updated: 2019-10-04
  • Resolved: 2018-10-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 12 Other
11.0.5Fixed 12 b15Fixed openjdk8u232Fixed
Description
This came up in shenandoah testing with XX:+ExtendedDTraceProbes.

make_runtime_call() is called through make_dtrace_method_exit() from Parse::return_current(). Memory state at this point is:

 137    Phi     ===  135 _ _  91  [[ 74  141  145  150  152  162  166  168  179  182  187  193  202  211  216  225  228  237  242  258  266  274  282 ]]  #memory  Memory: @BotPTR *+bot, idx=Bot; !jvms: IdentityHashMap::put @ bci:24
 141    MergeMem        === _  1  137  1  1  279  1  275  282  [[ 142 ]]  { - - N279:java/lang/Object+-8 * - N275:narrowoop: java/lang/Object *[int:>=0]+-8 * N282:narrowoop: java/lang/Object *[int:>=0]+any * [narrow] }  Memory: @BotPTR *+bot, idx=Bot; !jvms: IdentityHashMap::put @ bci:24

The Phi is a loop phi so not all its inputs are set yet. The following code in GraphKit::make_runtime_call():
    assert(!wide_out, "narrow in => narrow out");
    Node* narrow_mem = memory(adr_type);
    prev_mem = reset_memory();
    map()->set_memory(narrow_mem);

set the entire memory state to the phi. Next in  GraphKit::set_predefined_input_for_runtime_call():

  Node* memory = reset_memory();

causes the current memory state (the Phi) to be transformed which the GVN transforms to:
 91     Phi     ===  89 _ _  73  [[ 137  100  103  105  113  116  118  126  129  131 ]]  #memory  Memory: @BotPTR *+bot, idx=Bot; !jvms: IdentityHashMap::put @ bci:24

the out of loop memory state and so the wrong state.
Comments
Fix Request (11u and 8u): change applies cleanly. Testing with tier1. Change fixes long standing issues in c2. This change was pushed to the development branch in october 2018 and there was no follow up bugs that I'm aware of.
21-08-2019

Testing passed.
09-10-2018

http://cr.openjdk.java.net/~roland/8211232/webrev.00/
08-10-2018

ILW = H(possible crash due wrong memory state attached to call) L(rare) M(disable compilation) = P3
28-09-2018