1 回答

TA貢獻1780條經驗 獲得超1個贊
問題是您workload只調用一次并多次執行該循環;你沒有執行workload很多次;這是你在這里遇到的主要問題。JIT可以優化方法,但這里只有一個循環 - 因此除非OSR處于活動狀態,否則沒有太多需要優化的地方。
這很容易證明,您可以使用以下方法運行您的方法:
-XX:+UnlockDiagnosticVMOptions
-XX:TieredStopAtLevel=1
-XX:+TraceNMethodInstalls // this is to track the compiled methods
-XX:-UseOnStackReplacement
com.so.jit.OSRCompilation // this is the classname I've used
在您將獲得的輸出中,您會看到很多Installing method.
但是,如果您啟用OSR:
-XX:+UnlockDiagnosticVMOptions
-XX:TieredStopAtLevel=1
-XX:+TraceNMethodInstalls // this is to track the compiled methods
-XX:+UseOnStackReplacement
com.so.jit.OSRCompilation // this is the classname I've used
你會得到很多Installing method,而且還有一行:
Installing osr method (1) com.so.jit.OSRCompilation.workload()I @ 5
添加回答
舉報