java inlined,有什么可以阻止Java内联方法的吗?

In certain situations java will "inline" a method body to avoid the overhead of the method call, if the method call becomes a bottleneck. However, I can't find any information about anything that will stop java from doing this. E.g. I can imagine perhaps that if the method is non-static or modifies fields, then this could stop java from inlining the method body.

Can all methods be inlined, or are there certain elements of my code that would stop java from inlining a method?

Edit: I do not want to prevent it - I want to understand if there are things that would stop it, so I can avoid doing those things. I'm thinking specifically of things in code (modifiers, field access etc), not jvm args.

解决方案

If your method is too big, or has method which have been inlined too many times already, your method won't get inlined.

Can all methods be inlined, or are there certain elements of my code that would stop java from inlining a method?

There is a number of parameters which control this.

$ java -XX:+PrintFlagsFinal -version | grep Inline

bool C1ProfileInlinedCalls = true {C1 product}

intx FreqInlineSize = 325 {pd product}

bool IncrementalInline = true {C2 product}

bool Inline = true {product}

ccstr InlineDataFile = {product}

intx InlineSmallCode = 2000 {pd product}

bool InlineSynchronizedMethods = true {C1 product}

intx MaxInlineLevel = 9 {product}

intx MaxInlineSize = 35 {product}

intx MaxRecursiveInlineLevel = 1 {product}

intx Tier23InlineeNotifyFreqLog = 20 {product}

bool UseInlineCaches = true {product}

bool UseOnlyInlinedBimorphic = true {C2 product}

Of note: the MaxInlineSize limits the depth of inlining. In general this is not worth increasing as it can increase you code size and slow you program. The FrehInlineSize is the maximum size even frequently called methods will be inlined. I have found that increasing this a little can help for some programs.

The MaxInlineSize is the number of bytes that a small method needs to be to be inlined even if it is not frequently called.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值