JDK-8251503 : C2: compiler/intrinsics/klass/CastNullCheckDroppingsTest.java fails with -XX:+AlwaysIncrementalInline
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 16
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2020-08-12
  • Updated: 2022-11-29
  • Resolved: 2022-11-29
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.
Other
tbdResolved
Related Reports
Duplicate :  
Description
----------System.err:(143/5820)----------
events:
[jdk.Deoptimization {
  startTime = 20:43:55.951
  compileId = 685
  compiler = "c2"
  method = jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Object, Object[])
  lineNumber = 43
  bci = 6
  instruction = "invokevirtual"
  reason = "class_check"
  action = "maybe_recompile"
  eventThread = "MainThread" (javaThreadId = 12)
  stackTrace = [
    jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
    java.lang.reflect.Method.invoke(Object, Object[]) line: 564
    compiler.intrinsics.klass.CastNullCheckDroppingsTest.runTest(Method, boolean, Object) line: 306
    compiler.intrinsics.klass.CastNullCheckDroppingsTest.main(String[]) line: 112
    jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Method, Object, Object[])
    ...
  ]
}

, jdk.Deoptimization {
  startTime = 20:43:56.133
  compileId = 685
  compiler = "c2"
  method = jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Object, Object[])
  lineNumber = 43
  bci = 6
  instruction = "invokevirtual"
  reason = "class_check"
  action = "maybe_recompile"
  eventThread = "MainThread" (javaThreadId = 12)
  stackTrace = [
    jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
    java.lang.reflect.Method.invoke(Object, Object[]) line: 564
    compiler.intrinsics.klass.CastNullCheckDroppingsTest.runTest(Method, boolean, Object) line: 306
    compiler.intrinsics.klass.CastNullCheckDroppingsTest.main(String[]) line: 112
    jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Method, Object, Object[])
    ...
  ]
}

, jdk.Deoptimization {
  startTime = 20:43:56.133
  compileId = 685
  compiler = "c2"
  method = jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Object, Object[])
  lineNumber = 43
  bci = 6
  instruction = "invokevirtual"
  reason = "class_check"
  action = "maybe_recompile"
  eventThread = "MainThread" (javaThreadId = 12)
  stackTrace = [
    jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
    java.lang.reflect.Method.invoke(Object, Object[]) line: 564
    compiler.intrinsics.klass.CastNullCheckDroppingsTest.runTest(Method, boolean, Object) line: 306
    compiler.intrinsics.klass.CastNullCheckDroppingsTest.main(String[]) line: 112
    jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Method, Object, Object[])
    ...
  ]
}

, jdk.Deoptimization {
  startTime = 20:43:56.133
  compileId = 685
  compiler = "c2"
  method = jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Object, Object[])
  lineNumber = 43
  bci = 6
  instruction = "invokevirtual"
  reason = "class_check"
  action = "maybe_recompile"
  eventThread = "MainThread" (javaThreadId = 12)
  stackTrace = [
    jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
    java.lang.reflect.Method.invoke(Object, Object[]) line: 564
    compiler.intrinsics.klass.CastNullCheckDroppingsTest.runTest(Method, boolean, Object) line: 306
    compiler.intrinsics.klass.CastNullCheckDroppingsTest.main(String[]) line: 112
    jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Method, Object, Object[])
    ...
  ]
}

, jdk.Deoptimization {
  startTime = 20:43:56.196
  compileId = 887
  compiler = "c2"
  method = jdk.internal.reflect.GeneratedMethodAccessor8.invoke(Object, Object[])
  lineNumber = -1
  bci = 37
  instruction = "checkcast"
  reason = "null_check"
  action = "make_not_entrant"
  eventThread = "MainThread" (javaThreadId = 12)
  stackTrace = [
    jdk.internal.reflect.GeneratedMethodAccessor8.invoke(Object, Object[])
    jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
    java.lang.reflect.Method.invoke(Object, Object[]) line: 564
    compiler.intrinsics.klass.CastNullCheckDroppingsTest.runTest(Method, boolean, Object) line: 316
    compiler.intrinsics.klass.CastNullCheckDroppingsTest.main(String[]) line: 112
    ...
  ]
}

, jdk.Deoptimization {
  startTime = 20:43:56.196
  compileId = 885
  compiler = "c2"
  method = compiler.intrinsics.klass.CastNullCheckDroppingsTest.testMHCast(String)
  lineNumber = 272
  bci = 10
  instruction = "checkcast"
  reason = "speculate_null_check"
  action = "make_not_entrant"
  eventThread = "MainThread" (javaThreadId = 12)
  stackTrace = [
    compiler.intrinsics.klass.CastNullCheckDroppingsTest.testMHCast(String) line: 272
    jdk.internal.reflect.GeneratedMethodAccessor8.invoke(Object, Object[])
    jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
    java.lang.reflect.Method.invoke(Object, Object[]) line: 564
    compiler.intrinsics.klass.CastNullCheckDroppingsTest.runTest(Method, boolean, Object) line: 316
    ...
  ]
}

]
java.lang.AssertionError: compilation must  not  got deoptimized
	at compiler.intrinsics.klass.CastNullCheckDroppingsTest.checkDeoptimization(CastNullCheckDroppingsTest.java:359)
	at compiler.intrinsics.klass.CastNullCheckDroppingsTest.runTest(CastNullCheckDroppingsTest.java:328)
	at compiler.intrinsics.klass.CastNullCheckDroppingsTest.main(CastNullCheckDroppingsTest.java:112)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
	at java.base/java.lang.Thread.run(Thread.java:832)

Comments
Fixed by JDK-8293798.
29-11-2022

I suggest to fix the test for now and add -XX:-AlwaysIncrementalInline unconditionally there.
30-11-2020

The reason this doesn't work is that the null check removal happens only during the inlining in the parser. In post-parse inlining it's impossible to do that because the checkcast has been already expanded and the false arm of the check has a deopt. The only way to make this work is to have a checkcast macro node that it going to be expanded after the post-parse inlining is done. So, since this is not actually a correctness issue but a missing performance optimization for a non-default mode of operation I'm converting this to an RFE that should be done when we do gradual lowering. This may be a good place to start for the inlining work since it seems like it would be a requirement to fix it.
06-11-2020