question about PrintOptoStatistics atomicity

Liu, Xin xxinliu at amazon.com
Wed Jul 15 15:31:56 UTC 2020


Hi,


I have a question about -XX:+PrintOptoStatistics in c2_globals.hpp.

It dumps many internal counters in different C2 phases.  I found those counters are all static fields.

eg.

http://hg.openjdk.java.net/jdk/jdk/file/4b9ced2b948c/src/hotspot/share/opto/chaitin.cpp#l2297

http://hg.openjdk.java.net/jdk/jdk/file/4b9ced2b948c/src/hotspot/share/opto/phaseX.hpp#l599


I notice that all setters of those fields are not atomic. IMHO, hotspot may has more than one c2-compiler-threads running at the same time.

How does hotspot guarantee those fields are thread-safe? or the flag intends to do statistics in single-thread mode by design?


If those counters are not atomic, shall we connect this flag to CICompilerCount?

I think we can constrain the number of c2-compiler-thread to 1 if user set PrintOptoStatistics. Does it make sense?


thanks,

--lx



More information about the hotspot-compiler-dev mailing list