openj9
openj9 copied to clipboard
Investigate inlined System.nanoTime() on Linux on Z for CRIU
In https://github.com/eclipse-openj9/openj9/issues/15513#issuecomment-1184561051 Younes has briefly summarized how System.nanoTime() is handled on X and Z.
Currently on Linux on Z java_lang_System_nanoTime method is recognized. It emits artificial call to currentTimeMaxPrecisionSymbol with trees that uses the return valus from that call to make adjustment to calculate System.nanoTime(). While generating instructions for the artifical call currentTimeMaxPrecisionSymbol, we generate binary sequence that uses STCKF instruction to get current value of TOD clock and subtracts the TOD clock time of midnight, January 1, 1970 UTC. This difference is fed to the trees generated by the J9Simplifier::convertNanoTime that produces the System.nanoTime() [1].
With the changes in https://github.com/eclipse-openj9/openj9/pull/15609, x86 currently generates instruction to call clock_gettime() directly to read the standard CLOCK_MONOTONIC. In checkpoint mode the JIT then adjusts the value returned by the the call, by subtracting any elapsed time between checkpoint and restore. On Z, for CRIU, it will generate regular JNI calls. I am opening up this issue to investigate and implement work needed for faster version of System.nanoTime() on Z.
[1]. https://github.com/eclipse-openj9/openj9/blob/8cc2ecda50ca3e43f556399f0992af90e61334e9/runtime/compiler/optimizer/J9Simplifier.cpp#L410-L434