亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

標準 JIT 編譯而不是 HotSpot 中的 On Stack Replacement

標準 JIT 編譯而不是 HotSpot 中的 On Stack Replacement

RISEBY 2022-11-30 11:23:55
我試圖在 Java HotSpot VM 中使用 C1 查看標準 JIT 編譯而不是 OSR 的結果。我已經關閉了 OSR using-XX:-UseOnStackReplacement并使用-XX:TieredStopAtLevel=1. 但是現在我的方法根本沒有被編譯。我打開了 Print Compilation,如果我讓它使用 OSR,它會很好地記錄編譯。此外,在沒有 OSR 的情況下,我的所有斷點都不會在 C1 文件中命中。我正在使用一個非常簡單的代碼片段來測試這個class Demo {  public static void main(String[] args) {      int a = workload();    System.out.println("Calculated answer is: " + a);  }  private static int workload() {    int a = 14;    for (int i = 0; i<100000; i++) {      a = a + i;    }    return a;  }}
查看完整描述

1 回答

?
慕神8447489

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


查看完整回答
反對 回復 2022-11-30
  • 1 回答
  • 0 關注
  • 109 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號