Created
February 10, 2024 06:11
-
-
Save navyxliu/2421f3e206a8afc00789d003cb426b6a to your computer and use it in GitHub Desktop.
C2 inliner rejects a callee because of under-profiled subprocedure.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// java -XX:CompileOnly='UnderProfiledSubprocedure.foo' -XX:+PrintInlining -XX:+PrintCompilation -XX:CompileCommand=quiet -Xbatch UnderProfiledSubprocedure | |
import java.util.ArrayList; | |
class UnderProfiledSubprocedure { | |
private static int ODD = 100; | |
public void foo(boolean cond) { | |
var x = new ArrayList<Integer>(); | |
if (cond) { // the branch is only taken by ODD | |
x.add(0); // ArrayList::add(E) is the subprocedure. it will call ArrayList::add(E, Object[], int) | |
// when C2 compile method(), the methoddata of ArrayList::add(E) has not been mature yet. | |
// refer to | |
} | |
return; | |
} | |
public static void main(String[] args) { | |
var kase = new UnderProfiledSubprocedure(); | |
for (int iterations = 0; iterations <= 1_000_000; ++iterations) { | |
boolean cond = (iterations % ODD) == 0; | |
kase.foo(cond); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
here is inline tree.
C2 refuses to inline ArrayList::add(23 bytes) because the methoddata of ArrayList::add(25 bytes) has not mature when C2 compiles 'UnderProfiledSubprocedure::foo'.