LogCompilation后JIT输出文件格式解析

https://wiki.openjdk.org/display/HotSpot/LogCompilation+overview
https://spotcodereviews.com/articles/optimization/2020/12/23/why-does-the-jit-continually-recompile-the-same-method.html

  • task_queued
    count表示总共执行次数,iicount表示解释器执行次数
<task_queued 
compile_id='105' 
method='org/apache/skywalking/apm/dependencies/net/bytebuddy/matcher/StringMatcher matches (Ljava/lang/Object;)Z' 
bytes='9' 
count='34176' iicount='34176' stamp='6.475' comment='tiered' hot_count='34176'/>

  • nmethod节点
    表示编译完成
<nmethod compile_id='105' 
compiler='C2' 
level='4' entry='0x00007fe8bc467060' 
size='736' address='0x00007fe8bc466f10' 
relocation_offset='296' insts_offset='336' stub_offset='496' scopes_data_offset='544' scopes_pcs_offset='608' dependencies_offset='688' handler_table_offset='696' nul_chk_table_offset='720' 
oops_offset='520' method='org/apache/skywalking/apm/dependencies/net/bytebuddy/matcher/StringMatcher matches (Ljava/lang/Object;)Z' bytes='9' count='34523' iicount='34523' stamp='6.497'/>
  • uncommon_trap节点
    如果编译器认为某段代码执行不够comon,放弃编译,会产生该节点。也会在执行中被抛出,交给解释器执行。其中的bci节点表示是在哪里发生的该问题。
<uncommon_trap thread='140538428724992' reason='null_check' action='none' compile_id='60889' compiler='C2' level='4' count='-1' state='null_check recompiled' stamp='208.678'>
<jvms bci='1722' method='xxx;' bytes='3588' count='73261' backedge_count='1169266' iicount='73261' decompiles='3' null_check_traps='-1' unstable_if_traps='1' overflow_traps='54218'/>
</uncommon_trap>

对于reason,有以下枚举

Reason_null_check,            // saw unexpected null or zero divisor (@bci)
Reason_null_assert,           // saw unexpected non-null or non-zero (@bci)
Reason_range_check,           // saw unexpected array index (@bci)
Reason_class_check,           // saw unexpected object class (@bci)
Reason_array_check,           // saw unexpected array class (aastore @bci)
Reason_intrinsic,             // saw unexpected operand to intrinsic (@bci)
Reason_bimorphic,             // saw unexpected object class in bimorphic 
Reason_profile_predicate,     // compiler generated predicate moved from
                              // frequent branch in a loop failed

Reason_unloaded,              // unloaded class or constant pool entry
Reason_uninitialized,         // bad class state (uninitialized)
Reason_unreached,             // code is not reached, compiler
Reason_unhandled,             // arbitrary compiler limitation
Reason_constraint,            // arbitrary runtime constraint violated
Reason_div0_check,            // a null_check due to division by zero
Reason_age,                   // nmethod too old; tier threshold reached
Reason_predicate,             // compiler generated predicate failed
Reason_loop_limit_check,      // compiler generated loop limits check
                              // failed
Reason_speculate_class_check, // saw unexpected object class from type
                              // speculation
Reason_speculate_null_check,  // saw unexpected null from type speculation
Reason_speculate_null_assert, // saw unexpected null from type speculation
Reason_rtm_state_change,      // rtm state change detected
Reason_unstable_if,           // a branch predicted always false was taken
Reason_unstable_fused_if,     // fused two ifs that had each one untaken
                              // branch. One is now taken.

比如下列的代码会产生对应的reason=null_check

String a = "a";
Object b = "b";
int i = 0;
while (true) {
  if (++i == 100000000) {
    System.out.println("Calling a.equals(b) with b = null");
    b = null;
  }
  a.equals(b);
}
  • make_not_entrant下面是两个例子
<make_not_entrant thread='140562628134656' compile_id='60365' compiler='C1' level='3' stamp='134.137'/>
<make_not_entrant thread='140562623907584' zombie='1' compile_id='60365' compiler='C1' level='3' stamp='142.536'/>


<make_not_entrant thread='140562632365824' compile_id='41640' compiler='C1' level='3' stamp='110.012'/>
<make_not_entrant thread='140562621794048' zombie='1' compile_id='41640' compiler='C1' level='3' stamp='115.470'/>

zombie='1’表示该代码编译已经无效了。
源代码的注解如下。简单来说就是原来的编译已经失效,需要重新编译。

// Make the nmethod non entrant. The nmethod will continue to be
// alive.  It is used when an uncommon trap happens.  Returns true
// if this thread changed the state of the nmethod or false if
// another thread performed the transition.
bool  make_not_entrant() { return make_not_entrant_or_zombie(not_entrant); }
//...
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值